Script to Monitor E1/BRI Channel Usage

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

celtic6969
Posts: 17
Joined: Wed Jun 22, 2005 10:43 pm

Script to Monitor E1/BRI Channel Usage

Post by celtic6969 »

Hi

I'm sure this question has been asked a couple of times ... I am trying to graph the amount of inbound and outbound voice calls on a Cisco router. Cisco provides a CISCO−POP−MGMT−MIB http://www.cisco.com/en/US/tech/tk648/t ... be59.shtml to collect this info from there AS5xxx servers, but this MIB doesn't populate on their other range of voice routers.

I am trying to locate a script that will:
1. snmpwalk a router and return the "isdnBearerOperStatus"
2. Count all results equalling "active (4)"
3. Return a numeric value which can be graphed in Cacti.

For example, the following output would return a result of "2" ...

[root@cacti/]# snmpwalk -v1 -c public 10.1.1.1 .1.3.6.1.2.1.10.20.1.2.1.1.2
ISDN-MIB::isdnBearerOperStatus.103 = INTEGER: idle(1)
ISDN-MIB::isdnBearerOperStatus.104 = INTEGER: active(4)
ISDN-MIB::isdnBearerOperStatus.107 = INTEGER: idle(1)
ISDN-MIB::isdnBearerOperStatus.108 = INTEGER: idle(1)
ISDN-MIB::isdnBearerOperStatus.111 = INTEGER: active(4)
ISDN-MIB::isdnBearerOperStatus.112 = INTEGER: idle(1)

I'm sure that if someone has some spare time to create a perl or sh script to achieve this functionality it would benefit many people in the VoIP world :D

I tried playingaround with existing "ping.pl" and a few other scripts ... but didn't have a clue what I was doing :-?

TIA
User avatar
kjmattakat
Posts: 15
Joined: Fri Oct 12, 2007 3:03 pm

cisco active calls on PRI

Post by kjmattakat »

I have wanted to graph active calls per PRI on a voice gateway and have not found any MIBs that will do this.

I ended up writing a perl script that will ssh to the router, parse responses to show commands and then return number of active calls. It worked well enough for me and covers multiple PRIs on a gateway.

I am no perl guru, so i am sure there is a better way to handle the ssh. I had to run it once manually on the cacti server when adding the gateway before it would store the key, then it worked fine everytime. I am sure someone more advanced in perl could fix that.

below is a graph, i can export the template and script if anyone is interested. I am running cacti on windows so this is using the w32perl SSh package.
Attachments
graph query
graph query
calls2.JPG (25.08 KiB) Viewed 26558 times
graph
graph
calls.JPG (90.92 KiB) Viewed 26564 times
aleu
Cacti User
Posts: 216
Joined: Mon Dec 11, 2006 10:17 am

Re: cisco active calls on PRI

Post by aleu »

kjmattakat wrote:below is a graph, i can export the template and script if anyone is interested. I am running cacti on windows so this is using the w32perl SSh package.
Please share your template and the script.

Thanks,
AL
User avatar
kjmattakat
Posts: 15
Joined: Fri Oct 12, 2007 3:03 pm

Post by kjmattakat »

I just did an export on the data query template, think that included the other templates, let me know.

The query xml and the perl script are in the sub folders.

you will need to change the $ENV{HOME} to point where you want your keys stored, and change the username and password of course.

Hopefully it works for you. Like i said, i have not had any problems with it. I poll some gateways at 1 min and others at 5 min.

I had to run it once from a command prompt on the cacti server for each gateway i wanted to manage prior to adding the graphs to the gateway. (perl Cisco_Calls.pl <ip_address> index)

FYI - The script pulls the "description" from the T1 controller config.
Attachments
calls.zip
(5.13 KiB) Downloaded 1802 times
aleu
Cacti User
Posts: 216
Joined: Mon Dec 11, 2006 10:17 am

Post by aleu »

kjmattakat wrote:I just did an export on the data query template, think that included the other templates, let me know.
Thanks kjmattakat. It works fine for me.
gonz0
Posts: 8
Joined: Sun Apr 01, 2007 11:28 am
Location: Poland - Warsaw

Post by gonz0 »

I have a problem - I have multiple PRI (E1 controllers) but it shows me only the first PRI - the rest are not shown:

Code: Select all

Cisco Active Gateway Calls  	 (Verbose Query)  	 Uptime Goes Backwards  	 Success [3 Items, 1 Row]
after clicking on VERBOSE QUERY getting this:

Code: Select all

+ Running data query [14].
+ Found type = '4 '[script query].
+ Found data query XML file at '/home/www/cacti/resource/script_queries/Cisco_Calls.xml'
+ XML file parsed ok.
+ Executing script for list of indexes 'perl /home/www/cacti/scripts/Cisco_Calls.pl xxxxxxxxxx index'
+ Executing script query 'perl /home/www/cacti/scripts/Cisco_Calls.pl xxxxxxxxxx  query index'
+ Found item [Index='0/0/0:23'] index: 0/0/0:23
+ Executing script query 'perl /home/www/cacti/scripts/Cisco_Calls.pl xxxxxxxxxx  query name'
+ Found item [name='Serial0/0/0:23'] index: 0/0/0:23
+ Executing script query 'perl /home/www/cacti/scripts/Cisco_Calls.pl xxxxxxxxxx  query description'
+ Found item [descr=''] index: 0/0/0:23
+ Found data query XML file at '/home/www/cacti/resource/script_queries/Cisco_Calls.xml'
+ Found data query XML file at '/home/www/cacti/resource/script_queries/Cisco_Calls.xml'
+ Found data query XML file at '/home/www/cacti/resource/script_queries/Cisco_Calls.xml'
+ Found data query XML file at '/home/www/cacti/resource/script_queries/Cisco_Calls.xml'
But I have more PRI on that device (at the moment 4 PRI, two of them are UP and runnign, two of them are down).

Any help to show another PRI's ?


edited;

at cacti's log file found this:

Code: Select all

ERROR: Empty result [xxxxxx]: 'perl /home/www/cacti/scripts/Cisco_Calls.pl xxxxxx get activeCount 1/0:23'
fix: it should be 1/0:15 at the end - where to change it ?

and this for the same router:

Code: Select all

Empty result [xxxxxx]: 'perl /home/www/cacti/scripts/Cisco_Calls.pl xxxxxx get index 1/0:23'
User avatar
kjmattakat
Posts: 15
Joined: Fri Oct 12, 2007 3:03 pm

Post by kjmattakat »

I only use T1 PRI so the script was set up for D channel on channel 23. I have edited the script to look for the ISDN D channel instead of the serial interface, probably a better way of doing it anyway.

i have attached the new script, run it from the command line first to see what you get, appeared to work for me.

Also, the description is pulled from the 'show controller t1/e1' info, i attempted to make this work with either T1 or E1 based on if the D channel was either 15 or 23. Again this worked for me but i only have T1. Please let me know if all goes well for you.

- Remember to change the $ENV{HOME} and user and password.
Attachments
Cisco_Calls.pl
v0.9.1 (add E1)
(1.73 KiB) Downloaded 963 times
User avatar
kjmattakat
Posts: 15
Joined: Fri Oct 12, 2007 3:03 pm

Post by kjmattakat »

Update:
I added the 'controller' name for the query. Nothing major, should be pretty obvious but might be nice to see in the query.

Here is the new script and xml
Attachments
Cisco_Calls.pl
v0.9.2 (controller name)
(1.91 KiB) Downloaded 1225 times
Cisco_Calls.xml
resource-query_scripts XML file
(1.16 KiB) Downloaded 1339 times
graphcalls.jpg
graphcalls.jpg (88.97 KiB) Viewed 26034 times
querycalls.jpg
querycalls.jpg (25.9 KiB) Viewed 26034 times
gonz0
Posts: 8
Joined: Sun Apr 01, 2007 11:28 am
Location: Poland - Warsaw

Post by gonz0 »

not really

when using E1 the serial interface is also named: serial x/x:23

Only you must change :23 to :15 like this (sorry I am not a programmer) when checking active calls.

Code: Select all

my ($spr1, $spr2) = split (':',$intx);

$intx = $spr1.':15';
why ? because the cmd is like that: show voice call x/x:15

I will post all my changes when see that script working correctly :)
User avatar
kjmattakat
Posts: 15
Joined: Fri Oct 12, 2007 3:03 pm

Post by kjmattakat »

That is dissapointing, Sorry.

could you post a 'show voice call <interface>' and a 'show isdn stat' maybe i can figure something out.
User avatar
kjmattakat
Posts: 15
Joined: Fri Oct 12, 2007 3:03 pm

Post by kjmattakat »

actually 'show voice call summary' and a 'show voice port summary' may be better.
ryusez
Posts: 25
Joined: Thu Sep 28, 2006 9:36 pm

Post by ryusez »

Dear kjmattakat

the Cisco_Calls.pl that can you usage telnet function to access router..

thank you
User avatar
kjmattakat
Posts: 15
Joined: Fri Oct 12, 2007 3:03 pm

Post by kjmattakat »

do you need telnet with username/password or just password?

I could try and create a version that will auto discover telnet/ssh but that will take a little bit and will probably add more time for polling.
ryusez
Posts: 25
Joined: Thu Sep 28, 2006 9:36 pm

Post by ryusez »

Dear kjmattakat

yes, i telnet to router that is require both username/password or
password
gonz0
Posts: 8
Joined: Sun Apr 01, 2007 11:28 am
Location: Poland - Warsaw

Post by gonz0 »

My mistake - of course it is working with :15 in Europe :) forgive my ignorance but as I wrote before I am not a programmer and I can make only simple changes in the script..

=====

about the TELNET - download cisco telnet tools:

use Net::Telnet::Cisco;

my $telnet_session = Net::Telnet::Cisco->new(Host => $h);
$telnet_session->login($user, $pass);
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests