Nagios jitter testing

As part of our new SLA we are required to test and repost on jitter across the core of our network on a per MPLS VPN basis. That seemed ok to start with, but a Nagios does not have an ‘out-of-the-box’ jitter test which, when you think about it, is not that surprising. The Cisco routers we use can measure jitter so our solution was to get the Cisco routers to do all the fiddly jitter measuring and Nagios to just jump in, collect the data and the glory! Naturally we’ll need a new test written in Perl to bridge the two together.

1. Set up the Cisco router SLA

ip sla 100
 icmp-jitter 10.0.0.1
 vrf VRFNAME

2. Now schedule the test

ip sla schedule 100 life forever start-time now

Now you can see the results by typing:

# show ip sla statistics 100

Round Trip Time (RTT) for	Index 100
Type of operation:		icmpJitter
	Latest RTT: 7 milliseconds
Latest operation start time: 22:03:37.093 GMT Fri Mar 1 2013
Latest operation return code: OK
RTT Values:
	Number Of RTT: 10		RTT Min/Avg/Max: 7/7/9 
Latency one-way time:
	Number of Latency one-way Samples: 0
	Source to Destination Latency one way Min/Avg/Max: 0/0/0 
	Destination to Source Latency one way Min/Avg/Max: 0/0/0 
Jitter Time:
	Number of SD Jitter Samples: 9
	Number of DS Jitter Samples: 9
	Source to Destination Jitter Min/Avg/Max: 0/1/1 
	Destination to Source Jitter Min/Avg/Max: 0/1/1 
Packet Late Arrival: 0
Out Of Sequence: 0
	Source to Destination: 0	Destination to Source 0
	In both Directions: 0
Packet Skipped: 0	Packet Unprocessed: 0
Packet Loss: 0
	Loss Period Length Min/Max: 0/0
Number of successes: 24
Number of failures: 0
Operation time to live: Forever

We are only after one value here which is near the top ‘ Latest RTT: 7 milliseconds and its just the number ‘7’ we need. the next task is to write a per test which will extract that number periodically and the test should alarm if it goes out of our defined SLA parameters. Here is the script we used:

#! /usr/bin/perl -w

use Net::Telnet::Cisco;
use strict;

my $host = shift;
my $sla_ref = shift;
my $warn = shift;
my $critical = shift;

my $conn = Net::Telnet::Cisco->new(Host => "$host");

$conn->login('username', 'password');

my @shipsla = $conn->cmd("sh ip sla statistics $sla_ref");
my $result;
foreach (@shipsla){
        if (/^\s+Latest RTT: ([0-9]+) milliseconds/){
                $result = $1;
                last;
        }
}

if ($result >= $critical){
print "CRITICAL - Jitter reading : $result ms\n";
exit(2);
}
if ($result >= $warn){
print "WARNING - Jitter reading : $result ms\n";
exit(1);
}

print "OK - Jitter reading : $result ms\n";
exit(0);

With that plugged into Nagios we are now monitoring multiple jitter values for multiple clients.

This entry was posted in Cisco, FreeBSD Administration, Perl, test_cat and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *