Friday, December 3, 2010

MRTG Graphing of VoIP Sessions on Cisco IP-to-IP Gateway




Just a quick post. I would like to share this helpful PERL script created by Yasin Kaplan,especially to those who use MRTG as part of their daily network traffic monitoring task.

Cisco does not provide an OID for fetching number of VoIP sessions on an IP-to-IP Gateway. One way to plot number of VoIP sessions using MRTG is explained below. You need IOS version >= 12.4 on the Cisco gateway.

IOS command “show call leg active event -log” gives total number of call legs established on a Cisco gateway. Half of this number gives actual VoIP session s established on a Cisco IP-to-IP Gateway:

Cisco#show call leg active event-log
Total call-legs: 268


You can get updated number of sessions information periodically telnet into gateway. MRTG allows console output of shell or PERL scripts as data source in place of SNMP OIDs. Following PERL script can be used to get number of active call legs form a Cisco Gateway:

monitor# more /usr/local/bin/voip_sess.pl
#!/usr/bin/perl
use Net::Rsh;

my $mgw = $ARGV[0];

my $voip_sess;
my @greped;

$a=Net::Rsh->new();

@c=$a->rsh($mgw,"root","root","sh call leg act event-log");
@greped=grep(/^Total/, @c);

if ($greped[0] =~ m/Total call-legs: (\d+)/) {
$voip_sess = sprintf("%.0f", $1/2);
print "$voip_sess\n$voip_sess\n0\n0\n";
} else {
print "0\n0\n0\n0\n";}

You need to add following configuration to Cisco Gateway in order the gateway permit incoming
RCMD request:

ip rcmd rsh-enable
ip rcmd remote-host root 101 root enable
ip rcmd remote-username root
ip rcmd source-interface
!
access-list 101 remark **** RCMD Access Control ****
access-list 101 permit ip host 192.168.10.1 any

Finally add a profile to your “mrtg.cfg” script to read number of VoIP sessions. MRTG user must have necessary rights to run “voip_sess.pl” (chmod +x /usr/local/bin/voip_sess).

Target[Number_of_VoIP_Sessions]: `/usr/local/bin/voip_sess.pl 192.168.10.2`
MaxBytes[Number_of_VoIP_Sessions]: 500
YLegend[Number_of_VoIP_Sessions]: Active sessions
Options[Number_of_VoIP_Sessions]: growright, integer, gauge
Title[Number_of_VoIP_Sessions]: Number of Active VoIP Sessions (Cisco)
PageTop[Number_of_VoIP_Sessions]: < h1 >Number of Active VoIP Sessions
(Cisco)
< h1 >


Scripts are heaven-sent to make network administration tasks easier. Hope this helps.

Ron