I extended(extend-sh) the functionality of Net-SNMP snmpd with a shell script which echoes "empty" in case the condition checked with the script is true. However, there seems to be multiple OIDs which contain this string- nsExtendOutput1Line."backup", nsExtendOutputFull."backup" and nsExtendOutLine."backup".1. Which one is the correct OID to monitor? What is the best practice here? Just for information, "backup" is simply the name token. In addition, similar behavior can be seen in Net-NMP wiki in retrieving value section.

1 Answer 1


Which OID to use depends on what your script outputs, and what part of it are you interested in, and perhaps what is easier to process inside the monitoring system checking those OIDs.

The OID in SNMP is just a (standardised) naming of something that the snmpd knows about.

With OIDs having strings inside them, the strings is converted most often to numbers by counting the characters, and then adding each character's ASCII code to it. For example, "hello" (5 characters long) would become

You can check this with snmptranslate:

% snmptranslate .

But back to the question. The various OIDs you can check via the extend configuration helps to fetch several properties from the run of the extend script.

To see all the features, consider this executable sh script that outputs two lines, and returns an arbitrary values, configured as an extend hello /usr/local/sbin/myscript

echo today
exit 33

The output via snmpwalk can be:

% snmpwalk -v2c -c mysecretcommunity localhost .
NET-SNMP-EXTEND-MIB::nsExtendOutput1Line."hello" = STRING: today
NET-SNMP-EXTEND-MIB::nsExtendOutputFull."hello" = STRING: today
Sat Dec 19 15:59:59 UTC 2015
NET-SNMP-EXTEND-MIB::nsExtendOutNumLines."hello" = INTEGER: 2
NET-SNMP-EXTEND-MIB::nsExtendResult."hello" = INTEGER: 33

So, the OIDs you can examine are:


The first line of the script output. If the script you are interested in has only a single line of output, or all important data is on the first line, use this.


If your scripts prints more than one lines, and you need to record all of those, this may be better.


The number of lines in the script output. If all you are interested in how many lines are in the output, use this. If your script prints a line for each file it processes, and you are interested only how many files are processed, this can be what you need.


If you are interested to see if the script failed or succeeded, and it returns an appropriate exit code, this OID will return that.

NET-SNMP-EXTEND-MIB::nsExtendOutLine."hello".1 = STRING: today
NET-SNMP-EXTEND-MIB::nsExtendOutLine."hello".2 = STRING: Sat Dec 19 16:02:44 GMT 2015

If you know which specific line contains information interesting for your, you can fetch the specific line number with the above OIDs.

These and a lots more should be available and documented (though in a fairly technical way) in the MIB files for this OID on your system on a location like /usr/share/snmpd/mibs/NET-SNMP-EXTEND-MIB.txt

So it all depends on what you need to process and/or monitor from the script you run.

Please note as SNMP is UDP based, and many agents will time out, and/or resend the request if a response is not seen within the configured timeout, the script may run several times, and/or can be run without the result visible from the monitoring station. It's best to use this for very short running scripts only (i.e. completing within a few seconds under all circumstances).

Another approach may be to start a background process that then must be protected against concurrent runs via appropriate locking methods. If the latter raises more questions, I'm afraid they may be answered better in a different topic, depending on the operation to be done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.