Use/Convert snmp STRING to a useable output value

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
jfchevrette
Posts: 1
Joined: Fri Mar 19, 2010 2:45 pm

Use/Convert snmp STRING to a useable output value

Post by jfchevrette »

Hello,

I am trying to figure out how I can use a snmp STRING value in my data query. When running my snmp query by hand, this it what I get:

Code: Select all

# snmpwalk -v1 -cpublic IP .1.3.6.1.4.1.789.1.21.1.2.1.25
SNMPv2-SMI::enterprises.789.1.21.1.2.1.25.1 = STRING: "22C (71F)"
SNMPv2-SMI::enterprises.789.1.21.1.2.1.25.2 = STRING: "21C (69F)"
SNMPv2-SMI::enterprises.789.1.21.1.2.1.25.3 = STRING: "23C (73F)"
SNMPv2-SMI::enterprises.789.1.21.1.2.1.25.4 = STRING: "26C (78F)"
SNMPv2-SMI::enterprises.789.1.21.1.2.1.25.5 = STRING: "26C (78F)"
SNMPv2-SMI::enterprises.789.1.21.1.2.1.25.6 = STRING: "25C (77F)"
SNMPv2-SMI::enterprises.789.1.21.1.2.1.25.7 = STRING: "26C (78F)"
SNMPv2-SMI::enterprises.789.1.21.1.2.1.25.8 = STRING: "24C (75F)"
I would like to use the first integer as the value for my ds. I tried many different approach su as using VALUE/REGEXP in my <source> tag and I can't get it to work.

Code: Select all

<enclTempSensorsCurrentTemp>
         <name>CurrentTemp</name>
         <method>walk</method>
         <source>VALUE/REGEXP:^([0-9]*)C.*</source>
         <direction>output</direction>
         <oid>.1.3.6.1.4.1.789.1.21.1.2.1.25</oid>
</enclTempSensorsCurrentTemp>
I can see the following warnings in my logs and my RRDs are not being filed with the correct values (only zeroes)

Code: Select all

Poller[0] Host[5] DS[122] WARNING: Result from SNMP not valid.  Partial Result: 55C (131
Poller[0] Host[5] DS[123] WARNING: Result from SNMP not valid.  Partial Result: 50C (122
Poller[0] Host[5] DS[123] WARNING: Result from SNMP not valid.  Partial Result: 23C (73
Poller[0] Host[5] DS[123] WARNING: Result from SNMP not valid.  Partial Result: 55C (131
Poller[0] Host[5] DS[124] WARNING: Result from SNMP not valid.  Partial Result: 50C (122
Poller[0] Host[5] DS[124] WARNING: Result from SNMP not valid.  Partial Result: 26C (78
Poller[0] Host[5] DS[124] WARNING: Result from SNMP not valid.  Partial Result: 55C (131
Poller[0] Host[5] DS[125] WARNING: Result from SNMP not valid.  Partial Result: 50C (122
Poller[0] Host[5] DS[125] WARNING: Result from SNMP not valid.  Partial Result: 26C (78
From what I've read, it is possible that VALUE/REGEXP cannot be used for an output field. However, the cacti documentation says it can be used.

Any ideas?

Thanks !
lex
Posts: 4
Joined: Wed Jul 21, 2010 4:37 pm

Post by lex »

I'm having the same problem with similar data:

Code: Select all

35 C/95 F
The VALUE/REGEXP feature doesn't work with the direction set to output, I've read through the sourcefiles and found the proof that it only works with the direction set to input.
From lib/data_query.php: (the only file that contains the string 'VALUE/REGEXP')

Code: Select all

}else if (($field_array["method"] == "walk") && ($field_array["direction"] == "input")) {
[..]
                        }elseif (substr($field_array["source"], 0, 11) == "OID/REGEXP:") {
[..]
                        }elseif (substr($field_array["source"], 0, 13) == "VALUE/REGEXP:") {
[..]
@developers: please fix this as the REGEXP feature would be very handy to use with output values.
lex
Posts: 4
Joined: Wed Jul 21, 2010 4:37 pm

Post by lex »

Is this forum still alive? :(
Can one of the developers at least confirm this, as I've read in other topics that this should work with output values...
JGoude
Posts: 1
Joined: Mon Dec 14, 2015 4:15 pm

Re: Use/Convert snmp STRING to a useable output value

Post by JGoude »

At the moment, same issue, fortigate firewall

[root@iepmon rra]# snmpwalk -c public -v 2c 1.1.1.1 .1.3.6.1.4.1.12356.101.4.3.2.1.3
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.1 = STRING: "3.2856"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.2 = STRING: "5.048"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.3 = STRING: "12.136"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.4 = STRING: "0.9903"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.5 = STRING: "1.0491"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.6 = STRING: "0.9315"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.7 = STRING: "1.7841"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.8 = STRING: "1.5097"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.9 = STRING: "1.04"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.10 = STRING: "2.464"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.11 = STRING: "11.904"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.12 = STRING: "1.136"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.13 = STRING: "0.736"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.14 = STRING: "0"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.15 = STRING: "3.264"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.16 = STRING: "3.264"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.17 = STRING: "3.264"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.18 = STRING: "1.04"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.19 = STRING: "46"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.20 = STRING: "45"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.21 = STRING: "43"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.22 = STRING: "43"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.23 = STRING: "35"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.24 = STRING: "42"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.25 = STRING: "37"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.26 = STRING: "38"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.27 = STRING: "42"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.28 = STRING: "4800"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.29 = STRING: "5200"
SNMPv2-SMI::enterprises.12356.101.4.3.2.1.3.30 = STRING: "4900"


Value/Regexp or OID/regexp does not work with Output values?
Is editing data_query.php a possible solution?
jantram
Posts: 12
Joined: Mon Aug 27, 2012 1:25 pm

Re: Use/Convert snmp STRING to a useable output value

Post by jantram »

My first fix for this was a php script to pull the point and return (print dsname:value) it as a data point, using the string manipulations in php. I feel like this is very SLOW. I'd like to redo this in the cacti scripting engine ( where PHP and DB hooks exist already ) and see what sort of improvement can be had there. ( Reading on that tonight. )

I am planning to rewrite the php script so it handles all the string OID's from a host type and returns them en-mass to one RRD file, to reduce php startup overhead; walk the OIDs in a batch/get table and then manipulate the results and return them all at once. This would be more efficient, process wise but also lock all the data points to the same refresh/get rate.

My final option is to recompile spine with the no_snmp_string_return and see what spine returns from those points. This might give you both numerics mushed together, guessing from your snmpwalk results pasted above.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests