---> IMPORTANT NOTE: Because snmp v3 checking uses -x for selecting a privacy protocol, -x is no longer the option for passing a check type. Instead, I've changed it to the more sensible -t option. This means your service command definitions need to be updated before you can use this plugin!!!

I liked the original plugin but wanted to be able to report the status of all consumables. For some devices this output can get huge. When only 1 component is empty, it becomes a challenge to find what needs to be replaced in the output. So this script was born.

I added checks for user input and better feedback for improper parameters. The same goes for SNMP status - before any code is executed, this is tested.

The CONSUM option gives results for all consumable names that match the string passed. For instance, you can pass "CONSUM Toner" and see all toner levels (no staple cartridges or imaging units). Similarly, "CONSUM Black" will show you the Black imaging unit and Black toner levels all at once. The ALL option gives all consumable status at once, and TEST will show you which CONSUMABLES can be monitored.

CONSUMX reports on consumables that match the eXact string passed to it. This helps alleviate problems when a "unique" string is not possible. For example, "CONSUMX Black Toner" would give an error unless the FULL description of the consumable (from a CONSUM TEST) is "Black Toner". Any consumable named "Black Toner1" or "Black Toner Cartridge" would be overlooked.

TRAY can be passed a number or list of numbers (comma-separated) as a parameter. The ALL parameter reports all tray statuses and TEST lets you know which trays the device has. In addition to generic status, the tray function tries to calculate paper remaining as a % of capacity (if possible), although this only works as good as the sensors on the device (and often only returns values at fixed intervals, such as 25%, 50%, 75%, etc.)

Salut to everyone and thanks for this plugin, espetially Mr Leonard as a creator.
I write because I have some struggling with snmp v. 3 from past day. snmp v. 1/2 is working great, but I need to use v.3 with hp M527 enterprise printer. I know this is not support section, but I need just something to go on if it`s ok.
As I said, snmp 2 is ok and its working with Nagios Core 4 - CentOS 7.

Looks like an awesome plugin and would save a lot of time, but I can't figure out how to set up checks that require more than one word. Specifically, checking CONSUM ALL and TRAY ALL from the command line works excellently. I can't get them configured correctly in the Nagios config files. They invariably return errors such as "UNKNOWN: No valid check type specified to -t parameter". I don't know how to add anything with a space (single and double quotes return errors). But, the single word checks work fine!

We have Xerox, Ricoh and HP printers at our facility and I found that the status function wasn't returning enough info for me. I needed the following:

1) If an HP printer is asleep, it should recognize that not go critical.
2) Xerox machines always complain about the bypass tray, ignore them. In fact never return a warning or critical with Xerox printers (specific to our environment)
3) If the printer does go into an error state, parse the return code and tell me what the actual problem is. Some issues in our environment should be fixed by our techs while others are handled by administrative staff so that is important to know.

I haven't programmed in BASH since the mid-90's and even then only sparingly so I apologize to the actual pro's out there if this isn't the cleanest but it works so, um, yay!

Here is the entire Status function that has been tested against Ricoh, Xerox and HP printers:

I've been trying to get this to work on a Color Laserjet m451dn but each time I just recieve UNKNOW -OID not found! When I do CONSUM TEST I receive the same error. running the check from the terminal works just fine when I do it ./check_snmp_printer -H 192.168.4.50 -C public -x "CONSUM ALL" -w 20 -c 10

As you can see I have added PAGECOUNTCOLOR, PAGECOUNTBLACK and PAGECOUNTTOTAL, so when you have made these changes you can also put the help function.

You will get something like this:

echo ''
echo ' PAGECOUNTTOTAL'
echo ' How many pages this printer has processed for black and color'
echo ''
echo ' PAGECOUNTBLACK'
echo ' How many pages this printer has processed for black'
echo ''
echo ' PAGECOUNTCOLOR'
echo ' How many pages this printer has processed for color'

That's all the changes I made, I just find it handy to know all the number instead of just the total one.

And I wanted to post it here so maybe more people can use it so they don't have to search for it on google.

However it doesn't work through nagios
I get this (even when I use CONSUM TEST instead of CONSUM ALL)
UNKNOWN - OID not found! Your printer may not support checking this consumable. Use the CONSUM TEST option to determine which consumables may be monitored.

and I also got this error initially
No SNMP response from 192.168.x.x! Make sure host is up and SNMP is configured properly.
Once again works fine manually when using check_snmp_printer in a shell

I've modded this slightly to return a status of 'Unknown' rather than 'Warning' when the check gets no response from the printer. After line 860, I changed:
EXIT_CODE=1
to:
EXIT_CODE-3

We have lots of printers, and end users often like to switch them off. With the above change, it makes it much easier to see actual warnings for low toners, etc. rather than them being lost amongst lots of 'No SNMP response' type messages.

In a school with lots of different types and ages of colour printers, this plugin is incredibly useful due to its versatility and ease of use. It saves a lot of leg work!!

I think maybe the output is different for different printers,
so I changed it again to
idle|3|"idle(3)") --> idle OR 3 OR idle(3)
and it still works like a charm (at least on our 3 DELL printers, tests on the big Xerox machine are up later).