Custom Monitoring MySQL and SNMP with BixData - Page 2

Example 3: Collecting SNMP Data


Basically all SNMP devices have an interface table that gives you basic statistics on bytes sent and received link status (up/down), link speed, etc. You get snmp values from a device by issuing a command like

snmpget -v1 -c public hostname OID

Where hostname is the name of the snmp device and OID is the special SNMP string.

First let's make a script that can query SNMP devices for Interface statistics (bytes in and out). I will be using snmpget from Net-SNMP and python. But you could use perl and other SNMP modules.

You can get the latest script from It is BSD license which means you are free to use and expand it.

At the top of the script there is a list of hosts and Interface IDs that you can replace with your own. To find out what interface IDs your host has, issue the following command:

snmpwalk -v 1 -c public hostname interfaces.ifTable.ifEntry.ifDescr

Here is the section in

hostIntf = { "" : 19, "" : 18415 }

As you can see I am getting stats on interface 19 on 192.168.11 and interface 18415 on You can add as many hosts and interfaces as you want. The rest of the script simply executes the snmpget command to get the data and outputs it in this format:

host :
interface : 18415
in : 1441849
out : 317351

host :
interface : 19
in : 10540
out : 1395103

SNMP Step 1

Download the script from and copy it to bixagent/data/scripts.

SNMP Step 2

Do an snmpwalk on your SNMP devices to determine their interface IDs.

snmpwalk -v 1 -c public hostname interfaces.ifTable.ifEntry.ifDescr

The output will look like this:

IF-MIB::ifDescr.1 = STRING: Switch Port 1
IF-MIB::ifDescr.200 = STRING: Switch Port 200

Here the '.1' and '.200' are the IDs. So edit and add those ids:

hostIntf = { "hostname" : 1, "hostname" : 200 }

SNMP Step 3

Next run the script to make sure it works.

cd bixagent/data/scripts

SNMP Step 4

Add the script to bixagent/data/xml/dp-import.xml.

  <path>python data/scripts/</path>

This tells BixData what fields to expect.

SNMP Step 5

In BixDesktop connect to your BixAgent and under real-time graph choose 'Custom'. Navigate to the BixSNMP namespace and add the counters you want to see.

Navigating SNMP data

In/out are cumulative while rate is the rate over the sample period. The following screenshot shows an example of realtime data:

Real-time graph of SNMP data

All other components in BixData such as Service Checks and Notifications will now work with SNMP.

SNMP Step 6

Next we want to create graphs. You can download the graph used in this example and copy it to bixserver/data/reporting/templates/, or you can follow these steps to create a graph.

Connect to your BixServer and then:

  • Go to Reporting, Setup Templates
  • Click the + button and select New Graph
  • Enter a reportName and description
  • Click on the big + button next to streams to browse for streams. You can add as many streams as you want.
  • Click 'Save changes Yes' and you can add the report to your Report Setup

Hopefully this gives you an idea of the flexibility of BixData. As you can see it is an easy tool to use and extend that should be able to adapt to your particular monitoring needs. Once you have a script that produces data, the chore of collecting, storing and visualizing data is taken care of by BixData. You can download some of the scripts from their site, and since the scripts are BSD license you can make them your own.

Share this page:

Suggested articles

0 Comment(s)

Add comment