Tylan / check_snmp_printer

Icinga Plugin for Checking SNMP Printer Status (Trays, Consumables and Pagecounts)
GNU General Public License v3.0
12 stars 4 forks source link

New Printer Support #11

Closed Optimaximal closed 3 years ago

Optimaximal commented 3 years ago

Hi,

Can you possibly look at adding Lexmark SNMP support to this plugin?

Here is the Lexmark SNMP docs - http://support.lexmark.com/index?page=content&id=FA615&locale=en&userlocale=EN_UK and the MIB pack - http://support.lexmark.com/library/LEXMARK/FA615/Lexmark_MIB_file_pack_20190502.zip

Tylan commented 3 years ago

Hi - I have partial support for Lexmark - can you tell me what exactly isn't working?

If you could provide me with the snmpwalks for the following OIDs I'd appreciate it:

1.3.6.1.4.1.641 1.3.6.1.2.1.43 1.3.6.1.2.1.25.3.2.1.3.1

Optimaximal commented 3 years ago

I'll send them over tomorrow along with walks of our our Kyocera TaskALFA as per the other issue.

At the moment you're missing Printer Status, but that may be a conscious decision on your part.

Tylan commented 3 years ago

Ok no problem. When you say Printer Status - what exactly are you referring to so I'm clear? The printer as a whole? Like 'Everything is fine / there's a warning somewhere / critical error detected"? If so that's usually what the --messages switch is for, but let me know either way :)

Optimaximal commented 3 years ago

Yeah, outputting '--messages' just returns the following:

(Can't determine messages)

Tylan commented 3 years ago

I might need the whole snmpwalk for 1.3.6.1.2.1.43 then so I can see what it's trying to say for messages if you can provide that

Optimaximal commented 3 years ago

There's also a consumable issue on Lexmark. The result is reading negative which is being interpreted as OK, but this itself is a misnomer as the actual value on the printer UI is showing a nebulous '~2%'.

OK: Black Toner is at -3% remaining. .1.3.6.1.2.1.43.11.1.1.9.1.1 = INTEGER: -3

m5155_badtoner.txt

Regarding messages, I'm not sure if you want the single line output:

.1.3.6.1.2.1.43.16.5.1.2.1.1 = STRING: "Sleep Mode . Tray 2 Missing . Tray 1 Low . "

or the separate lines you can put in an array:

.1.3.6.1.2.1.43.18.1.1.8.1.518 = STRING: "Cartridge low" .1.3.6.1.2.1.43.18.1.1.8.1.534 = STRING: "Tray 1 Low" .1.3.6.1.2.1.43.18.1.1.8.1.536 = STRING: "Tray 2 Missing"

Tylan commented 3 years ago

These are perfect, thanks! Let me look into the toner issue as well as fixing the messages.

Tylan commented 3 years ago

Before I publish the new version I'd like you to try this patch and let me know if there are any issues. Thanks!

patch check_snmp_printer < check_snmp_printer_1.2.2-patch.txt

check_snmp_printer_1.2.2-patch.txt

Tylan commented 3 years ago

I re-uploaded the patch above because I originally was going to add Waste Toner back into the code but I soon realized that anywhere I looked it always reported a -3 which according to the OID documentation is an unknown state. In all the snmpwalks you sent me I didn't see a single waste toner so I couldn't validate it against your environment but in mine they always came up unknown. I took the waste toner back out in the new patch.

Optimaximal commented 3 years ago

--messages is now working (results from C4150, XC2132 and M5155 respectively & match the OSD)...

Yellow cartridge low, 600 estimated pages remain Waste toner bottle nearly full Cartridge low

--trays still not working correctly on the XC2132. It's detecting no problem with the empty Envelope tray. Granted, this is probably by design...

CRITICAL: Manual Paper (8.27in x 11.69in) is at 0% paper remaining.
OK: Manual Envelope (4.33in x 8.66in)
OK: Tray 1 (8.27in x 11.69in) is at 100.00% paper remaining.
|Manual_Envelope=2;;;; Manual_Paper=0;;;; Tray_1=2;;;;

Running it with --nofeeder on any printer just returns a pipe with no further data.

--consum still returns OK for a < 0% value on M5155s plus the black toner cartridge name is now missing.

OK: Maintenance Kit is at 74.00% remaining.
OK: Roller Kit is at 84.00% remaining.
OK:  is at -3% remaining.
OK: Imaging Unit is at 49.00% remaining.
OK: Roller Kit is at 94.00% remaining.
OK:  is at 75.00% remaining.
OK: Maintenance Kit is at 89.00% remaining.
OK: Imaging Unit is at 76.00% remaining.
Tylan commented 3 years ago

Hmm. --nofeeder should have ignored the Manual Paper and Manual Envelope it's not by design for sure. I made more precise verbiage check in the code so hopefully it catches them and ignores it let me know. I hopefully also fixed the -3% remaining and the blank black toner name. Please replace your check_snmp_printer with this entire file and let me know thanks! You'll have to remove the .txt first - Github won't let me attach it unless it has .txt on the end.

check_snmp_printer.txt

Optimaximal commented 3 years ago

Descriptions are back (although I guess one of the Black Toner's should be the image unit or drum) but the readings are totally out of whack & inconsistent across each re-check.

root@fs-monitor:/usr/lib/nagios/plugins# ./check_snmp_printer -H 192.168.0.221 -C spice --consum
OK: Imaging is at 70.00% remaining.
OK: Fuser is at 28000% remaining.
OK: Magenta Toner is at 100.00% remaining.
OK: Yellow Toner is at 60000% remaining.
OK: Black Toner is at 50.00% remaining.
OK: Cyan Toner is at 1500% remaining.
OK: ITU is at 90.00% remaining.
OK: Maintenance Kit is at 2700% remaining.
|Imaging=70.00;;;; Fuser=28000;;;; Magenta_Toner=100.00;;;; Yellow_Toner=60000;;;; Black_Toner=50.00;;;; Cyan_Toner=1500;;;; ITU=90.00;;;; Maintenance_Kit=2700;;;;
root@fs-monitor:/usr/lib/nagios/plugins# ./check_snmp_printer -H 192.168.0.221 -C spice --consum
OK: Fuser is at 100.00% remaining.
OK: Yellow Toner is at 60000% remaining.
OK: Black Toner is at 90.00% remaining.
OK: ITU is at 2700% remaining.
OK: Magenta Toner is at 90.00% remaining.
OK: Imaging is at 5400% remaining.
OK: Cyan Toner is at 100.00% remaining.
OK: Maintenance Kit is at 60000% remaining.
|Fuser=100.00;;;; Yellow_Toner=60000;;;; Black_Toner=90.00;;;; ITU=2700;;;; Magenta_Toner=90.00;;;; Imaging=5400;;;; Cyan_Toner=100.00;;;; Maintenance_Kit=60000;;;;

...and the -3% value is still there, returning OK...

root@fs-monitor:/usr/lib/nagios/plugins# ./check_snmp_printer -H 192.168.0.227 -C spice --consum
OK: Roller is at 84.00% remaining.
OK: Black Toner is at 252000% remaining.
OK: Maintenance Kit is at -3% remaining.
OK: Imaging is at 74.00% remaining.
|Roller=84.00;;;; Black_Toner=252000;;;; Maintenance_Kit=-3;;;; Imaging=74.00;;;;
Tylan commented 3 years ago

Oh my. Let me roll back those changes I made and look at where I went wrong. Yikes, sorry about that! They don't act that funky on my HP/Canon printers.

Tylan commented 3 years ago

apologies for delay - can you give this a try and let me know?

check_snmp_printer.txt

Optimaximal commented 3 years ago

Sorry, ignore the last posts - when I downloaded the file, it appended a .1 to the filename as it already existed and I overwrite the plugin with an older file.

'/usr/lib/nagios/plugins/check_snmp_printer' '-H' '192.168.0.220' '--consum' '-C' 'spice' '-w' '5' '-c' '1'

WARNING: Yellow Toner is at 2.00% remaining.
OK: Black Toner is at 64.00% remaining.
OK: Color is at 88.00% remaining.
OK: Cyan Toner is at 38.00% remaining.
OK: Black Toner is at 79.00% remaining.
OK: Fuser is at 72.00% remaining.
OK: Transfer Unit is at 79.00% remaining.
OK: Magenta Toner is at 28.00% remaining.

FYI, the Imaging Units are showing up as 'Color' and the 79% 'Black Toner' respectively - they're definitely distinct in OID 1.3.6.1.4.1.641.6.4.4.2.1.5, but the two Black components are grouped under 'black' in 1.3.6.1.4.1.641.6.4.4.2.1.4, whereas the Color IMU is grouped with the fuser, transfer module and waste toner.

iso.3.6.1.4.1.641.6.4.4.2.1.4.1.1 = STRING: "black"
iso.3.6.1.4.1.641.6.4.4.2.1.4.1.2 = STRING: "black"
iso.3.6.1.4.1.641.6.4.4.2.1.4.1.3 = STRING: "none"
iso.3.6.1.4.1.641.6.4.4.2.1.4.1.4 = STRING: "cyan"
iso.3.6.1.4.1.641.6.4.4.2.1.4.1.5 = STRING: "none"
iso.3.6.1.4.1.641.6.4.4.2.1.4.1.6 = STRING: "none"
iso.3.6.1.4.1.641.6.4.4.2.1.4.1.7 = STRING: "magenta"
iso.3.6.1.4.1.641.6.4.4.2.1.4.1.8 = STRING: "none"
iso.3.6.1.4.1.641.6.4.4.2.1.4.1.9 = STRING: "yellow"
iso.3.6.1.4.1.641.6.4.4.2.1.5.1.1 = STRING: "Black Imaging Unit"
iso.3.6.1.4.1.641.6.4.4.2.1.5.1.2 = STRING: "Black Cartridge"
iso.3.6.1.4.1.641.6.4.4.2.1.5.1.3 = STRING: "Color Imaging Kit"
iso.3.6.1.4.1.641.6.4.4.2.1.5.1.4 = STRING: "Cyan Cartridge"
iso.3.6.1.4.1.641.6.4.4.2.1.5.1.5 = STRING: "Fuser"
iso.3.6.1.4.1.641.6.4.4.2.1.5.1.6 = STRING: "Transfer Module"
iso.3.6.1.4.1.641.6.4.4.2.1.5.1.7 = STRING: "Magenta Cartridge"
iso.3.6.1.4.1.641.6.4.4.2.1.5.1.8 = STRING: "Waste Toner Bottle"
iso.3.6.1.4.1.641.6.4.4.2.1.5.1.9 = STRING: "Yellow Cartridge"
Tylan commented 3 years ago

Hopefully this patch resolves the issue with the Imaging Unit and Kit. Are all the percentages at least accurate? Also, does the -nofeeder option work as expected now?

check_snmp_printer_1.2.2-patch3.txt

patch check_snmp_printer < check_snmp_printer_1.2.2-patch3.txt

Optimaximal commented 3 years ago

Scanning a C4150 now works just fine. Values are correct...

WARNING: Yellow Toner is at 2.00% remaining.
OK: Black Toner is at 64.00% remaining.
OK: Transfer Unit is at 79.00% remaining.
OK: Cyan Toner is at 38.00% remaining.
OK: Color Imaging Kit is at 88.00% remaining.
OK: Magenta Toner is at 28.00% remaining.
OK: Black Imaging Unit is at 79.00% remaining.
OK: Fuser is at 72.00% remaining.

M5155 values now interpret sub-0 values as 'LOW'.

WARNING: Black Toner levels are LOW.
OK: Imaging Unit is at 49.00% remaining.
OK: Maintenance Kit is at 74.00% remaining.
OK: Roller is at 84.00% remaining.
Label | Value
Imaging_Unit | 49.00
Black_Toner | -3.00
Maintenance_Kit | 74.00
Roller | 84.00

--nofeeder still just returns a pipe as it's obviously removing the value...

root@fs-monitor:/usr/lib/nagios/plugins# ./check_snmp_printer -H 192.168.0.220 -C spice --trays --nofeeder
|

Let me know if you need another walk...

Tylan commented 3 years ago

Good to know for the C4150.

For both M5155's, the OID for Max Capacity shows 35000, but on the good one, the Current Capacity shows 35000 which is 100%, but for the M5155 with the bad toner, the current capacity shows -3 for some reason. I cannot accurately get a % based upon that. Usually -3 means "OK" on certain printers, but Lexmark isn't doing that here. I assumed based upon the messages for this printer:

.1.3.6.1.2.1.43.18.1.1.8.1.518 = STRING: "Cartridge low" .1.3.6.1.2.1.43.18.1.1.8.1.534 = STRING: "Tray 1 Low" .1.3.6.1.2.1.43.18.1.1.8.1.536 = STRING: "Tray 2 Missing"

That -3 must mean low so I wrote into the code when I see a Max Capacity greater than 0 and a Current Capacity lower than 0 to do some extra steps. Unfortunately I cannot grab a % on that so I had to use words instead to indicate the level. Is the black cartridge really low in this particular instance?

For the -nofeeder I need to look at the code a bit more to see why it's also removing Tray 1 when activated. I'll get back to you on that soon.

Tylan commented 3 years ago

Hopefully this patch fixes the nofeeder issue:

check_snmp_printer_1.2.2-patch4.txt

patch check_snmp_printer < check_snmp_printer_1.2.2-patch4.txt

Optimaximal commented 3 years ago

The black cartridge on this printer is really low - I'm not sure the printer even knows the exact amount, hence ~.

**Black Cartridge**
--
Toner Remaining | ~2%
Cartridge Capacity | Up to 35000 Pages at approximately 5% coverage
Serial Number | CAP1730814A2
Type | Genuine

--nofeeder is now showing the trays minus the manual envelope trays, but the values returned don't seem to refer to the values the printer is outputting...

./check_snmp_printer -H 192.168.0.227 --trays -C spice --metric --nofeeder
OK: Tray 1 (210mm x 297mm) is at 100.00% paper remaining.
OK: Tray 2 (210mm x 297mm)
|Tray_1=2;;;; Tray_2=2;;;;

icinga2web:

OK: Tray 1 (210mm x 297mm) is at 100.00% paper remaining.
OK: Tray 2 (210mm x 297mm)

Printer UI:

Paper Input Tray:    Status:    Capacity:    Size:    Type:
Tray 1                     OK          550             A4       Plain Paper
Tray 2                     Low        550             A4        Plain Paper

I've output both .1.3.6.1.2.1.43.8.2.1 and .1.3.6.1.2.1.43.8.2.1.10.1 and I cannot obviously say where the 2 is coming from, but the output of the latter does seem to tally '-3' meaning 'LOW'...

snmpwalk 192.168.0.227 -v 1 -c spice .1.3.6.1.2.1.43.8.2.1.10.1
iso.3.6.1.2.1.43.8.2.1.10.1.1 = INTEGER: 550
iso.3.6.1.2.1.43.8.2.1.10.1.2 = INTEGER: -3
iso.3.6.1.2.1.43.8.2.1.10.1.3 = INTEGER: -3
iso.3.6.1.2.1.43.8.2.1.10.1.4 = INTEGER: -3
iso.3.6.1.2.1.43.8.2.1.10.1.5 = INTEGER: 0
Tylan commented 3 years ago

On the one that shows Low, but I report OK, can you provide with an snmpwalk for 1.3.6.1.2.1.43.8.2.1.11.1?

As for the 2, because some trays don't really report a % I opted for 2=OK 1=LOW 0=OUT, but I will certainly revisit that to see about changing it to a % for the perfdata.

Optimaximal commented 3 years ago
snmpwalk -c spice -v 2c 192.168.0.227 1.3.6.1.2.1.43.8.2.1.11.1
iso.3.6.1.2.1.43.8.2.1.11.1.1 = INTEGER: 4
iso.3.6.1.2.1.43.8.2.1.11.1.2 = INTEGER: 4
iso.3.6.1.2.1.43.8.2.1.11.1.3 = INTEGER: 4
iso.3.6.1.2.1.43.8.2.1.11.1.4 = INTEGER: 4
iso.3.6.1.2.1.43.8.2.1.11.1.5 = INTEGER: 17
Tylan commented 3 years ago

So looking into this it gets a pick tricky. According to the Lexmark MIB it appears -3 means at least something is remaining. So even though the Printer UI knows better, the OID won't provide an accurate reading and just presents -3.

prtInputCurrentLevel OBJECT-TYPE SYNTAX Integer32 -- in capacity units -- (PrtCapacityUnitTC). MAX-ACCESS read-write STATUS current DESCRIPTION "The current capacity of the input sub-unit in input sub-unit capacity units (PrtCapacityUnitTC). If this input sub-unit can reliably sense this value, the value is sensed by the printer and may not be changed by management requests; otherwise, the value may be written (by a Remote Control Panel or a Management Application). The value (-1) means other and specifically indicates that the sub-unit places no restrictions on this parameter. The value (-2) means unknown. The value (-3) means that the printer knows that at least one unit remains." ::= { prtInputEntry 10 }

Tylan commented 3 years ago

upon further reflection I think I'm going to label -3 from Lexmark as low and give a warning out. Let me know if this affects any other lexmark readings in an out of the ordinary way.

I'm still on the fence about changing the 2, 1, 0 perf data as there's a lot of printers out there that either report a % or not and I think the 2, 1, 0 might be the way to go.

Tylan commented 3 years ago

Okay so I played around with the tray's perf data and I put it in as a % now. If I cannot read the percentage but I assume its OK it's statically set to 100, if I assume it's Low I statically set it to 10 and if I assume it's empty I statically set it to 0, otherwise it will display the correct % in the perf data if I can calculate it. Let me know if how this works out for you.

check_snmp_printer_1.2.2-patch5.txt

patch check_snmp_printer < check_snmp_printer_1.2.2-patch5.txt

Optimaximal commented 3 years ago

Sorry for the delay - just testing this now...

Tylan commented 3 years ago

How'd the patch work out?

Optimaximal commented 3 years ago

I do have a problem with the tray readings triggering flapping - i'm trying to collect some data before reporting back.

Optimaximal commented 3 years ago

Here's data from this morning alone on one of the printers...

Friday, September 11, 2020
OK
09:21:25
WARNING
09:20:28
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
09:19:31
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
09:05:06
WARNING
08:55:30
WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
08:54:33
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
08:53:36
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
08:39:11
WARNING
08:10:22
WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
08:09:25
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
08:08:28
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
08:03:40
WARNING
07:54:03
WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
07:53:03
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
07:52:03
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
07:47:03
WARNING
05:59:56
WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
05:58:59
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
05:58:02
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
05:43:38
WARNING
05:42:40
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
05:37:52
WARNING
05:09:03
WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
05:08:03
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
05:07:03
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
04:52:31
WARNING
04:47:43
WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
04:46:45
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
04:45:48
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
04:31:24
WARNING
04:30:27
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
04:29:30
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
04:24:41
WARNING
04:19:53
WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
04:18:56
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
04:17:59
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
04:08:22
WARNING
04:07:25
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
03:57:49
WARNING
03:43:24
WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
03:42:27
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
03:41:30
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
03:36:42
WARNING
03:35:45
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
03:34:48
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
03:29:59
WARNING
03:15:35
WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
03:14:38
[ 2/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

WARNING
03:13:40
[ 1/3 ] WARNING: Tray 1 is LOW. (210mm x 297mm)

OK
02:59:16

This is overnight flapping, whilst the printer is sleeping. Not every 5155 is doing it.

Tylan commented 3 years ago

Well that's very strange. Is it more than one 5155? I know you said not everyone is doing it but curious if it's a one-off printer or a couple that do it? Can you provide me with the snmpwalk on one of the flapping ones and one of the good ones for these OID:

1.3.6.1.2.1.43.8.2.1

Optimaximal commented 3 years ago

I've run out of time today, so i'll try and get this for you next week. In the meantime, i'll monitor the problem over the weekend as I've got EasyNag running on my phone.

Optimaximal commented 3 years ago

Right, I've redone my 'check_snmp_printer' service templates in Icinga2 (learning fields and args), which has had the side effect of wiping out all the history of the service - i'll continue to monitor...

Optimaximal commented 3 years ago

Right, since re-doing the services and resolving an issue with how I was passing multiple check commands, this hasn't flapped, so it could either have been down to a glitch with the way Icinga2 was running the checks (i.e. a stale config) or someone has just filled the tray in the respective printer.

Will monitor for another day or so then call it done!

Tylan commented 3 years ago

Sweet! Glad to hear the flapping at least stopped. Let me know in a few days and if no more flapping I'll officially release 1.2.2. Thanks for all the testing!

Btw, I'd be remiss if I didn't at least say how much I love your Monkey Island avatar ;)

Optimaximal commented 3 years ago

Found a new bug - 'LOW' tray warnings are not being suppressed by setting the critical & warn stats on the tray check to 0!

check_snmp_printer -H 192.168.0.227 -C spice --trays -w 0 -c 0 --metric --nofeeder

WARNING: Tray 2 is LOW. (210mm x 297mm)
OK: Tray 1 (210mm x 297mm) is at 100.00% paper remaining.
|Tray_1=100.00;;;; Tray_2=100.00;;;;
Tylan commented 3 years ago

Good catch :) Try this patch and let me know.

check_snmp_printer_1.2.2-patch6.txt

patch check_snmp_printer < check_snmp_printer_1.2.2-patch6.txt

Optimaximal commented 3 years ago

Yep, that's solved that one.

Tylan commented 3 years ago

gonna head and close this out let me know if its still an issue with the flapping