Cacti SNMP data queries Filed Under: Networks
Introduction
Cacti comes with some SNMP data queries but they are the typical ones related to interfaces, but at work were I have Cacti installed I wanted to monitor the temperature of various modules in a Cisco switch so I had to create a custom SNMP data query. So here is the tutorial on how to create a custom SNMP data query.
Creation of a custom data query
Creation of the xml file with the query information
First of all we will need to create our own SNMP data query in a XML file and save it to the folder “resource\snmp_queries” on your cacti installation. You can download the temperature data query I created from here.
Rather than me explaining again the structure of the whole XML file and miss something, you can find more information about the XML syntax from the documentation of Cacti.
Just a tip while you create your custom XML file. Make sure you find the index of the data you are trying to query. Normally It will have in the name of the OID Index
at the end. For example in interfaces is ifIndex
and in the temperature I created it was called entPhysicalChildIndex
.
Creation of a new Data query
First of all save the XML file you created before to the folder “resource\snmp_queries” in your cacti installation.
After you done that then go to your cacti web page and click on Data queries under Collection Methods and create a new Data query.
Fill all the information on that page. Under the Data Input Method on that page select “get SNMP Data (Indexed)”.
When you finish click on Create. For the time being will leave the Associated Graph template for the moment, we will come back to it later on.
Creation of a Data template
Once the data query has being created, we will need to create a new Data template. To do that we will go to Data templates under the templates section, and click on Add to create a new Data template.
Fill all the relevant information on that page. The important parts are:
- Tick the box “Use Per-Data Source Value (Ignore this Value)” on the Name section
- On the Data Input Method select “get SNMP Data (Indexed)”
- Under the Data source Item part you will need to:
- Set the “Internal Data Source” name. This is the name that will be used later on other templates.
- set the “Maximum Value” if you require.
- select the type of Data source type. Gauge if the output will display the actual value (like temperature) or Counter if the output is a value that increases on every reading and you want just the difference (like the traffic on a network interface).
After you done with typing all the required fields click on Create. This will make appear a new section at the bottom of the page. In this new section make sure you have ticked:
- Output Type ID
- Index Value
- Index Type
Creation of a Graph Template
After we have created our Data Template to capture the data to graph we will need to create a Graph Template to graph the data. To create a Graph Template go to the Graph Templates section under Templates and click on Add to add a new one.
On that new page add the appropriate text to the Name, Title and Vertical Label fields.
Click on the button Create. After that we will need to create the items that will appear on the template. For doing this step click on Add on the Graph Template Items section at the top of the page.
For each data output to draw do the following:
- Select the data source that we created in the previous step.
- Select the color you want your data to appear.
- Select the graph item type you want. Normally I select Area.
- Fill the Text Format section with the relevant name.
- Click on create to add to the Graph Template
To create the legend at the bottom of the graph like all other Cacti graphs do the following:
- Select the same data source as before (the one we created in the previous step).
- Do not select any color
- On the Graph Item Type select the option LEGEND.
- Click on create and this will create all the values for the legend automatically
Associate the Graph Template with the Data query
As the final step we will need to associate the Graph Template we just created with the Data query we created in the first step. So to do that, go back to your Data query and in the section “Associated Graph Templates” that we left empty at the beginning click on Add.
On the new page type a name and select the Graph Template we created before .To finish click on Create.
On the following page under the section “Associated Data Templates” click on the tick box for the Data sources that you want to use to draw the graph. Note that if you forget this step even if you select an specific item to graph later on it will not create you the rrd file and therefore not draw you the graph.
Next fill the “Suggested Values section”. For example for the Data template part you could type:
- On the first part: |host_description| – |query_entPhysicalDescr| – Temperature
- On the Field Name part: name
For example on the Graph Template part you could type:
- On the first part: |host_description| – |query_entPhysicalDescr| – Temperature
- On the Field Name part: title
Finish
With all these steps you have created your custom SNMP data query. Now the only thing remaining to do is to select a device where you want to apply the data query and start graphing. Your Data query will be on the drop down box of the “Associated Data Queries” at the bottom of the device page.
Tags: cacti, data query, snmp
- Permalink
- Alberto Diaz
- 7 Sep 2008 4:06 PM
- Comments (3)
January 14th, 2011 at 14:11
Hi and thanks for the introduction.
I have an problem indexing a mib-tree off the cisco-mib 1.3.6.1.4.1.9.9.13.1.3, this guys at cisco did not index this table in the common way. The table entries are indexed 60011-60032 for example, but there is no index table available :-(. Do you think its possible to index by unique strings like the entryname?
I wish cisco would know what they do and stop changing there coding style every minor release.
January 14th, 2011 at 15:26
Hi Boa,
The mib you are looking has an index but in not accessible according to the cisco documentation and also is the top object in the mib so you need to go down that branch to find the readable objects. Check the Cisco SNMP navigator at http://tools.cisco.com/Support/SNMP/do/BrowseOID.do?local=en
For some extra information the index is called ciscoEnvMonTemperatureStatusIndex (not accessible) that is part of ciscoEnvMonTemperatureStatusEntry. Some entries you can access are ciscoEnvMonTemperatureStatusDescr, ciscoEnvMonTemperatureStatusValue and some others.
Hope this helps
October 21st, 2011 at 13:55
It is actually a nice and helpful piece of information. I’m glad that you shared this helpful information with us. Please keep us up to date like this. Thank you for sharing.