With Nagios, I want to read a device name of hundreds of Ubiquity devices. This value has one OID on some of them and another on others. The best way I got so far is using this script:
$1/check_snmp -H $2 -o .1.2.840.10036.3.1.2.1.3.5 > /tmp/$2.snmp.nagios.tmp
status=$?
if [ $status -ne 0 ]; then
$1/check_snmp -H $2 -o .1.2.840.10036.3.1.2.1.3.9 > /tmp/$2.snmp.nagios.tmp
status=$?
fi
cat /tmp/$2.snmp.nagios.tmp
exit $status
What I don't like here is that it uses filesystem, but I don't know how to read output of a command to one variable and exit code of the command to another variable.
Is there a way to write this so it uses variables only?
Isn't there a better way to achive the main goal?