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!


This is a beta version of the script: use it at your own risk!


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:


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 you can run

./ciscocbqos -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;host name=&quot;MYCISCODEVICE&quot;&gt;
			qos.items content goes here
			qos.graphs content goes here

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/telecommunications industry in the late '90s; I'm now a system and network engineer with a deep knowledge of the global Internet and its core architectures, and a strong focus on network automation.

Latest posts by Pier Carlo Chiodi (see all)


  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:


    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?


    • pierky says:


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

      • Vip says:


        Yes the SNMP string is correct.

        TEST [root@machine~]$ ./ciscocbqos -c public +trafficshaping +d | more
        host:, 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


  4. Alexandre says:

    I did this command line:
    ./ciscocbqos -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.

      • jharold says:

        Hi Pierk, are u ok?

        I´m using your script, but I can´t collect the items CIR (cbQosPoliceCfgRate64), can u help me?


  5. jj says:

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

  6. Jeimy Oliveira says:

    Where are I can find the script ?

Leave a Reply