Call statistics from your Cisco router using SNMP
[LEFT][B][SIZE=3][URL="http://www.servercare.nl/Lists/Posts/Post.aspx?ID=75"]Call statistics from your Cisco router using SNMP[/URL][/SIZE][/B]
If you are into VOIP using Cisco equipment. You'll understand how important it is to have good metrics. There are many commercial packages available, but this article focuses on the basics. For this you will [U]not [/U]need any commercial software, but it will simply pull the information needed using SNMP, leaving it to you to format it into anything that will be more readable.
[IMG]http://www.servercare.nl/lists/photos/102808_0902_Callstatist1.jpg[/IMG]
[B]Needed: SNMP and Mib's [/B]
Assuming you will be doing this from a Windows based computer you will need the SNMP toolset to start with. In particular the SNMPWalk command will be used in this document. An excellent set of these tools can be found in the open source "net-snmp" project: [URL="http://sourceforge.net/projects/net-snmp/"]net-snmp | Get net-snmp at SourceForge.net[/URL]
Direct link to the download location: [URL="http://sourceforge.net/project/showfiles.php?group_id=12694"]Browse net-snmp Files on SourceForge.net[/URL]
Once installed these will have created a directory with MIB files. To get the most out of SNMPWalk digging into the call statistics we will need to add more Cisco specific MIB information. This can be found here: [URL]ftp://ftp.cisco.com/pub/mibs/v2/[/URL]
Do not simply overwrite all the files already installed in the share/mib folder; as this will later on create a number of error messages (although functionality remains, it is annoying to get all this extra output).
The specific MIB files we need are:
CISCO-CALL-HISTORY-MIB
CISCO-SMI
CISCO-ISDN-MIB
Please note that the files from the location mentioned above need two minor changes to become functional:
[LIST=1][*][I]These are Unix files; meaning they need CR to become CR LF [/I][*][I]The extension is .my and needs to become .txt [/I][/LIST]
Since we only need a few files the most practical way is achieve this is to simply list the files in the web bowser, then copy and paste them into notepad and write the resulting file with the correct name into the mib folder.
[B]Pulling the data [/B]
We are now ready to start pulling the information out of the router. Assuming you know the IP address (or DNS name) of the router and the community string to read SNMP data from the device (usually 'public').
Go to the 'bin' directory and run the following command:
[FONT=Courier New]snmpwalk -m ALL -c public -v2c 172.20.20.3 1.3.6.1.4.1.9.9.26 [/FONT]
–m ALL: it will read all the MIB information you have added and will translate the OID's (Object ID) into readable form.
-c public: the community string
-v2c: We are using version 2 SNMP
172.20.20.3: the IP number of the router
The MIB information we want to read. In this case this represents the Cisco ISDN MIB. More information on this can be found here:
[URL="http://tools.cisco.com/Support/SNMP/do/BrowseOID.do?local=en&translate=Translate&objectInput=1.3.6.1.4.1.9.9.26"]Cisco SNMP Object Navigator[/URL]
This is The MIB module to describe the status of the ISDN
Interfaces on the routers.
The output for this command would be something similar to:
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrLogIf.37.1 = INTEGER: 67 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrLogIf.37.2 = INTEGER: 64 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrAddress.37.1 = STRING: 00541143312929 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrPermission.37.1 = INTEGER: weCanCallEachOther(3) [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrPermission.37.2 = INTEGER: weCanCallEachOther(3) [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrMaxDuration.37.1 = INTEGER: 2147483647 seconds [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrMaxDuration.37.2 = INTEGER: 2147483647 seconds [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrLastDuration.37.1 = INTEGER: 14 seconds [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrLastDuration.37.2 = INTEGER: 456 seconds [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrClearReason.37.1 = STRING: Unallocated/unassigned number [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrClearReason.37.2 = STRING: Normal call clearing [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrClearCode.37.1 = STRING: "0x01" [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrClearCode.37.2 = STRING: "0x10" [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrSuccessCalls.37.1 = Counter32: 5331 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrSuccessCalls.37.2 = Counter32: 0 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrFailCalls.37.1 = Counter32: 0 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrFailCalls.37.2 = Counter32: 0 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrAcceptCalls.37.1 = Counter32: 37793 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrAcceptCalls.37.2 = Counter32: 6077 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrRefuseCalls.37.1 = Counter32: 0 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrRefuseCalls.37.2 = Counter32: 0 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrLastAttemptTime.37.1 = Timeticks: (321505671) 37 days, 5:04:16.71 [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrStatus.37.1 = INTEGER: active(1) [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrStatus.37.2 = INTEGER: active(1) [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrCallOrigin.37.1 = INTEGER: originate(1) [/FONT]
[FONT=Courier New]CISCO-ISDN-MIB::demandNbrCallOrigin.37.2 = INTEGER: answer(2) [/FONT]
If we want more detailed call logging information we need to look at another MIB: 1.3.6.1.4.1.9.9.27 This is the Cisco call history MIB, and gives a whole lot more information. The command:
snmpwalk -m ALL -c public -v2c 172.20.20.3 1.3.6.1.4.1.9.9.27
Results in something looking like this:
[FONT=Courier New]CISCO-CALL-HISTORY-MIB::ciscoCallHistoryTableMaxLength.0 = INTEGER: 100 [/FONT]
[FONT=Courier New]CISCO-CALL-HISTORY-MIB::ciscoCallHistoryRetainTimer.0 = INTEGER: 15 minutes [/FONT]
[FONT=Courier New]CISCO-CALL-HISTORY-MIB::ciscoCallHistoryCallingNumber.012345678 56789 = STRING: "---N/A---" [/FONT]
[FONT=Courier New]CISCO-CALL-HISTORY-MIB::ciscoCallHistoryCallingNumber.012345678 56789 = STRING: "01234567890" [/FONT]
[FONT=Courier New]CISCO-CALL-HISTORY-MIB::ciscoCallHistoryCallingNumber.012345678 56789 = STRING: "01234567890" [/FONT]
[FONT=Courier New]CISCO-CALL-HISTORY-MIB::ciscoCallHistoryCallingNumber.012345678 56789 = STRING: "01234567890" [/FONT]
[FONT=Courier New]CISCO-CALL-HISTORY-MIB::ciscoCallHistoryCallingNumber.012345678 56789 = STRING: "---N/A---" [/FONT]
[FONT=Courier New]CISCO-CALL-HISTORY-MIB::ciscoCallHistoryCallingNumber.012345678 56789 = STRING: "---N/A---" [/FONT]
[FONT=Courier New]CISCO-CALL-HISTORY-MIB::ciscoCallHistoryCallingNumber.012345678 56789 = STRING: "---N/A---" [/FONT]
[FONT=Courier New]CISCO-CALL-HISTORY-MIB::ciscoCallHistoryCallingNumber.012345678 56789 = STRING: "01234567890" [/FONT]
[FONT=Courier New]Etc. etc. [/FONT]
(real numbers have been changed into 01234567890 for this article)
More information on what each OID means can be found here:
[URL="http://support.ipmonitor.com/mibs/CISCO-CALL-HISTORY-MIB/info.aspx"]ipMonitor :: CISCO-CALL-HISTORY-MIB: Cisco Call History[/URL]
[B]Extracting information [/B]
This information needs to be digested to be really useful, and a commercial solution that can do this is for example: [URL="http://www.luteus.biz/Download/LoriotPro_Doc/V4/LoriotProV4Doc/J10-Loriotpro_tools/J10-F6_Cisco_ISDN_History_Call.htm"]Cisco ISDN Call History Collector[/URL] (this page also hosts more information on the OID's b.t.w)
If we do not want to buy a costly solution, but would like to keep track of certain variables, we could choose to monitor only certain variables. Instead of walking the whole tree, we are for example only interested in the total amount of accepted calls on one of the (in this case) two ISDN interfaces.
The variable for this was, as we have seen earlier:
CISCO-ISDN-MIB::demandNbrAcceptCalls.37.1
Since we are using the MIB files, we can refer to it directly instead of using the number associated with this OID. Also, since we only want one variable we will not be walking the SNMP tree, instead we use SNMPGet this time, to simply pick out this one value:
snmpget -m ALL -c public -v2c 172.20.20.3 CISCO-ISDN-MIB::demandNbrAcceptCalls.37.1
(since we are only looking at the end of the branch of this particular tree, SNMPWalk would have given the same result, but this example makes it more clear what we are doing)
The result would be something like:
CISCO-ISDN-MIB::demandNbrAcceptCalls.37.1 = Counter32: [B]37837[/B]
A few minutes later:
CISCO-ISDN-MIB::demandNbrAcceptCalls.37.1 = Counter32: [B]37841[/B]
Of course the same can be done for other interfaces or for outgoing calls. In the same way detailed information on what numbers were dialed etc. can be pulled from the call history, which is kept by default for the last 15 minutes.
Another piece of useful information can be found in the [URL="http://www.cisco.com/pcgi-bin/Support/Mibbrowser/mibinfo.pl?mn=CISCO-POP-MGMT-MIB"]CISCO-POP-MGMT-MIB[/URL] . This will enable you to see the amount of open B channeld on the ISDN interface at the moment of polling. For example:
[FONT=Courier New]C:\mrtg-2.14.3\snmp\usr\bin>snmpwalk -m ALL -c public -v2c 172.20.20.3 isdnBearerOperStatus [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.38 = INTEGER: active(4) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.39 = INTEGER: active(4) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.40 = INTEGER: active(4) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.41 = INTEGER: active(4) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.42 = INTEGER: active(4) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.43 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.44 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.45 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.46 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.47 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.48 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.49 = INTEGER: active(4) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.50 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.51 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.52 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.53 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.54 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.55 = INTEGER: active(4) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.56 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.57 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.58 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.59 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.60 = INTEGER: active(4) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.61 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.62 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.63 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.64 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.65 = INTEGER: active(4) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.66 = INTEGER: idle(1) [/FONT]
[FONT=Courier New]ISDN-MIB::isdnBearerOperStatus.67 = INTEGER: active(4) [/FONT]
The command:
[FONT=Courier New]snmpwalk -m ALL -c public -v2c 172.20.20.3 isdnBearerOperStatus [/FONT]
This is now showing us that there are currently 10 calls being made. It would be possible to execute the command (make a batch file on the desktop for example) for ad-hoc information, or script it to log into a database for graphic representation of calls in progress.
Note that for this to function properly the following MIB's are needed:
CISCO-POP-MGMT-MIB
CISCO-SMI
CISCO-TC
CISCO-VOICE-IF-MIB
DS1-MIB
PerfHist-TC-MIB
C ISCO-ISDN-MIB
[/LEFT]