Getting custom OID from device into LibreNMS

Hello all,

I’m relatively new to LibreNMS (and SNMP).

I’m trying to inject/extend/add/pass a custom OID into SNMP and have it show in LibreNMS.

The device is a Raspberry Pi with a temperature probe. I already have this working and I can get the temperature value no problem.

In my /etc/snmp/snmpd.conf I have the following line:
extend .1.3.6.1.2.1.5.26.1 temp_hi_in /bin/sh /home/tempmonitor/gettemp.sh

Where gettemp.sh contains the following:
#!/bin/bash
SENSOR=$1
SLAVE="/sys/bus/w1/devices/28-666a741f64ff/w1_slave"
OUTPUT=$(/usr/bin/cat $SLAVE | /usr/bin/awk -F 't=' ' { printf $2 } ')
echo .1.3.6.1.2.1.5.26.1
echo guage
echo $OUTPUT

If I run /bin/sh /home/tempmonitor/gettemp.sh I get the following output:

root@tempmonitor:~# /bin/sh /home/tempmonitor/gettemp.sh
.1.3.6.1.2.1.5.26.1
guage
14562

If I run this command snmpwalk -v3 -l auth -u {user} -a MD5 -A {MD5pass} localhost .1.3.6.1.2.1.5.26.1 I get the output below:

root@tempmonitor:~# snmpwalk -v3 -l auth -u {user} -a MD5 -A {MD5pass} localhost .1.3.6.1.2.1.5.26.1 IP-MIB::icmpOutAddrMaskReps.1.1.0 = Wrong Type (should be Counter32): INTEGER: 1 IP-MIB::icmpOutAddrMaskReps.1.2.1.2.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): STRING: "/bin/sh" IP-MIB::icmpOutAddrMaskReps.1.2.1.3.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): STRING: "/home/tempmonitor/gettemp.sh" IP-MIB::icmpOutAddrMaskReps.1.2.1.4.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): "" IP-MIB::icmpOutAddrMaskReps.1.2.1.5.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): INTEGER: 5 IP-MIB::icmpOutAddrMaskReps.1.2.1.6.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): INTEGER: 1 IP-MIB::icmpOutAddrMaskReps.1.2.1.7.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): INTEGER: 1 IP-MIB::icmpOutAddrMaskReps.1.2.1.20.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): INTEGER: 4 IP-MIB::icmpOutAddrMaskReps.1.2.1.21.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): INTEGER: 1 IP-MIB::icmpOutAddrMaskReps.1.3.1.1.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): STRING: ".1.3.6.1.2.1.5.26.1" IP-MIB::icmpOutAddrMaskReps.1.3.1.2.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): STRING: ".1.3.6.1.2.1.5.26.1 guage 14500" IP-MIB::icmpOutAddrMaskReps.1.3.1.3.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): INTEGER: 3 IP-MIB::icmpOutAddrMaskReps.1.3.1.4.10.116.101.109.112.95.104.105.95.105.110 = Wrong Type (should be Counter32): INTEGER: 0 IP-MIB::icmpOutAddrMaskReps.1.4.1.2.10.116.101.109.112.95.104.105.95.105.110.1 = Wrong Type (should be Counter32): STRING: ".1.3.6.1.2.1.5.26.1" IP-MIB::icmpOutAddrMaskReps.1.4.1.2.10.116.101.109.112.95.104.105.95.105.110.2 = Wrong Type (should be Counter32): STRING: "guage" IP-MIB::icmpOutAddrMaskReps.1.4.1.2.10.116.101.109.112.95.104.105.95.105.110.3 = Wrong Type (should be Counter32): STRING: "14500"

Obviously I can see above a few errors but not sure if they are relevant nor how to fix them.

Finally in LibreNMS I have created a Custom OID with a type ‘Gauge’ using the OID .1.3.6.1.2.1.5.26.1 but it either displays nothing as the value or 0 as the value returned. I’ve tried deleting, re-adding and re-discovering but nothing.

Would appreciate if someone could lend a hand.

Alternatively, is there a way that I can ‘send’ a value to LibreNMS or have Libre NMS ‘get’ a value from a remote file (text or .json)?

Thanks in advance!

I would try to do this as a bit more of a standard extend.

First, I would just chmod +x your gettemp.sh script to simplify it in snmpd.conf. And then make sure you can run it as whatever user your snmpd process is run as (root, Debian-snmp, etc.).

I would remove echo .1.3.6.1.2.1.5.26.1 and echo guage from the script so that only the actual value is output.

Then I would put something like…
extend temp_hi_in /home/tempmonitor/gettemp.sh
…in your snmpd.conf.

This should give you two snmp walks to check.

snmpwalk -Os -v3 -l auth -u {user} -a MD5 -A {MD5pass} localhost NET-SNMP-EXTEND-MIB::nsExtendConfigTable

…should show you the setup info for the temp_hi_in extend. This is just for setup confirmation.

snmpwalk -On -v3 -l auth -u {user} -a MD5 -A {MD5pass} localhost NET-SNMP-EXTEND-MIB::nsExtendOutput1Table

…should show you the actual outputs. From that output grab the specific OID that has the temperature value you’re looking for and put that in CustomOID.

1 Like

Thanks so much for taking the time to reply.

YES!! Success! (Sorry for the upper case, I’ve been on this for days!)>

Really appreciate you taking the time to help, thank you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.