Search code examples
snmpnet-snmp

SNMP pass command returning OID error but apparently running on server


I'm just moving my first steps with SNMP, I'm trying to add the output of a simple check script to SNMP but I'm facing some issues. I'm trying to add a temperature check file for a Raspberry Pi 4 to be returned via SNMP to a remote poller, but just following most of the guides online lead to me to nothing, since I'm stuck with this error every time:

No Such Instance currently exists at this OID

I'm trying using the pass function but I had no luck getting any result. Currently this is what I declared in the snmpd.conf file:

pass 1.3.6.1.2.1.25.1.8 /bin/bash /script/check_temp.sh

This is the command output:

/script/check_temp.sh
.1.3.6.1.2.1.25.1.8
integer
589

This is the command output from the poller:

snmpget -c test -v 2c 1.2.3.4 .1.3.6.1.2.1.25.1.8
HOST-RESOURCES-MIB::hrSystem.8 = No Such Instance currently exists at this OID

But if I try to run snmpd in foreground I don't actually see any error, seems instead that the script is executed:

sudo snmpd -f -Le -Ducd-snmp/pass -Drun
registered debug token ucd-snmp/pass, 1
registered debug token run, 1
NET-SNMP version 5.7.3
ucd-snmp/pass: pass-running:  /bin/bash /usr/script/check_temperature/check_temp.sh -g .1.3.6.1.2.1.25.1.8
run:exec: running '/bin/bash /usr/script/check_temperature/check_temp.sh -g .1.3.6.1.2.1.25.1.8'
run:exec:   got 120000 bytes
run:exec:   child 7480 finished. result=768

What am I doing wrong? None of the guides I checked mentioned creating MIBS, or any other further steps than I'm already doing, but I'm still getting nothing of what I'm expecting.

Thanks in advance for any hint or suggestion that'll get me on the right way.


Solution

  • I hope this could help anybody trying to configure SNMP checks for their Raspberry, or any other tipycal Linux device, since most of the guides I checked were assuming you would already know some SNMP concepts, while it's possible that while you are just starting you are still not mastering them. Most of the guides will either state to use extend or passas following:

    view all included .1.3.6.1.4.1

    pass .1.3.6.1.4.1.9999.1 /bin/bash /path/to/command
    
    extend checkcommand /bin/bash /path/to/command
    

    Like this, I faced the issues of my original question; I was able to get things working only when I added the following lines, providing an empty OID branch to the extend function and the view all accessibility to the .1.3.6.1.4.1 branch:

    view all included .1.3.6.1.4.1
    
    extend .1.3.6.1.4.1.9999.1 checkcommand /bin/bash /path/to/command
    

    This way I actually get a reply from snmpwalk, and from snmpwalk result on OID .1.3.6.1.4.1.9999.1 you can retrieve the OID snmpd builds for the output of the script, in order to use it to make snmp queries from a poller.

    I know this probably is the basis, but all the tutorials and guides I read at first were likely implying one or more of these steps, so I hope this can be of help to any other SNMP beginner.