I have two scripts that take values from SAR and place them in a log file (one example):
rxkBps=`sar -n DEV 1 295 | tail -n1 | awk '{print $5}'`
rxMbps=$(echo "scale=2;$rxkBps/128" | bc -l)
echo $rxMbps >./rxMbps.log
exit
That number is always a decimal number (ex: .06).
In snmpd.conf I've added an extend section for both scripts that takes that number and associates it with its OID represented by in this example Get_rxMbps:
extend Get_rxMbps /bin/sh /usr/local/bin/Get_rxMbps.sh
When I run an snmpwalk over NET-SNMP-EXTEND-MIB::nsExtendObjects I get back the information but it sees it as a string and our monitoring software can't convert or use the string information.
NET-SNMP-EXTEND-MIB::nsExtendCommand."Get_rxMbps" = STRING: /bin/sh
NET-SNMP-EXTEND-MIB::nsExtendArgs."Get_rxMbps" = STRING: /usr/local/bin/Get_rxMbps.sh
NET-SNMP-EXTEND-MIB::nsExtendInput."Get_rxMbps" = STRING:
NET-SNMP-EXTEND-MIB::nsExtendCacheTime."Get_rxMbps" = INTEGER: 5
NET-SNMP-EXTEND-MIB::nsExtendExecType."Get_rxMbps" = INTEGER: exec(1)
NET-SNMP-EXTEND-MIB::nsExtendRunType."Get_rxMbps" = INTEGER: run-on-read(1)
NET-SNMP-EXTEND-MIB::nsExtendStorage."Get_rxMbps" = INTEGER: permanent(4)
NET-SNMP-EXTEND-MIB::nsExtendStatus."Get_rxMbps" = INTEGER: active(1)
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."Get_rxMbps" = STRING: .83
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."Get_rxMbps" = STRING: .83
NET-SNMP-EXTEND-MIB::nsExtendOutNumLines."Get_rxMbps" = INTEGER: 1
NET-SNMP-EXTEND-MIB::nsExtendResult."Get_rxMbps" = INTEGER: 0
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Get_rxMbps".1 = STRING: .83
I'm new to this and inheriting someone else's work so if there is a better way I'm open for that as well, but I need SNMP to see and use that number as an integer not a string.