Files
Cactidocumentation/How-To-Existing-SNMP-Data-Queries.md
T
Thomas Vincent 741ad51355 docs: [1.2.x] refresh the front page, correct grammar and Markdown, and align plugin pages with their READMEs (#273)
* docs: [1.2.x] refresh the manual front page

The front page opened with version notes before saying what Cacti is,
used headings as sentences in the credits, and its table of contents
listed seven sections while the page has ten.

Open with a short description and a getting-started sequence, link the
website and forums, give the credits real headings, and list every
section in the table of contents in page order. Record Jeff Pasnak
under In Memoriam with a link to the 1.2.31 release announcement.
Correct label typos and wrap long entries with reference links.

Existing section anchors are unchanged, and every page is still linked.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs: [1.2.x] fix typos, unrendered headings and forum links

A check of every page linked from the front page found misspellings in
eleven pages, three Mactrack headings written without a space after the
hashes, which render as plain text, and two forum links still using
http.

Correct the spellings, add the missing space so the headings render,
and point the forum links at https, where they already redirect.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs: [1.2.x] align the plugin pages with the plugin READMEs

The supported plugins list and the Syslog and Mactrack pages had drifted
from the README and INFO files in the plugin repositories.

Update the descriptions that the READMEs contradict: Monitor's Thold
requirement, the Router Configs transfer methods, the ReportIt release
and Cacti versions, the WMI collection methods and its development
status, and NUT support in Apcupsd. Add the Syslog requirements, the
upgrade procedure, the dedicated database settings and the remote
collector settings, and correct the database grant and a misplaced
code fence. Add the Mactrack requirements and a short section on
history partitioning and ignored ports that links to the README.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs: [1.2.x] correct grammar, spelling and broken Markdown

A read of every page linked from the front page found grammar and
spelling errors throughout, and Markdown that does not render as
intended.

Correct grammar, spelling, punctuation and product-name capitalization
in 95 pages without changing headings, code blocks, link targets or
the meaning of the text. Repair the Markdown defects: a code fence in
the SSH tunnel how-to that never closed, malformed bold markers in the
user management and device defaults pages, a release notes table with
no blank line before it, split rows in the tree sorting table, and
LDAP list items missing their markers. Correct three interface labels
quoted with typos.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* docs: [1.2.x] correct statements that differ from the 1.2.x source

Reviewers of the linked pages flagged statements that looked wrong.
Each was compared with the Cacti 1.2.x source at 1523aa04b, and only
those the source or the page itself settles are changed.

Correct interface labels and option names (Index Count Changed,
Permissive, Not Selected, Utilities, the BCC description, the gear
icon for plugin install), the default Maximum Value of U for a new
data source item, the sysDescr object name, the PHP floor wording in
the requirements table, the Mactrack wildcard character and the
snmptrapd -On option. Repair cross-references, example values that
disagree with their commands, two table captions, a split list and
several sentences with missing words.

Statements the source does not settle are left as written.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
2026-11-24 00:58:06 -08:00

8.4 KiB

SNMP Data Queries

Walkthrough: A New SNMP Data Query

For SNMP Queries, you won't need to create a data retrieval script. Cacti will use SNMP to retrieve information. But Cacti will need additional information on how the indexed data is structured. Think about a table (a MIB table in this case); you'll have to tell Cacti about the table structure. This is done by defining an XML file. Basically, you have to define the index to tell Cacti about the number of rows and about their unique index. This index is later used to access each rows data. Furthermore, you may define columns that serve as descriptive fields to be shown in the selection table. The XML file knows them as

<direction>input</direction>

You will have to define those fields that will be queried for the readings, e.g. ifInOctets, ifOutOctets, ifInErrors, … The XML file knows them as

<direction>output</direction>

Let's have an example: standard Interface MIB with the corresponding part of the <path_cacti>/resource/snmp_queries/interface.xml file are displayed using the following table:

SNMP Table 1

SNMP Table 2

SNMP Table 3

and see the corresponding table structure when defining New Graphs for that Device (my laptop):

Creating graph for Data Query

Now you can map

  • Index: IF-MIB::ifIndex

  • Status: IF-MIB::ifOperStatus

  • Description: IF-MIB::ifDescr

  • Type: IF-MIB::ifType

  • Speed: IF-MIB::ifSpeed

All those are <direction>input</direction> Parameters. They serve as descriptive information to each row to help you identify the proper interface to use. Those parameters of <direction>output</direction> can be compared to output parameters of a script (see ping.pl script above). These are the readings from the device. By selecting the appropriate row (the one grayed out had been selected by me), you tell Cacti to retrieve data from the interface defined by this index. But how does Cacti know what output parameters it shall retrieve? See the Select a Graph Type to Create dropdown. It specifies a Graph Template defined for this Data Query. The Graph Template in turn references a Data Template which incorporates the needed output parameters as Data Sources. This works quite the same way as defined for a Data Input Method.

To sum up: the SNMP XML file is somehow a replacement for the Data Input Method described above to be used on indexed values. It tells Cacti what data it should retrieve (direction: output). To help you identify the relevant indexes, the XML defines descriptive parameters (direction: input) to be displayed in the selection table.

A walkthrough for this is given now. It is based on the already supplied interface.xml XML file.

Create a Data Query to tell cacti how to retrieve data

Go to Data Queries and click the plus (+) glyph to see:

Add new Data Query

Here, we are using the already existing interface.xml file. Select Get SNMP Data (Indexed) as Data Input Method. Press Create to see:

Fill Data for Data Query

See that Cacti found the XML file. Don't bother with the Associated Graph Templates at the moment. The success message does not include checking of the XML file's content. Now let's proceed to the next definitions.

Create a Data Template to tell Cacti how to store data

This is the exact copy of the definitions made above. So I do not repeat everything here. Data Input Method must be selected as Get SNMP Data (Indexed). As this data source is a COUNTER type, select this as the Data Source Type. But after saving the new Data Source definition, you may want to define a second Data Source to the same Data Template. To do so, select New from the Data Source Item heading to see:

Enter new Data Source Item

The name of the internal RRDtool Data Source (ifOutOctets) is not replaced in the Tab until you save your work. By default, Maximum Value is set to U (no maximum). You may keep it or set a reasonable value (e.g. interface speed); all readings above a maximum will be stored as NaN by RRDtool. Don't forget to specify COUNTER! You will have noticed that the name of the data source does not match the Name in the interface.xml. Don't worry, the solution to this is given later on. Before leaving, pay attention to the bottom of the page:

Check Indexes for Data Query Data Template

This is specific to indexed Data Queries. You will have to check the last three items to make indexing work. All other items should be left alone; their values will be taken from the appropriate device definitions. Now click Save and you're done with this step.

Note that if you wish to hand Edit mappings of various indexed interfaces manually for each Graph in the future, you should check the following three fields Index Type, Index Value and Output Type ID as shown below. Do this for each Data Template Data Source Items in the Data Template.

Force the Indexes to be Hand Editable

Create a Graph Template to tell cacti how to present the data

Since creating a new Data Query based upon an existing Data Query called SNMP - Interface Statistics we don't need to create any Graph Templates, we can use the ones created for the other Data Query.

Add Graph Template to the Data Query

Now it's time to re-visit our Data Query. Remember the Associated Graph Template we've left alone in the very first step? Now it will get a meaning. Go to Data Queries and select our new one. Then press the plus (+) glyph, and select Interface - Traffic (bits/sec) from the drop down as shown below. Press Create to initialize the association of this Graph Template with our new Data Query.

Add new associated Graph Template

Once we press the Create button, we should get an image like the one below. From here, it's important that we associate the Data Sources to the XML file columns that retrieve the data using SNMP. Press the Save button to complete the mapping of Data Sources to the XML file Data Source Output Values.

Creating new associated Graph Template

In addition, we need to set up any Suggested Values as you can see from the example below. Suggested Values are optional when the Data Query can have a multitude of suggested names based upon the output from the Data Query. For both the Suggested Values - Graphs and Suggested Values - Data Sources, we must include the name of the column, and the Suggested Value which can include the special tag |query_xmlcolumn| as shown in the examples below.

Suggested Values for Associated Graph Template

Once the Associated Graph Template mappings have been completed, you should see the image below, where we have:

  • Mapped the internal Data Template Data Sources to the XML file Input Data Sources

  • Added any Suggested Values for the Graph Title or other Graph fields

  • Added any Suggested Values for the Data Source name or other Data Source fields

Associated Graph Template Completed

Once you have confirmed all the values, you can press Return to return to the Data Query page for our Example Data Query as shown below.

Save Associated Graph Template

Apply the Data Query to your Device

Now go to your Device to add the Associated Data Query:

Apply Data Query to your Device

Click Add and then Create Graphs for this Device to see:

Create Graphs for Data Query

Now select the wanted Interfaces and press Create to generate the Traffic Graph. As long as there's only one Associated Graph Template for that Data Query, there will be no Associated Graph Type drop down. Once you create more than one Associated Graph Template for the Data Query, you will see a drop down just above the Create button showing the available Graph Templates for the Data Query in question, like the SNMP - Interface Statistics as shown below.

Additional Associated Graph Templates Example

Pressing the Set Default button will set the selected Graph Type to be the default for this Data Query.


Copyright (c) 2004-2026 The Cacti Group