Reputation: 832
I am trying to extend freeradius statistics to snmp. I want to monitor these values and collect them within rrd files. My problem is that these values should be rrd counter but it appears that counter values needs to retrieve an INTEGER and not a STRING. You can see in this snmpwalk that the value is returned as STRING.
snmpwalk -v2c -c public 127.0.0.1 .1.3.6.1.3.1983.1.1
# output
iso.3.6.1.3.1983.1.1.1.0 = INTEGER: 1
iso.3.6.1.3.1983.1.1.2.1.2.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = STRING: "/bin/cat"
iso.3.6.1.3.1983.1.1.2.1.3.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = STRING: "/var/log/freeradius/statistics/total_access_requests"
iso.3.6.1.3.1983.1.1.2.1.4.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = ""
iso.3.6.1.3.1983.1.1.2.1.5.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 5
iso.3.6.1.3.1983.1.1.2.1.6.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 1
iso.3.6.1.3.1983.1.1.2.1.7.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 1
iso.3.6.1.3.1983.1.1.2.1.20.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 4
iso.3.6.1.3.1983.1.1.2.1.21.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 1
iso.3.6.1.3.1983.1.1.3.1.1.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = STRING: "9566"
iso.3.6.1.3.1983.1.1.3.1.2.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = STRING: "9566"
iso.3.6.1.3.1983.1.1.3.1.3.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 1
iso.3.6.1.3.1983.1.1.3.1.4.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115 = INTEGER: 0
iso.3.6.1.3.1983.1.1.4.1.2.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115.1 = STRING: "9566"
# /etc/snmp/snmpd.conf
extend .1.3.6.1.3.1983.1.1 access_requests /bin/cat /var/log/freeradius/statistics/total_access_requests
The snmp script is extended by printing the value within the file. The file that are used by /bin/cat are generated by the the script /usr/local/sbin/radstat.sh
How do I make this output become an INTEGER?
iso.3.6.1.3.1983.1.1.4.1.2.15.97.99.99.101.115.115.95.114.101.113.117.101.115.116.115.1 = STRING: "9566"
Thanks Dominick
Upvotes: 2
Views: 6621
Reputation: 9877
You probably need to use pass instead of extend, so that your script can specify the type returned. From man snmpd.conf:
pass [-p priority] MIBOID PROG will pass control of the subtree rooted at MIBOID to the specified PROG command. GET and GETNEXT requests for OIDs within this tree will trigger this command, called as:
PROG -g OID
PROG -n OID respectively, where OID is the requested OID. The PROG command should return the response varbind as three separate lines printed to stdout - the first line should be the OID of the returned value, the second should be its TYPE (one of the text strings integer, gauge, counter, timeticks, ipaddress, objectid, or string), and the third should be the value itself.
If the command cannot return an appropriate varbind - e.g the specified OID did not correspond to a valid instance for a GET request, or there were no following instances for a GETNEXT - then it should exit without producing any output. This will result in an SNMP noSuchName error, or a noSuchInstance exception.
A SET request will result in the command being called as:
PROG -s OID TYPE VALUE where TYPE is one of the tokens listed above, indicating the type of the value passed as the third parameter.
If the assignment is successful, the PROG command should exit without producing any output. Errors should be indicated by writing one of the strings not-writable, or wrong-type to stdout, and the agent will generate the appropriate error response.
Upvotes: 2