Printers

SNMP Printer Check

Description:

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.

Current Version

4.0

Last Release Date

2016-06-09

Compatible With

  • Nagios 3.x
  • Nagios 4.x

License

GPL


Project Files
Project Photos
Project Notes
*** 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) Add a Review
Great Plugin!!!
by jpcozar, August 31, 2022

It is a very complete plugin, working in 2022 with Nagios Core 4.4.6. Most of options were working except for partial searchings like "CONSUM ". I was getting no output. I had to change line 670 from: for MARKER_ID in $(echo "$MARKERS_MATCHED" | awk -F. '{print $8}' | awk -F= '{print $1}') to: for MARKER_ID in $(echo $MARKERS_MATCHED|sed 's/Printer/nPrinter/g'|sed '/^$/d'|awk -F= '{print $1}'|awk -F. '{print $NF}') So I got the MARKER_IDs and got the match. Congrats!



Great Plugin!
by j03man, October 31, 2021

Works great! I just finished setting it up for 2 Konica Minolta C458.



One printer returning unknown OID.
by jamesc_syd, June 30, 2019

I have the following check set up: $USER1$/check_snmp_printer -H $HOSTADDRESS$ -C public -w 10 -c 5 -t "CONSUM ALL" For most printers it's fine. But for one it returns: UNKNOWN - OID not found! Your printer may not support checking this consumable. Use the CONSUM TEST option to determine which consumables may be monitored.Tray 1 Roller Kit HP Z7Y88A is at 99% - OK!,Tray 2 Roller Kit HP Z9M01A is at 99% - OK!, 'Tray 1 Roller Kit HP Z7Y88A'=99;10;5 'Tray 2 Roller Kit HP Z9M01A'=99;10;5 Is there a way to filter out that unknown OID responses without having to define the checks each individual printer accepts? All printers are quite new HP printers. The one causing this problem is an HP E87640



PAGECOUNT PERFDATA
by 42bios, April 30, 2019

For working Perfdata for Page Counter, I changed the following lines: 297: PERFDATA="'Pages'=$PAGE_COUNT [c]" 298: PAGE_COUNT=$(echo $PAGE_COUNT | sed -e :x -e 's/([0-9][0-9]*)([0-9][0-9][0-9])/1.2/' -e 'tx') ->in use with HP and Xerox printers.



Plugin question
by imarkovic, February 28, 2019

Hello Nagios team, 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. When I type from command: ./check_snmp_printer -H 192.168.2.10 -t MODEL -u user -x DES -X password -a MD5 -A password -l authPriv I only get "Plugin check_snmp_printer failure - snmpwalk command error. This must be working in order to go on and implement it on Nagios monitoring. Thanks, cheers!



Worked fine on Nagios Core 4 Not so much on Icinga.
by webersnet, March 31, 2018

tried to implement the plugin into Icinga2 but didnt work. Worked fine on Nagios Core 4



Issues with extra snmp mibs
by endi-brett, October 31, 2017

Not sure if its because I'm using Icinga2 or something else. via command line everything works great, but get via icingaweb2 i see permission denied errors on all my 3rd party mibs



little Typo
by langejunior, April 30, 2017

Hi, if you try to use --community instead of -C in the command you get an error, because in while test -n "$1"; do case "$1" in ... --comunity|-C) COMMUNITY=$2 shift ;; change it to --community and it will work :-)



Missing parameter for SNMP v3
by rnicksic, February 28, 2017

I had to add the parameter for CONTEXT (-n) in order to use SNMP v3 with Konica-Minolta bizhub C284 printers. --- /home/rnicksic/check_snmp_printer 2017-02-23 10:08:16.821478951 -0600 +++ check_snmp_printer 2017-02-23 11:53:04.914467280 -0600 @@ -890,7 +890,7 @@ walk_snmp(){ fi if [[ $SNMPVERSION = 3 ]]; then - RESULT_TEXT=`snmpwalk -v $SNMPVERSION $OUTPUT_OPTIONS -u $SNMPUSER -l $PRIVILEGELEVEL -x $PRIVACYPROTOCOL -X $PRIVACYPASSWORD -a $AUTHPROTOCOL -A $AUTHPASSWORD $HOST_NAME $1` + RESULT_TEXT=`snmpwalk -v $SNMPVERSION $OUTPUT_OPTIONS -u $SNMPUSER -n $CONTEXT -l $PRIVILEGELEVEL -x $PRIVACYPROTOCOL -X $PRIVACYPASSWORD -a $AUTHPROTOCOL -A $AUTHPASSWORD $HOST_NAME $1` RESULT_CODE=$? else # Check if community was also set @@ -989,6 +989,10 @@ while test -n "$1"; do PRIVACYPASSWORD=$2 shift ;; + --context|-n) + CONTEXT=$2 + shift + ;; --type|-t) # Assign check to perform CHECK_TYPE=$(echo "$2" | cut -d " " -f1) PARAMETER=$(echo "$2" | cut -d " " -f2-)



Error!
by andrebo, January 31, 2017

Hello, Does the plugin work for HP Color Laserjet CP2025dn? I am giving the command below and it is giving error Root @ srvnagios: / usr / local / nagios / libexec # ./check_snmp_printer -H 192.168.0.199 -C public -t "CONSUM Black Cartridge" -w 30 -c 10 Timeout: No Response from 192.168.0.199 Plugin check_snmp_printer failure - snmpwalk command error.



Works great, but...
by bpb21, November 30, 2016

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!



Great, I added some code to the Status function
by CameronMR, May 31, 2016

Hi: 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: STATUS_EXIT_CODE=0 PRINTER_STATUS=$(snmpget -v1 -Ovq -c $COMMUNITY $HOST_NAME 1.3.6.1.2.1.25.3.5.1.1.1 2>/dev/null) PRINTER_MODEL=$(snmpget -v1 -Ovq -c $COMMUNITY $HOST_NAME 1.3.6.1.2.1.25.3.2.1.3.1 2>/dev/null) PRINTER_DETECTED_ERROR=$(snmpwalk -v1 -Ovxq -c $COMMUNITY $HOST_NAME 1.3.6.1.2.1.25.3.5.1.2 2>/dev/null) DISPLAY=$(snmpwalk -v1 -Ovq -c $COMMUNITY $HOST_NAME 1.3.6.1.2.1.43.16.5.1.2.1 2>/dev/null | tr -d """) if [ ! -z "$PRINTER_DETECTED_ERROR" ]; then IFS=' ' read -ra ErrVals us is $PRINTER_STATUS. Printer is reporting: $PRINTER_ERROR_RESULT" STATUS_EXIT_CODE=2 fi if [[ "$DISPLAY" == "Sleep"* ]]; then EXIT_STRING="OK: Printer status is $DISPLAY." STATUS_EXIT_CODE=0 fi ;; "idle") EXIT_STRING="OK: Printer status is $PRINTER_STATUS" ;; "printing") EXIT_STRING="OK: Printer status is $PRINTER_STATUS" ;; "warmup") EXIT_STRING="OK: Printer status is $PRINTER_STATUS" ;; *) EXIT_STRING="WARNING: Printer status is $PRINTER_STATUS" STATUS_EXIT_CODE=1 ;; esac return $STATUS_EXIT_CODE }



wonderful plugin
by lehab, February 29, 2016

Works great! Attention! There is two "$" signs missing in section "define command". Be attentive. It must be "define command{ command_name check_printers command_line $USER1$/check_snmp_printer -H $HOSTADDRESS$ -C $ARG1$ -x $ARG2$ -w $ARG3$ -c $ARG4$ } "



please help
by mammuthus, February 29, 2016

Guys, what's wrong? error: Invalid check specified by -x parameter. but from terminal is okay: /etc/nagios-plugins/printer_status -H 192.168.0.197 -x "MODEL" Samsung SCX-472x Series, Serial # Z8Z7BJDC400094K define command: define command{ command_name printer_status command_line /etc/nagios-plugins/printer_status -H $HOSTADDRESS$ -C $ARG1$ -x $ARG2 -w $ARG3$ -c $ARG4$ } service: define service{ use generic-service hostgroup_name printers service_description Printer_Model check_command printer_status!public!"MODEL" } I believe the wrong is check_command string. But it's the same as aytor's and autor can't lie to us.



Almost there
by wizard210, January 31, 2016

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 I'm stuck.



One or more problems was encountered while processing the config files
by chris_l, October 31, 2015

I don't have any luck in this. I always have this error when trying to restart the nagios service. Could not find any host matching 'printer_groupmain' (config file '/etc/nagios3/conf.d/printers-service.cfg', starting on line 46) Error: Could not expand hostgroups and/or hosts specified in service (config file '/etc/nagios3/conf.d/printers-service.cfg', starting on line 46) Error processing object config files! I have done everything correctly in command definition define command{ command_name check_printer command_line $USER1$/check_snmp_printer -H $HOSTADDRESS -C $ARG1$ -x $ARG2 -w $ARG3$ -c } It even works in the /usr/lib/nagios/plugins if i run the command manually, however i can't run it normally in /etc/nagios3/conf.d. Appreciate anyone advice on this? Thanks.



Some changes for PAGECOUNT
by DutchEagleon, October 31, 2015

Good Script, Very helpful. I only had some problems with the STATUS and PAGECOUNT. The STATUS Problem I solved with the help of a previous review, that you had to change "idle(3)"); to "idle"). After I made that change it worked fine. The PAGECOUNT problem wasn't really a problem but more like it was missing something. The PAGECOUNT showed me the total number of pages printed color and black together. But I wanted to see the color PAGECOUNT and black PAGECOUNT separately, So I had to make some changes to the script. The original PAGECOUNT function looks like this: function check_page_count(){ 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 | sed -e :x -e 's/([0-9][0-9]*)([0-9][0-9][0-9])/1,2/' -e 'tx') EXIT_STRING="Pagecount is $PAGE_COUNT" PERFDAT="Pages=$PAGE_COUNT;" return 0 } The long number (1.3.6.1.2.1.43.10.2.1.4.1.1 2) is a OID, an OID is object identifier and this one is used to get the PAGECOUNT Total. But like I said I wanted to see the PAGECOUNT for color and Black separately, so I did some research of what the OID's are for this and I found them on an forum. 1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.33(COLOR) 1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.34(BLACK) I think they are officially for a Xerox Printer, but I think they will also work for other printers you just have to test. I didn't have any other printers available then Xerox. So the changes is made are this: function check_page_count1(){ PAGE_COUNT=$(snmpget -v1 -Ovq -c $COMMUNITY $HOST_NAME 1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.33 2>/dev/null | sed -e :x -e 's/([0-9][0-9]*)([0-9][0-9][0-9])/1,2/' -e 'tx') EXIT_STRING="Pagecount is $PAGE_COUNT" PERFDAT="Pages=$PAGE_COUNT;" return 0 } function check_page_count2(){ PAGE_COUNT=$(snmpget -v1 -Ovq -c $COMMUNITY $HOST_NAME 1.3.6.1.4.1.253.8.53.13.2.1.6.1.20.34 2>/dev/null | sed -e :x -e 's/([0-9][0-9]*)([0-9][0-9][0-9])/1,2/' -e 'tx') EXIT_STRING="Pagecount is $PAGE_COUNT" PERFDAT="Pages=$PAGE_COUNT;" return 0 } function check_page_count3(){ 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 | sed -e :x -e 's/([0-9][0-9]*)([0-9][0-9][0-9])/1,2/' -e 'tx') EXIT_STRING="Pagecount is $PAGE_COUNT" PERFDAT="Pages=$PAGE_COUNT;" return 0 } As you can see the commands stay the same only OID changes and the name of the function. I kept the original PAGECOUNT for the total number. After you have done this you will need to changes the main code, you will have to add the commands to name you can use. You will need to make the following changes around line 880: else STRING_TYPE=$(echo "$ALL_MARKERS" | tr -d "n" | cut -d " " -f3) case "$CHECK" in "MESSAGES") check_messages ;; "MODEL") check_model ;; "CONSUM") check_consumables "$PARAMETER" ;; "CONSUMX") check_exact_consumable "$PARAMETER" ;; "TRAY") check_paper_trays "$PARAMETER" ;; "PAGECOUNTCOLOR") check_page_count1 ;; "PAGECOUNTBLACK") check_page_count2 ;; "PAGECOUNTTOTAL") check_page_count3 ;; "DEVICES") check_device_status ;; "STATUS") check_printer_status ;; "DISPLAY") check_display ;; *) # no parameters were passed, or a parameter was incorrect (wrong spelling, etc.) echo 'Invalid check specified by -x parameter.' echo '' print_help ;; esac EXIT_CODE=$? 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. Maybe it's a thing for in the next version.



not working but almost there i hope
by Pikmin, February 28, 2015

I'm using FAN (Nagios Core 3.4.4) /etc/nagios/objects/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$ } /etc/nagios/objects/command-plugins.cfg command[check_snmp_printer]=/usr/lib64/nagios/plugins/check_snmp_printer -H $HOSTADDRESS$ -C $ARG1$ -x $ARG2$ -w $ARG3$ -c $ARG4$ /etc/nagios/objects/printer.cf define service{ use generic-service host_name Test-Printer service_description Toner Supply check_command check_snmp_printer!public!"CONSUM Toners"!20!10 } When I run the command manually on the server it works fine #./check_snmp_printer -H 192.168.4.50 -C public -x "CONSUM ALL" -w 20 -c 10 Black Toner [K] Cartridge;SN1220AA80E00004A0 is at 99% - OK! Yellow Toner [Y] Cartridge;SN04156480E0000478 is at 89% - OK! Magenta Toner [M] Cartridge;SN11338080E0000479 is at 83% - OK! Cyan Toner [C] Cartridge;SN0F2DD980E000047A is at 82% - OK! Waste Toner Container is OK! Black Drum Cartridge is at 93% - OK! Yellow Drum Cartridge is at 72% - OK! Magenta Drum Cartridge is at 71% - OK! Cyan Drum Cartridge is at 72% - OK! | Black Toner [K] Cartridge;SN1220AA80E00004A0=99;20;10; Yellow Toner [Y] Cartridge;SN04156480E0000478=89;20;10; Magenta Toner [M] Cartridge;SN11338080E0000479=83;20;10; Cyan Toner [C] Cartridge;SN0F2DD980E000047A=82;20;10; Waste Toner Container=-3;20;10; Black Drum Cartridge=93;20;10; Yellow Drum Cartridge=72;20;10; Magenta Drum Cartridge=71;20;10; Cyan Drum Cartridge=72;20;10; 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



Indispensable
by jat_nagiosexchange, February 28, 2015

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



No Luck with Canon printer
by ThomasC., October 31, 2014

Hey, While th eplugin works with my Xerox printers, i always receive: WARNING: No SNMP response from 10.7.161.208! Make sure host is up and SNMP is configured properly. from a Canon iR-ADV C5030. I have configured SNMP and the host is UP.



Great plugin
by marcgpx, October 31, 2014

Saves me a lot of time! Great Work



Great script
by shiz0, September 30, 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



Status is warning
by mpeck@beautyent.net, July 31, 2014

Great script. As a previous reviewer mentioned, the STATUS command is coming up as WARNING:Printer is Idle. Any thoughts or solutions on this?



Problem with Utax CD1120 Printers (Toner always 600 %)
by MiWo85, June 30, 2014

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.



Brother HL-5350DN
by feltel, June 30, 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 fix, otherwise it's very good
by davewatkins, October 31, 2013

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



Would love to try this out...
by sharris, August 31, 2013

@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!



Great Script!
by rendicott, April 30, 2013

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



hex format
by fibercool, March 31, 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.



consumable without colour
by milda, January 31, 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"



Thank You.
by egalstad, October 31, 2012

Thank you Jason for the plugin. It is making my job alot easier!



Toner levels on Xerox
by joshvazquez, October 31, 2012

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.



Some dependencies. Works Great
by eby, September 30, 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.



new printer counter
by molnarmate, March 31, 2012

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 }



Trouble with STATUS check
by mattrk, March 31, 2012

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!



Errors when no max capacity is available
by meilon, January 31, 2012

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.



xxd
by garazh317, December 31, 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'



bug/feature request
by stijns, November 30, 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.



service definitions
by oricalco, November 30, 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...



zavisha
by zavisha, November 30, 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



by zoemu, October 31, 2011




Some problems
by Huerres, August 31, 2011

First of all give you many thanks for this excellent plugin. It is valid for many items of our printers. I have a little problem. My commands.cfg I add: #'check_printer' command definition define command{ command_name check_printer command_line $USER1$/check_printer -H $HOSTADDRESS$ -p $ARG1$ $ARG2$ $ARG3$ } After this I add this to my printers.cfg: define service{ use generic-service host_name ljpm1217nfwmfp service_description PS check_command check_printer!-H 192.168.220.11 -C public -x "STATUS" -w WARNING -x CRITICAL -S / |-V|-h normal_check_interval 1 retry_check_interval 1 } But the Nagios webpage return me a "null". Can you help me please? Thanks a lot, Alex.



great plugin - 3 little changes
by harmscon, May 31, 2011

Works well for 3 different brand network printers. I had to make the following changes to get the plugin to run: 1. dos2unix 2. set bash as shell 3.put quotes around MARKER_COLOR to eliminate grep error messages 4.new line after here doc terminator $ diff -b ../../Downloads/firefox/check_snmp_printer_args.sh /usr/lib/nagios/plugins/check_snmp_printer_args.sh 1c1 #!/bin/bash 495a496 > CURRENT_STATUS=0 561c562 if $(echo "$MARKER_NAME" | grep -vqi "$MARKER_COLOR"); then 1022c1023,1024 all_required_binaries > )



Command/Service
by dceola, April 30, 2011

Any chance someone can share their service definition and command definition lines for this? I'm having trouble configuring them correctly.



config commands
by 3mwhite, February 28, 2011

Any chance on us getting the config commands? define service{ use generic-service host_name SharpAr-m257 service_description PING check_command check_ping!3000.0,80%!5000.0,100% normal_check_interval 10 retry_check_interval 1 } define command{ command_name check_local_users command_line $USER1$/check_users -w $ARG1$ -c $ARG2$ }



A+
by e314, November 30, 2010

Nice script, very useful.



UTF-8
by ydduj, October 31, 2010

I tried to use 'iconv' to convert from UTF-8 to ASCII with no success. Try: 'strings check_snmp_printer.sh > check_snmp_printer-ASCII.sh' 'file' now reports: check_snmp_printer-ASCII.sh: POSIX shell script text executable



Works great - added 3 Functions
by Schillo, October 31, 2010

Great Plugin. I added 3 little Functions - maybe you wanne add them to the Script: Display Message Printer Status Device Status ################################################# ######################################################### ### check_display function ### ######################################################### function check_display(){ DISPLAY=`snmpget -v1 -On -c $COMMUNITY $HOSTNAME 1.3.6.1.2.1.43.16.5.1.2.1.1 | cut -d " " -f4-` printf "Displaytext: $DISPLAY " exit 0 } ######################################################### ### check_printer_status function ### ######################################################### function check_printer_status(){ PRSTATUS=`snmpget -v1 -On -c $COMMUNITY $HOSTNAME 1.3.6.1.2.1.25.3.5.1.1.1 | cut -d " " -f4-` EXITSTRING="Drucker Status = " EXITCODE=0 case "$PRSTATUS" in "other(1)") EXITSTRING="$EXITSTRING$PRSTATUS - STATUS: CRITICAL!" EXITCODE=2 ;; "idle(3)") EXITSTRING="$EXITSTRING$PRSTATUS - STATUS: OK!" EXITCODE=0 ;; "printing(4)") EXITSTRING="$EXITSTRING$PRSTATUS - STATUS: OK!" EXITCODE=0 ;; "warmup(5)") EXITSTRING="$EXITSTRING$PRSTATUS - STATUS: OK!" EXITCODE=0 ;; *) EXITSTRING="$EXITSTRING$PRSTATUS - STATUS: WARNING!" EXITCODE=1 ;; esac printf "$EXITSTRING|$PRSTATUS;;; " exit $EXITCODE } ######################################################### ### check_device_status function ### ######################################################### function check_device_status(){ DEVSTATUS=`snmpget -v1 -On -c $COMMUNITY $HOSTNAME 1.3.6.1.2.1.25.3.2.1.5.1 | cut -d " " -f4-` EXITSTRING = "Geraet Status = " EXITCODE=0 case "$DEVSTATUS" in "unknown(1)") EXITSTRING="$EXITSTRING$DEVSTATUS - STATUS: WARNING!" EXITCODE=1 ;; "running(2)") EXITSTRING="$EXITSTRING$DEVSTATUS - STATUS: OK!" EXITCODE=0 ;; "warning(3)") EXITSTRING="$EXITSTRING$DEVSTATUS - STATUS: WARNING!" EXITCODE=1 ;; "testing(4)") EXITSTRING="$EXITSTRING$DEVSTATUS - STATUS: OK!" EXITCODE=0 ;; "down(5)") EXITSTRING="$EXITSTRING$DEVSTATUS - STATUS: CRITICAL!" EXITCODE=2 ;; *) EXITSTRING="$EXITSTRING$DEVSTATUS - STATUS: WARNING!" EXITCODE=1 ;; esac printf "$EXITSTRING|$DEVSTATUS;;; " exit $EXITCODE }



Works well - konica C600 & c552
by tocri, May 31, 2010

The script give the error "bad interpreter" at the beginning. To solve it make a "dos2unix" command. After this problem, the script works very well. Thanks a lot



Does not work for me
by DI, April 30, 2010

I tried it on 4 Linux based PC, 2 gentoo64, 1 Sabayon 64, and 1 Centos, it simply does not work at all. Each time I try to launch it, i've got several errors, unknown command, at line 158,159,163,164. I edited the file and remove the help() function, and tried again to make it work. It failed, cannot find function, syntax error in check_snmp_printer, unknown ^M... It seems the file has been created under windows... If so, please mention it.



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.4 (64)
Favorites
13
Views
1,249,839