Ah, I misunderstood at first. I was wondering how a dynamic OID would change within as well. Anyways, you'll want to use the negate plugin.
Here's a working check -
Code: Select all
[root@localhost libexec]# ./check_snmp -H 192.168.5.41 -C nagiosprivate -o IF-MIB::ifIndex.1
SNMP OK - 1 | IF-MIB::ifIndex.1=1
[root@localhost libexec]# echo $?
0
Now, changing it to an invalid MIB -
Code: Select all
[root@localhost libexec]# ./check_snmp -H 192.168.5.41 -C nagiosprivate -o IF-MIB::ifIndex.0
External command error: IF-MIB::ifIndex.0: Unknown Object Identifier (Index out of range: 0 (ifIndex))
[root@localhost libexec]# echo $?
3
Now, run it through negate. I'm using
-u OK to change UNKNOWN -> OK.
Code: Select all
[root@localhost libexec]# ./negate -u OK ./check_snmp -H 192.168.5.41 -C nagiosprivate -o IF-MIB::ifIndex.0
External command error: IF-MIB::ifIndex.0: Unknown Object Identifier (Index out of range: 0 (ifIndex))
[root@localhost libexec]# echo $?
0
So, for you, we need to use -u CRITICAL.
Code: Select all
[root@localhost libexec]# ./negate -u CRITICAL ./check_snmp -H 192.168.5.41 -C nagiosprivate -o IF-MIB::ifIndex.0
External command error: IF-MIB::ifIndex.0: Unknown Object Identifier (Index out of range: 0 (ifIndex))
[root@localhost libexec]# echo $?
2
Hopefully that helps illustrate it for you, let us know if you have any questions.