Page 1 of 1

[Solved] How to alert on toner level?

Posted: Fri May 02, 2014 12:36 pm
by jbruyet
Hey all, I found the OIDs for the toner levels in several of my printers and I'd like to have Nagios send me an alert when they get down to 5%. I did find a couple of complicated check files on the Nagios Exchange but I just need to see how to alert when a number gets down to a certain value.

Thanks,

Joe B

Re: How to alert on toner level?

Posted: Fri May 02, 2014 1:03 pm
by sreinhardt
What plugin are you going to use to check them? Most checks will have a -w and -c for warning and critical, but they can have different notation for usage.

Re: How to alert on toner level?

Posted: Fri May 02, 2014 1:59 pm
by jbruyet
I wasn't sure which plugin to use because every one I've seen so far alerts on incrementing values and I want it to alert on decrementing values; to send an alert when the value drops to 5(%).

Thanks,

Joe B

Re: How to alert on toner level?

Posted: Fri May 02, 2014 2:19 pm
by sreinhardt
Could you show us a result of an snmpwalk on that printer, and identify the oid you are looking to use?

Re: How to alert on toner level?

Posted: Fri May 02, 2014 3:52 pm
by jbruyet
Hi sreinhardt, here are the four OIDs I'm looking at:

Code: Select all

SNMPv2-SMI::mib-2.43.11.1.1.9.1.1 = INTEGER: 0
SNMPv2-SMI::mib-2.43.11.1.1.9.1.2 = INTEGER: 68
SNMPv2-SMI::mib-2.43.11.1.1.9.1.3 = INTEGER: 47
SNMPv2-SMI::mib-2.43.11.1.1.9.1.4 = INTEGER: 80
The first one is a zero because it's an empty black toner cartridge. This printer sits in dispatch and needs to be available all the time. Another time I caught the low toner in Finance just before I would have been injured -- we're in the middle of an audit.

On an unrelated note, why do some Nagios files look fine in Notepad (yeah, I know) and others need something like Wordpad to display correctly?

Thanks,

Joe B

Re: How to alert on toner level?

Posted: Mon May 05, 2014 10:16 am
by sreinhardt
On an unrelated note, why do some Nagios files look fine in Notepad (yeah, I know) and others need something like Wordpad to display correctly?
I got a chuckle out of that one. This is just because of differing line endings. All nagios configs should have unix line endings, which notepad does not respect, but wordpad or notepad++(highly suggested) do.

As for tests on those OIDs, try something like:

Code: Select all

./check_snmp -H [Printer IP] -o SNMPv2-SMI::mib-2.43.11.1.1.9.1.2 -v 2c -C [community string] -w 25: -c 10: -l "[Color] Toner Level" -u "%"
This should result in checking the second OID you listed, using version 2c, with a warning for anything less than 25 and critical for anything less than 10. It will also label the performance data with "[Color name] Toner Level" and use a unit of %. If I were to do this same thing in a command for nagios I would probably do something like:

Code: Select all

$USER1$/check_snmp -H $HOSTADDRESS$ -o SNMPv2-SMI::mib-2.43.11.1.1.9.1.$ARG1$ -v 2c -C [community string] -w 25: -c 10: -l "$ARG2$ Toner Level" -u "%"

$ARG1 = OID index for specific toner cartridge
$ARG2$ = Color name for label
You could also do community string and warning\criticals if they are going to change printer to printer, but I didn't want to make it overly complex. I should also note that check_snmp may need you to use the full numeric oid instead of mixed shortname and oid extension, but give it a shot as is first.

Re: How to alert on toner level?

Posted: Mon May 05, 2014 1:02 pm
by jbruyet
Thanks sreinhardt, I did the command but I'm getting the critical warning and the toner cartridge is at 66% capacity:

Code: Select all

root@FreeNag:/usr/home/jobee/SNMP # /usr/local/libexec/nagios/check_snmp -H 192.168.2.78 -o 1.3.6.1.2.1.43.11.1.1.9.1.2 -v 1 -C public -w 25: -c 1
/usr/local/bin/snmpget -t 1 -r 5 -m '' -v 1 [authpriv] 192.168.2.78:161 1.3.6.1.2.1.43.11.1.1.9.1.2
iso.3.6.1.2.1.43.11.1.1.9.1.2 = INTEGER: 66
SNMP CRITICAL - *66* | iso.3.6.1.2.1.43.11.1.1.9.1.2=66
root@FreeNag:/usr/home/jobee/SNMP #
Is there an additional command for decrementing values as opposed to incrementing values? Also, you may notice that I had to drop it back to snmp version v1. Thank you Hewlett-Packard.

Thanks,

Joe B

Re: How to alert on toner level?

Posted: Mon May 05, 2014 1:24 pm
by abrist
You need to change the critical threshold value in your check. Currently it will alert critical for any value over 1. Place a colon after the critical threshold to force it to only trip when under the threshold:

Code: Select all

/usr/local/libexec/nagios/check_snmp -H 192.168.2.78 -o 1.3.6.1.2.1.43.11.1.1.9.1.2 -v 1 -C public -w 25: -c 1:
Though, you may want to change it to '2' so you are warned (with a critical notification) when 1% is left instead of 0%:

Code: Select all

/usr/local/libexec/nagios/check_snmp -H 192.168.2.78 -o 1.3.6.1.2.1.43.11.1.1.9.1.2 -v 1 -C public -w 25: -c 2:
See the following doc for more details:
https://nagios-plugins.org/doc/guidelines.html

Re: How to alert on toner level?

Posted: Mon May 05, 2014 2:50 pm
by jbruyet
Thank you very much sreinhardt and abrist! I just ran the check from the command line (after correcting my colon typo error) and it worked spectacularly. FWIW, I ran the test on another similar printer and saw that it's down to 5% on one of the toner cartridges.

Thanks again,

Joe B