SNMP query - ifIndex is not at the end of the OID

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
daveram
Posts: 10
Joined: Wed Oct 18, 2023 5:02 am

SNMP query - ifIndex is not at the end of the OID

Post by daveram »

Thanks for taking the time to look at my post!

I've copied the standard interfaces interface XML for use with the SNMP query, in order to add additional metrics - in this case some optical metrics for monitoring power on ADVA interfaces.

As an example,
An interface in question: IF-MIB::ifDescr.190 = STRING: node 1 interface 1/1/p1 opt-phy

I'm already successfully monitoring transmitted power, as per this section I've added in the XML. This works fine as the ifIndex for this particular metric appears at the end of the OID.
<aosCoreFacCurrOpticalPowerTx>
<name>CurrentOptPowerTx</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2544.1.20.1.3.2.1.1.2</oid>
</aosCoreFacCurrOpticalPowerTx>

The next few metrics I want to monitor however, the ifIndex is not at the end, as per the below.
aosCoreFacHist15MinOpticalPowerRxLow .1.3.6.1.4.1.2544.1.20.1.3.2.2.1.3.(ifIndex).1

I've attempted doing this by using both regular expressions in the XML, and also the oid_suffix.
The oid_suffix seemed to be the easier way of doing this, but isn't working. Details of this I found in table 12-4 within the following page - https://docs.cacti.net/Data-Queries.md

Here are the examples of both of these methods as I've implemented them. In both cases, I'm getting -nan values returns in the graph.

REGEXP method;
<aosCoreFacHist15MinOpticalPowerRxLow>
<name>Optical Power Rx Low</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2544.1.20.1.3.2.2.1.3.1.1</oid>
<oid_index_parse>OID/REGEXP:.*\.([0-9]{1,2})\.[0-9]{1,2}$</oid_index_parse>


OID_SUFFIX method;
<aosCoreFacHist15MinOpticalPowerRxLow>
<name>Optical Power Rx Low</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2544.1.20.1.3.2.2.1.3</oid>
<oid_suffix>.1</oid_suffix>
</aosCoreFacHist15MinOpticalPowerRxLow>


A disclaimer - I've been using Cacti for about a month, so am very new to this, so please bear with me if I've asked a very simple question. I have tried to answer this myself through the forums and documentation, but have hit a wall with it.

I'd greatly appreciate any help anyone might be able to give.
I've attached the complete XML (with the regexp method), as well as the verbose query output.

Many thanks
Attachments
verbose query output.txt
(119.95 KiB) Downloaded 12 times
XML query.txt
(9.98 KiB) Downloaded 9 times
User avatar
Osiris
Cacti Guru User
Posts: 1424
Joined: Mon Jan 05, 2015 10:10 am

Re: SNMP query - ifIndex is not at the end of the OID

Post by Osiris »

A few things:

1) it's not good to modify the stock data queries
2) Create a separate data query and start from scratch. Not that hard
3) oid_suffix can work, but applies to all measures.
4) you may have to read the code in lib/data_query com
Before history, there was a paradise, now dust.
daveram
Posts: 10
Joined: Wed Oct 18, 2023 5:02 am

Re: SNMP query - ifIndex is not at the end of the OID

Post by daveram »

Thanks for the reply.
I've now created the XML from scratch with only the additional sections for the OIDs I'm interested in. At that basic level, it's working fine.

I won't use the oid_suffix as don't want it to be applied to everything.

So instead am trying to get the regexp line to work, which presumably I can apply to just one field?

I've been searching through existing forum threads, and this is the closest I've come to one that matches my requirement;
viewtopic.php?t=25285
However I'm still not having any luck.

<aosCoreFacCurrOpticalPowerRx>
<name>CurrentOptPowerRx</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2544.1.20.1.3.2.1.1.1</oid>
</aosCoreFacCurrOpticalPowerRx>
<aosCoreFacCurrOpticalPowerTx>
<name>CurrentOptPowerTx</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2544.1.20.1.3.2.1.1.2</oid>
</aosCoreFacCurrOpticalPowerTx>

### Added the REGEXP below, to add the trailing .1 at the end of the OID after the ifIndex. ###
<aosCoreFacHist15MinOpticalPowerRxLow>
<name>Optical Power Rx Low</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2544.1.20.1.3.2.2.1.3</oid>
<oid_index_parse>OID/REGEXP:.*\.([0-9]{1,3}\.1)$</oid_index_parse>
</aosCoreFacHist15MinOpticalPowerRxLow>

Likelihood is I'm just doing it wrong. It seems from various old articles that the functionality to be able to this was due to be added in a patch, but I can't tell whether it was ever done.

Please could someone tell me whether a) this is possible and b) whether the above is correct
c) if not, how on earth do I do it?? :)

Many thanks!
daveram
Posts: 10
Joined: Wed Oct 18, 2023 5:02 am

Re: SNMP query - ifIndex is not at the end of the OID

Post by daveram »

Solved.

This is working with the below XML config;

<aosCoreFacHist15MinOpticalPowerRxLow>
<name>Optical Power 15 min Rx Low</name>
<method>walk</method>
<source>value</source>
<direction>output</direction>
<oid>.1.3.6.1.4.1.2544.1.20.1.3.2.2.1.3</oid>
<oid_suffix>1</oid_suffix>
</aosCoreFacHist15MinOpticalPowerRxLow>

The query made by Cacti using this for an an interface with ifIndex of 190, for example, looks like;
.1.3.6.1.4.1.2544.1.20.1.3.2.2.1.3.190.1
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests