As said in my previous post about this topic, I’ve made a small Perl script to build Zabbix configuration for Cisco Class-Based QoS monitoring.
As first, I have to say I’m NOT a Perl programmer, so I think real Perl programmers will find my script a shocking jumble of code. I apoligize!
Any suggestion would be appreciate!
Disclaimer
This is a beta version of the script: use it at your own risk!
Download
You can find the script here. It requires Net::SNMP module (“apt-get install libnet-snmp-perl” on Debian to install it).
What it does
This script lets you to monitor Cisco QoS stats and counters in your Zabbix NMS using the builtin SNMP agent. You can store the same stats you can see with a “show policy-map interface …” command and have graphs built on them.
You can get values from class-maps, match statements, traffic policing and shaping.
How it works
When you run the script (with proper arguments!) it walks through the SNMP MIB of your device and discovers QoS policies layout; then, it builds Zabbix items and graphs about objects it finds.
How to use it
Unfortunately Zabbix has a quite complex database structure, so I preferred to use the builtin import/export feature instead of manipulating tables directly in my script to add items and graphs.
The output is formatted on the basis of the Zabbix XML configuration file.
To use the script you have to export your Cisco device configuration from the Zabbix Configuration / Export/Import menu, then merge the script’s output within the <host> XML element and, finally, import the new XML file into Zabbix.
Usage is pretty simple:
./ciscocbqos HOST [-c SNMP_COMMUNITY] -o OUTPUT_PATH OBJECTS_TO_MONITOR
Here, HOST is the Cisco device IP address, SNMP_COMMUNITY is the SNMP read community (default to public), and OBJECTS_TO_MONITOR is a list of one or more objects you want to add to Zabbix (objects are class-maps, match statements, traffic policing and traffic shaping). More options are available: you can see the full help just running ./ciscocbqos without any argument.
For example, if you want to monitor traffic-shaping on router at 192.168.0.1 you can run
./ciscocbqos 192.168.0.1 -c myreadcommunity -o /root/qos +trafficshaping
Once done, you will find /root/qos.items and /root/qos.graphs files containing a scrap of Zabbix XML file to merge with your existing configuration. At this point all you have to do is to put qos.items and qos.graphs content inside the <host> XML element of the exported Zabbix file (line 17 and 18 of the following example).
<?xml version="1.0"?> <zabbix_export version="1.0" date="21.04.09" time="17.59"> <hosts> <host name="MYCISCODEVICE"> <useip>1</useip> <dns></dns> <ip>192.168.0.1</ip> <port>10050</port> <status>0</status> <groups> <group>Router</group> </groups> <templates> <template>Template_Cisco_Device</template> <template>Template_MyOwnTemplate</template> </templates> qos.items content goes here qos.graphs content goes here </host> </hosts> <dependencies> </dependencies> </zabbix_export>
Zabbix keys and SNMP indexes
As you know Zabbix uses keys to uniquely identify items within a host; SNMP agent gets those values from devices and stores them using their keys. This script can be ran in two ways to build Zabbix keys: with or without the +p option.
You should use the +p option only if your device has the “snmp mib persist cbqos” command in the configuration. This option lets the script to build keys based on the SNMP indexes: if you use the “snmp mib persist cbqos” command indexes are maintained after device restart.
With no “snmp mib persist cbqos” command in the config, you should run the script without the +p option, in order to build Zabbix keys on the basis of a hash of items descriptions. In this scenario you have to run the script every time you restart your device, cause SNMP indexes will change and Zabbix items will be outdated.
The cbqos keyword was added starting from IOS 12.4(4)T.
Some graphs
Here are some Zabbix graphs generated using the script:
Latest posts by Pier Carlo Chiodi (see all)
- Good MANRS for IXPs route servers made easier - 11 December 2020
- Route server feature-rich and automatic configuration - 13 February 2017
- Large BGP Communities playground - 15 September 2016
Hi,
small patch for the debug section :
Hi, I have one problem, i hope you can help me.
I want to do some SLA monitor, and I write a script to find all the OIDS about SLA in one router, and generate one xml file, then i import this xml file to the zabbix server.
but there is one big problem, some OIDs change along with time, so some oids i added to the zabbix server does not work after some time, because the OIDS change, so how can i do with these?
OIDS like:
1: rttMonStatsCaptureCompletions.1.95768378.1.1.1 60
2: rttMonStatsCaptureCompletions.1.96128379.1.1.1 3
3: rttMonStatsCaptureCompletions.5.95768350.1.1.1 60
4: rttMonStatsCaptureCompletions.5.96128352.1.1.1 3
5: rttMonStatsCaptureCompletions.10.95768355.1.1.1 60
6: rttMonStatsCaptureCompletions.10.96128357.1.1.1 3
7: rttMonStatsCaptureCompletions.15.95768385.1.1.1 60
8: rttMonStatsCaptureCompletions.15.96128387.1.1.1 3
9: rttMonStatsCaptureOverThresholds.1.95768378.1.1.1 0
10: rttMonStatsCaptureOverThresholds.1.96128379.1.1.1 0
look forward your reply ,thank you
Hi Penxiao,
I don’t know how the “SLA monitor” SNMP works, but I can suggest you to check out the following Zabbix feature:
Advanced SNMP monitoring – Use of dynamic indexes
http://www.zabbix.com/documentation/1.8/manual/advanced_snmp/dynamic_indexes
Bye,
Pierky
Hi,
I am having problems here, I can generate items file but there is no data in them.
Can you please advise what I need to do from here please?
Thanks,
Vip
Hi,
is the router configured for SNMP? Are you using the right SNMP community in the script (with the -c arguments)?
Hi,
Yes the SNMP string is correct.
TEST [root@machine~]$ ./ciscocbqos 1.1.1.1 -c public +trafficshaping +d | more
host: 1.1.1.1, port: public, community: 161
(in) – if type 2 (Sub-if GigabitEthernet0/1.1) – cbQosServicePolicyIndex: 384 – cbQosIfType: 2
cbQosObjectsIndex: 384 – cbQosConfigIndex: – cbQosObjectsType =
cbQosObjectsIndex: 131072 – cbQosConfigIndex: 1593 – cbQosObjectsType = 2
cbQosObjectsIndex: 65538 – cbQosConfigIndex: 609120741 – cbQosObjectsType = 3
cbQosObjectsIndex: 65539 – cbQosConfigIndex: 1897308695 – cbQosObjectsType = 8
cbQosObjectsIndex: 131073 – cbQosConfigIndex: 1594 – cbQosObjectsType = 3
cbQosObjectsIndex: 65536 – cbQosConfigIndex: 378475901 – cbQosObjectsType = 2
cbQosObjectsIndex: 1 – cbQosConfigIndex: 123816106 – cbQosObjectsType = 1
cbQosObjectsIndex: 65537 – cbQosConfigIndex: 581663196 – cbQosObjectsType = 3
This is the qos.items file
TEST [root@machine~]$ more qos.items
TEST [root@machine~]$
This is the qos.graphs file file
TEST [root@machine ~]$ more qos.graphs
Thanks,
Vip
It creates the file, but it is pretty empty.
Like this:
“”
“”
Like this, but cannot put in < and / where they begin and end
"graphs"
"graphs"
Hi,
I’ve the same problem like VIP.
Have you find a solution to this issue ?
Thanks you for you feedback !
R
I did this command line:
./ciscocbqos 10.10.3.254 -c public -o /tmp/resultados +trafficshaping
But response is: ERROR: Traffic-shaping – The requested table is empty or does not exist.
And how are all OBJECTS_TO_MONITOR options that can i set at command?
OBJECTS_TO_MONITOR may be one (or more) of the following:
+classmap Class maps
+matchstatement Match statements
+police Police
+trafficshaping Traffic shaping
If you got that error may be your device does’nt support QoS SNMP.
Hi Pierk, are u ok?
I´m using your script, but I can´t collect the items CIR (cbQosPoliceCfgRate64), can u help me?
tks.
maybe the script can be updated to zabbix 2.x?
zabbix has changed many objects
https://zabbix.org/wiki/Export_changelog#Changes_from_1.8_till_2.0
Where are I can find the script ?