Zabbix tool for Cisco Class-Based QoS monitoring

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).

&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;zabbix_export version=&quot;1.0&quot; date=&quot;21.04.09&quot; time=&quot;17.59&quot;&gt;
	&lt;hosts&gt;
		&lt;host name=&quot;MYCISCODEVICE&quot;&gt;
			&lt;useip&gt;1&lt;/useip&gt;
			&lt;dns&gt;&lt;/dns&gt;
			&lt;ip&gt;192.168.0.1&lt;/ip&gt;
			&lt;port&gt;10050&lt;/port&gt;
			&lt;status&gt;0&lt;/status&gt;
			&lt;groups&gt;
				&lt;group&gt;Router&lt;/group&gt;
			&lt;/groups&gt;
			&lt;templates&gt;
				&lt;template&gt;Template_Cisco_Device&lt;/template&gt;
				&lt;template&gt;Template_MyOwnTemplate&lt;/template&gt;
			&lt;/templates&gt;
			qos.items content goes here
			qos.graphs content goes here
		&lt;/host&gt;
	&lt;/hosts&gt;
	&lt;dependencies&gt;
	&lt;/dependencies&gt;
&lt;/zabbix_export&gt;

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:

Traffic policing

Traffic policing

Traffic policing class-map

Traffic policing class-map

Interface overview (stack of class-map)

Interface overview (stack of class-map)

The following two tabs change content below.
Italian, born in 1980, I started working in the IT area in the late '90s; I'm now a system and network administrator with a deep knowledge of the global Internet and its core architectures.

14 Comments

  1. Hi,

    small patch for the debug section :

    --- ciscocbqos.orig     Fri May 15 13:55:27 2009
    +++ ciscocbqos  Fri May 15 13:56:23 2009
    @@ -331,7 +331,7 @@
     
     if( $DEBUG == 1 )
     {
    -       printf( "host: %s, port: %s, community: %s", $Host, $Community, $Port );
    +       printf( "host: %s, port: %s, community: %s", $Host, $Port, $Community );
     }
     
     my ($session, $error) = Net::SNMP->session(
    
  2. penxiao says:

    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

  3. Vip says:

    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

    • pierky says:

      Hi,

      is the router configured for SNMP? Are you using the right SNMP community in the script (with the -c arguments)?

      • Vip says:

        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

  4. Alexandre says:

    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?

    • pierky says:

      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.

  5. jj says:

    maybe the script can be updated to zabbix 2.x?

Leave a Reply