Home Directory Plugins Hardware Printers SNMP Printer Check

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

SNMP Printer Check Popular

Rating
64 votes
Favoured:
13
Current Version
4.0
Last Release Date
2016-06-09
Compatible With
  • Nagios 3.x
  • Nagios 4.x
License
GPL
Hits
1236921
Files:
FileDescription
check_snmp_printerVersion 3.141592 Script
check_snmp_printerVersion 4.0 Script
check_snmp_printer_versions.txtVersion History
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
SNMP Printer Check
Universal printer check. Check for specific consumables or report on all. Query model/serial #, event messages, tray status and much more!

Originally based on Monitoring Solutions' check_snmp_printer, this provides friendly output, quick execution and thorough pre-flight checking.
*** LATEST CHANGES: SNMP v3 checking supported, with improvements to code and error handling. Also simplified output some and added ability to pass long style options (--).

---> 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.

Usage for SNMP v1/2c:
check-snmp_printer -H {host/IP} -t {type of check} [-C {SNMP community}] [-S] [-w] [-c]

Usage for SNMP v3:
check-snmp_printer -v 3 -H {host/IP} -t {type of check} -u {user} -x {protocol} -X {password} -a {protocol} -A {password} -l {security mode} [-S] [-w] [-c]

Check type can be one of the following:
CONSUM {"string" | TEST | ALL}
DEVICE
DISPLAY
MESSAGES
MODEL
PAGECOUNT
STATUS
TRAY {number(s) | TEST | ALL}
VERSION

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.)

DEVICE, DISPLAY, MESSAGES, MODEL and STATUS report information about the printer's hardware devices, physical display, event log messages, model/serial or overall status (respectively).

If you want the output for consumables to contain multiple lines, pass the following argument:
-S "n"

Then you need to edit your service notifications. Just after the $SERVICEOUTPUT$ macro, you will need to add "n$LONGSERVICEOUTPUT$". E-mails will finally contain lines 2 and up of the output.


Reviews (50)
bymarcgpx, October 1, 2014
Saves me a lot of time! Great Work
byshiz0, September 24, 2014
Great script, all is working well, except for STATUS.
It kept returning WARNINGS:

# snmpget -v 1 x.x.x.x -c xxxx 1.3.6.1.2.1.25.3.5.1.1.1
HOST-RESOURCES-MIB::hrPrinterStatus.1 = INTEGER: idle(3)

# ./check_snmp_printer -H x.x.x.x -C xxxx -x "STATUS"
WARNING: Printer status is idle


It seems like the script didnt trigger the idle case (line 268),
but jumped stright to *) (line 277).

I'm not that familiar with bash scripting but I played around a bit when I changed line 268 from
"idle(3)")
to
idle)
it worked as expected and now I got:

# ./check_snmp_printer -H x.x.x.x -C xxxx -x "STATUS"
OK: Printer status is idle

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).

Regards,
shiz0
Great script.

As a previous reviewer mentioned, the STATUS command is coming up as WARNING:Printer is Idle.

Any thoughts or solutions on this?
The script does very fine, I am very happy to use it. But there is still a little problem with Utax CD1120 printers (We got two in our enviroment).

The "Toner Container" is always 600 %. No percentage more or less.

But maybe this is not a script related problem because i did not found any toner capacity information on the web-gui too.
byfeltel, June 4, 2014
I´m using your plugin since some time to monitor consumables of our corporate printers. It works very well. We recently purchased an Brother HL-5350DN which seems to have some Bugs in its Firmware (shipped with latest available one, version 1.18; downgrade not available/possible). For the black toner cartridge (the only one in this printer) there are two states reported like this:

Black Toner Cartridge is OK! Black Toner Cartridge is at CRITICAL level! Drum Unit is at 99% - OK! | Black Toner Cartridge=-3;20;5; Black Toner Cartridge=0;20;5; Drum Unit=99;20;5;

Reason for this is, that the machine claims it has two cartridges:

~ snmpwalk -v1 -Ovq -c public MY-PRINTER-IP 1.3.6.1.2.1.43.11.1.1.6.1
"Black Toner Cartridge"
"Black Toner Cartridge"
"Drum Unit"

My question is if you could filter out duplicate consumables in some sort of way? This could work as some sort of work-around for this type of bugs.

Thanks alot.
One small issue I had is some Fuji Xerox printers return the serial number of the toner cartridge in the output, however they include a semi colon ";"

This completely breaks nagiosgraph's ability to graph them.

I added

MARKER_NAME=${MARKER_NAME//;/" "}

to check_one_consumable to replace the all semi colons with spaces to correct this
@eby: You say you ran into the no xxd error and "I'm guessing this was the problem the one star reviewer encountered. bc is in portage and the pentoo overlay has xxd. Once I installed both of these the script ran fine."

Could you elaborate on how you installed xxd? I am getting the no xxd error but haven't the slightest idea how to install xxd as I am not remotely experienced with Linux.

Thanks!
byrendicott, April 12, 2013
1 of 1 people found this review helpful
Great script!

@zarisha
To avoid the "WARNING: No SNMP response from -C! Make sure host is up and SNMP is configured properly." message make sure that you add the additional $ after "$HOSTADDRESS" in the command definition. The OP was missing it and it fixed my problem.

The following line in the OP:
command_line $USER1$/check_snmp_printer -H $HOSTADDRESS -C $ARG1$ -x $ARG2 -w $ARG3$ -c

Should be:
command_line $USER1$/check_snmp_printer -H $HOSTADDRESS$ -C $ARG1$ -x $ARG2 -w $ARG3$ -c
byfibercool, March 12, 2013
Any idea why im getting the consumables names in HEX instead in ascii format, for example like this:

Consumables you may Monitor:
42 6C 61 63 6B 20 43 61 72 74 72 69 64 67 65 20
43 45 32 35 35 41 00

I'm getting same thing with different HP models.
bymilda, January 29, 2013
Printer Oki C5700 returns same names of consumables without colour:

SNMPv2-SMI::mib-2.43.11.1.1.6.1.1 = STRING: "Toner Cartridge OKI DATA CORP"
SNMPv2-SMI::mib-2.43.11.1.1.6.1.2 = STRING: "Toner Cartridge OKI DATA CORP"
SNMPv2-SMI::mib-2.43.11.1.1.6.1.3 = STRING: "Toner Cartridge OKI DATA CORP"
SNMPv2-SMI::mib-2.43.11.1.1.6.1.4 = STRING: "Toner Cartridge OKI DATA CORP"
SNMPv2-SMI::mib-2.43.11.1.1.6.1.5 = STRING: "Image Drum Unit OKI DATA CORP"
SNMPv2-SMI::mib-2.43.11.1.1.6.1.6 = STRING: "Image Drum Unit OKI DATA CORP"
SNMPv2-SMI::mib-2.43.11.1.1.6.1.7 = STRING: "Image Drum Unit OKI DATA CORP"
SNMPv2-SMI::mib-2.43.11.1.1.6.1.8 = STRING: "Image Drum Unit OKI DATA CORP"

Colours are named in MarkerColorantTable:
SNMPv2-SMI::mib-2.43.12.1.1.4.1.1 = STRING: "black"
SNMPv2-SMI::mib-2.43.12.1.1.4.1.2 = STRING: "cyan"
SNMPv2-SMI::mib-2.43.12.1.1.4.1.3 = STRING: "magenta"
SNMPv2-SMI::mib-2.43.12.1.1.4.1.4 = STRING: "yellow"
by, October 8, 2012
Thank you Jason for the plugin. It is making my job alot easier!
Great work on this. I'm having an issue monitoring a Xerox DocuColor 242 though. The reported toner levels fluctuate wildly every few minutes. Here is an example from CONSUM ALL:

Black Toner [K] Cartridge is at 253% - OK!
Black Drum Cartridge is at 55% - OK!
Black Toner [K1] Cartridge is at 1084% - OK!
Black Toner [K2] Cartridge is at 884% - OK!
| Black Toner [K] Cartridge=253;20;5; Black Drum Cartridge=55;20;5; Black Toner [K1] Cartridge=1084;20;5; Black Toner [K2] Cartridge=884;20;5;

Black Toner [K] Cartridge is at 15% - WARNING!
Black Drum Cartridge is at 17% - WARNING!
Black Toner [K1] Cartridge is at 1590% - OK!
Black Toner [K2] Cartridge is at 1071% - OK!
| Black Toner [K] Cartridge=15;20;5; Black Drum Cartridge=17;20;5; Black Toner [K1] Cartridge=1590;20;5; Black Toner [K2] Cartridge=1071;20;5;

This is for all consumables. Actual levels for K1 and K2 are 20% and 100%.

All other checks work. Tray levels look correct. Tray 5 says to refill it with .5 x .5 paper but it is set to 8.5x11.

Thanks.
byeby, September 23, 2012
Like the command layout of this one especially the custom warn/crit levels on the command line. Worked great with the lexmark printers we have. Haven't ran into any issues yet.

One thing that should be noted. On gentoo the bc and xxd binaries aren't present which this script uses. I'm guessing this was the problem the one star reviewer encountered. bc is in portage and the pentoo overlay has xxd. Once I installed both of these the script ran fine. Would be good to note some of the system binaries it uses in the description.
I wrote a little change in check_page_count function:

function check_page_count(){
local PAGE_EXIT_CODE=0
PAGE_COUNT=$(snmpget -v1 -Ovq -c $COMMUNITY $HOST_NAME 1.3.6.1.2.1.43.10.2.1.4.1.1 2>/dev/null)

if [ "$PAGE_COUNT" -lt "$WARNING" ]; then
EXIT_STRING="Pagecount is $PAGE_COUNT - OK!$SEPARATOR"
else
if [ "$PAGE_COUNT" -ge "$WARNING" ] && [ "$PAGE_COUNT" -lt "$CRITICAL" ]; then
EXIT_STRING="Pagecount is $PAGE_COUNT - WARNING!$SEPARATOR"
PAGE_EXIT_CODE=1
else
if [ "$PAGE_COUNT" -ge "$CRITICAL" ]; then
EXIT_STRING="Pagecount is $PAGE_COUNT - CRITICAL!$SEPARATOR"
PAGE_EXIT_CODE=2
fi
fi
fi

PERFDAT="Pages;Warning;Critical=$PAGE_COUNT;$WARNING;$CRITICAL;"
return $PAGE_EXIT_CODE

}
So far so good. The only issue i'm running into is with the STATUS check. I setup services for three of my printers and i'm getting weird results. Nagios is giving me the following:

WARNING: Printer status is idle

When i do an SNMPwalk on 1.3.6.1.2.1.25.3.5.1.1.1 2 of that printer i get the following:

INTEGER: idle(3)

Looking at the script it appears i should be getting an OK: but i'm getting a WARNING: instead.

Here is my check command definition:

define command {
command_name check_snmp_printer
command_line $USER1$/check_snmp_printer -H $HOSTADDRESS$ -C $ARG1$ -x $ARG2$ -w $ARG3$ -c $ARG4$
}

And my service command:

define service {
service_description Status
check_command check_snmp_printer!public!STATUS!!
host_name media-stats-printer
event_handler_enabled 0
use generic-service
contact_groups +admins
}


Any advice would be greatly appreciated.

Thanks!
I really like this plugin! But could you first check if the printer reports a maximum capacity before dividing through it? On our Sharp MX-2300N there is no such value, therefore the script tries to divide by 0 for a few times.
bygarazh317, December 19, 2011
Hi! I tried to use this plugin on freesd 7.4 but i have that error UNKNOWN: check_snmp_printer: No usable 'xxd' binary in '/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin'
bystijns, November 18, 2011
very nice plugin. However, there is a small bug: When a unknown tray or consumable is requested, the status information shows an error ("UNKNOWN - OID not found! Your printer may not support checking this consumable. Use the CONSUM TEST option to determine which consumables may be monitored.")
but: the status itself is "OK".

and 2 suggestions / feature requests:
-Can you refer to a tray or consumable by it's index in addition to it's name? I have a Brother B/W printer that returns 2 times a "black toner cartridge", one that is empty and another one with the correct information. But I can't point to the right one because they are named the same. And of course, the faulty one is the first one so that's the one CONSUMX returns.

-Can you exclude a certain tray or consumable together with the ALL statement? The manual paper tray is usually empty so will always return Critical. Excluding one is easier than specifying all but one tray.
byoricalco, November 15, 2011
thanks! your plug-in is just what I was searching for, but still I wanted to ask if you could please put the service definition for TRAY? it would be really useful. Also, are the service definitions you put for toner and model compatible with the 2.1 POSIX version or just the with the 3.14159 version?
if I have ubuntu is it recommendable to update or does the service definitions work either way? sorry if I'm making obvious questions its just that I am both an ubuntu and nagios noob and there is just too much I don't understand...
byzavisha, November 13, 2011
Looks great but i've got one problem with this.
printer.cfg
define service{
use generic-service
host_name hp1536dnf
service_description Toner Supply
check_command check_snmp_printer!192.168.115.70!public!CONSUM!20!10
normal_check_interval 10
retry_check_interval 1
}

commands.cfg
define command{
command_name check_snmp_printer
command_line $USER1$/check_snmp_printer -H $HOSTADDRESS -C $ARG1$ -x $ARG2 -w $ARG3$ -c $ARG4$
}

Nagios shows "WARNING: No SNMP response from -C! Make sure host is up and SNMP is configured properly."

Please, help
Page 2 of 3