[mrtg] isco 3600 ISDN In active calls and voice ovepip calls status by external perl script (mrtg)

Maxat maxat.abdugapparov at telecom.kz
Fri Nov 26 08:58:37 MET 2004


Hi,All

First we need onfigure a Router to Use rsh


You can use rsh to execute commands on remote systems to which you have
access. When you issue the rsh command, a shell is started on the remote
system. The shell allows you to execute commands on the remote system
without having to log in to the target host.

You do not need to connect to the system, router, or access server and then
disconnect after you execute a command if you use rsh. For example, you can
use rsh to remotely look at the status of other devices without connecting
to the target device, executing the command, and then disconnecting. This
capability is useful for looking at statistics on many different routers. 


Remotely Execute Commands Using rsh


You can use rsh to execute commands remotely on network servers that support
the remote shell protocol. To use this command, the  .rhosts files (or
equivalent files) on the network server must include an entry that permits
you to remotely execute commands on that host. 

If the remote server has a directory structure, as do UNIX systems, the rsh
command that you issue is remotely executed from the directory of the
account for the remote user that you specify through the /user username
keyword and argument pair. 

If you do not specify the /user keyword and argument, the Cisco IOS software
sends a default remote username. As the default value of the remote
username, the software sends the remote username associated with the current
TTY process, if that name is valid. If the TTY remote username is invalid,
the software uses the router host name as the both the remote and local
usernames.

To execute a command remotely on a network server using rsh, use the
following commands in privileged EXEC mode: 


Step 

Command 

Purpose 



1 .

 

enable [password]

Enter privileged EXEC mode.



2 .

 

rsh {ip-address | host} [/user username] remote-command

Enter the rsh command to be executed remotely. 

 


 

The following example executes the "ls -a" command in the home directory of
the user sharon on mysys.cisco.com using rsh:

Router# enable
Router# rsh mysys.cisco.com /user sharon ls -a
.
..
.alias
.cshrc
.emacs
.exrc
.history
.login
.mailrc
.newsrc
.oldnewsrc
.rhosts
.twmrc
.xsession
jazz
Router#

 

 

Note : you must enable privilege access to run only these rsh commands not
other commands
Commands are:
show isdn active
show dial-peer voice 2  
 
####Perl scripts#########BEGIN##########
 
 
-------------------------Get only IN calls---------------but you can change
the scrip to grab in and out calls
1.script
isdn_count.pl
 
 
#!/usr/bin/perl
open (input, "rsh -l root cisco_ip_address show isdn active | ")  or die
"Can't find article $INFO: $!\n";
my($total,$count);
while (<input>)
{
if (/In/,) {                               ### Commentary only in calls
$total += $_;
$count++;
}
}
print  "$count\n"; ##Active calls count
print "0\n";
print "0\n";
print "0\n";
 
 
----------------------------------------------------------------------------
-
2. isdn_status.pl    (To get only successful cals)
 
 
#! /usr/bin/perl
 
my $str;
my $stra;
open (input, "rsh -l root cisco_ip_address show dial-peer voice 2 |")  or
die "Can't find article $INFO: $!\n";
while (<input>)
{
if (/Successful Calls = /,) {
 
s/Successful Calls = //;
s/Failed Calls = //;
s/Incomplete Calls = //;
s/,//;
s/,//;
s/^//;
$stra=$_;
($arr[1],$arr[2],$arr[3]) = split(/\ /,$stra);
}
}
print "$arr[1]\n"; ##Successful calls to mrtg
print "0\n";
print "0\n";
print "0\n";
 
----------------------------------------------------------------------------
-----
 
 
3. isdn_failed_calls.pl
 
#!/usr/bin/perl
my $stra;
open (input, "rsh -l root cisco_ip_address  show dial-peer voice 2 |")  or
die "Can't find article $INFO: $!\n";
while (<input>)
{
if (/Failed Calls = /,) {
 
s/Successful Calls = //;
s/Failed Calls = //;
s/Incomplete Calls = //;
s/,//;
s/,//;
s/^//;
$stra=$_;
($arr[1],$arr[2],$arr[3]) = split(/\ /,$stra);
}
}
print "$arr[2]\n"; ##Failed calls to mrtg
print "0\n";
print "0\n";
print "0\n";
 
--------------------------------------------------------------
Note Array arr[1] = Successful calls
       arr[2]=Failed calls
arr[3]=Incomplete calls
-----------------------------------------
 
#############END Scripts#####################
 
 
####Mrtg config file####
File name is cisco_calls.cfg
 
##ISDN active calls###
workdir: /usr/local/www/data/mrtg/cisco_3640
Target[cisco_3640_activecall]: `/usr/bin/perl /path/to your
file/isdn_count.pl`
MaxBytes[cisco_3640_activecall]: 30
YLegend[cisco_3640_activecall]: In ISDN Calls
ShortLegend[cisco_3640_activecall]: calls
LegendI[cisco_3640_activecall]: &nbsp;calls:
LegendO[cisco_3640_activecall]: &nbsp;calls:
PageTop[cisco_3640_activecall]: <h1>In isdn active calls cisco_3640name</h1>
Title[cisco_3640_activecall]: isdn active -- cisco_3640
 <TABLE>
    <TR><TD>Device:</TD><TD>device_name</TD></TR>
    <TR><TD><a href="/mrtg/mrtg.html">HOME</a></TD></TR>
 </TABLE>
Options[cisco_3640_activecall]: gauge
 
###Successful cals###
 
Target[cisco_3640_success_calls]: `/usr/bin/perl /path/to your
file/isdn_status.pl`
MaxBytes[cisco_3640_success_calls]: 1000000
YLegend[cisco_3640_success_calls]: Success Calls
ShortLegend[cisco_3640_success_calls]: calls
LegendI[cisco_3640_success_calls]: &nbsp;calls:
LegendO[cisco_3640_success_calls]: &nbsp;calls:
PageTop[cisco_3640_success_calls]: <h1>VoiceOverIpPeer2 Successful  calls
cisco_3640name</h1>
Title[cisco_3640_success_calls]: isdn stat -- cisco_3640
 <TABLE>
     <TR><TD>Device:</TD><TD>device_name</TD></TR>
     <TR><TD><a href="/mrtg/mrtg.html">HOME</a></TD></TR>
 </TABLE>
Options[cisco_3640_success_calls]: gauge
 
###isdn_failed_calls.pl#####
 
Target[cisco_3640_failed_calls]: `/usr/bin/perl /path/to your
file/isdn_failed_calls.pl`
MaxBytes[cisco_3640_failed_calls]: 10000
YLegend[cisco_3640_failed_calls]: Failed Calls
ShortLegend[cisco_3640_failed_calls]: calls
LegendI[cisco_3640_failed_calls]: &nbsp;calls:
LegendO[cisco_3640_failed_calls]: &nbsp;calls:
PageTop[cisco_3640_failed_calls]: <h1>VoiceOverIpPeer2 Failed  calls
cisco_3640name</h1>
Title[cisco_3640_failed_calls]: isdn stat -- cisco_3640
 <TABLE>
    <TR><TD>Device:</TD><TD>device_name</TD></TR>
    <TR><TD><a href="/mrtg/mrtg.html">HOME</a></TD></TR>
 </TABLE>
Options[cisco_3640_failed_calls]: gauge
 
 
And run this config file as 
 
/usr/local/bin/mrtg  /path/to your config file/cisco_calls.cfg
 
Use only for own risk
But this script was tested on 
Mrtg host is freebsd 5.0 Release and mrtg version 2.9.25
Router is cisco 3640
IOS (tm) 3600 Software (C3640-IS-M), Version 12.2(21), RELEASE SOFTWARE
(fc3) 
Good luck!!!


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list