The Cacti Manual
Prev | Chapter 10. Data Queries | Next

# SNMP Query XML Syntax

    <query>
       <name>Get SNMP Interfaces</name>
       <description>Queries a host for a list of monitorable interfaces</description>
       <oid_index>.1.3.6.1.2.1.2.2.1.1</oid_index>

       <fields>
          <ifIndex>
             <name>Index</name>
             <method>walk</method>
             <source>value</source>
             <direction>input</direction>
             <oid>.1.3.6.1.2.1.2.2.1.1</oid>
          </ifIndex>
       </fields>
    </query>

Table 10-4. SNMP Query XML Field Reference

Field | Description
--- | ---
query->name | (Optional) You can enter a "friendly name" for the SNMP query here. It will not be used by Cacti, and is for identification only.
query->description | (Optional) You can enter a description for the SNMP query here. It will not be used by Cacti, and is for identification only.
query->oid_index | Every SNMP query must have an OID that represents the index values for the query when walked. As described above, any data query in Cacti must contain a field that uniquely identifies each row returned by the query. In the example above, the oid_index points to the OID of ifIndex in the interface MIB.
query->fields | Each field contained within the SNMP query must be defined under this tag.
query->fields->ifIndex | Each defined field in the SNMP query must have a unique name given to it. Do not use spaces or any non-alphanumeric characters, this name must be identifiable within Cacti.
query->fields->ifIndex->name | Here you can specify a "friendly name" for the field. This name will be used by Cacti to help the user identify this field.
query->fields->ifIndex->method | Tell Cacti how you want it to gather SNMP information for this field. Valid values are 'walk' and 'get'. The 'get' method obtains a list of indexes and does an snmpget for each index of the OID specified for this field. The walk method simply does a walk of the OID specified for this field. Both methods will return the same values, even though the 'walk' method is typically more efficient.
query->fields->ifIndex->source | When Cacti obtains a list for this field, you need to tell it how to derive its value for each row. Valid options here are 'value', 'OID/REGEXP:(regexp_match)', and 'VALUE/REGEXP:(regexp_match)'. The 'value' option simply returns the result of the snmpget for each row. The 'OID/REGEXP:(regexp_match)' can be used when you need to use a POSIX-based regular expression to derive the value from the OID. The most common example of this is to retreive the IP address of an interface, and can be seen in the 'interface.xml' file. Finally, the 'OID/REGEXP:(regexp_match)' option can be used to parse the value based on a regular expression, returning the first match.
query->fields->ifIndex->direction | There are two types of fields when dealing with an SNMP query, 'input' and 'output'. Input values are the "known" values that you will use to derive the output values, this is where the "query" part of SNMP query comes in. When you create a graph based on an SNMP query, Cacti will prompt you to choose the input value to base the graph on. A rule of thumb is that input fields contain semi-static data that is not graphable, while the output fields contain the data that will be graphed.
query->fields->ifIndex->oid | You must specify the actual OID that corresponds with the field. Each value for this field can be obtained by doing an snmpget on 'oid.(each)snmpindex'.

Prev | Home | Next
Data Queries | Up | Script Query XML Syntax