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

Services are critical when printer is offline #31

Closed gitbro23 closed 1 year ago

gitbro23 commented 1 year ago

Hello everyone,

I’m searching for a solution to set the service status to OK when the timeout is reached (because the user switched off the printer)

At the moment all monitored services (such as Pagecount, Trays, Consumables, Ping) are shown as CRITICAL when the devices are offline.

I already configured the thresholds to custom values. But this has no effect when the devices are not reachable.

So, can we set the status to OK when the timeout is reached?

See my screenshot 28-03-2023_08-28-06

Thank you very much!

BG

Tylan commented 1 year ago

I added an --ignoreoffline switch you can now use. A word of caution though: the printers you use this on will never tell you when they are actually offline. But you knew that already. Download it from the devel branch and let me know if it's working as you expect:

https://github.com/Tylan/check_snmp_printer/tree/devel

I also cannot control the Ping sensor you have. That is not a part of my code. You would have to disable/delete that one or find a way to silence it.

gitbro23 commented 1 year ago

Thank you for quick response! It seems to be, that your new version is based on the new version 2.0.0 And here is a new requrement, that all my plugins are located in the path "/usr/lib64/nagios/plugins" In my case the plugins are located in the path "/usr/lib/nagios/plugins"

So how can I change the default path in my icinga2 configuration?

Tylan commented 1 year ago

Hi -

I already have /usr/lib/nagios/plugins as well as /usr/lib64/nagios/plugins included. The new dependency may be that in 2.0.0 I switched to Net-SNMP versus Net::SNMP. You may need to install those libraries:

Debian:

sudo apt-get install libsnmp-perl

Centos/RHEL:

sudo yum install net-snmp-devel
gitbro23 commented 1 year ago

Thank you for your help! After I installed the libraries and replaced your new binary I faced a new crtival message Untitled

Update; I switched to SNMP version 2 and now the critical message is gone ;-)

Tylan commented 1 year ago

Awesome! So everything is working as you would expect?

gitbro23 commented 1 year ago

Not everything. The Toshiba printers give back a Timeout when using SNMP V2. But its enabled. Not sure if its a firmware bug on the printer. Untitled2

Tylan commented 1 year ago

Did this work pre 2.0.0?

From the command line can you do a simple snmpwalk against the printer?

snmpwalk -v2c -c public [PRINTER IP] sysName

gitbro23 commented 1 year ago

Hi Taylan, I made a test with the old version 1.3.1 Here the snmp V2 check is working fine. See my screenshot Untitled3

Tylan commented 1 year ago

Hi - can you try raising the timeout a bit? -t 60 for example

navratilp commented 1 year ago

Hi - The Xerox printers give back a Timeout when using SNMP V2. But SNMP its enabled.

output with parameter --consum (timeout) xxxx@icinga2:/home/navrc# perl /usr/lib/nagios/plugins/check_snmp_printer -H 10.0.0.33 -Cpublic -v2 --consum CRITICAL - Timeout after 15 seconds

output with parameter --pagecount (OK) xxxx@icinga2:/home/navrc# perl /usr/lib/nagios/plugins/check_snmp_printer -H 10.0.0.33 -Cpublic -v2 --pagecount Pagecount is 62295 Black-and-White, 144901 Color |Black-and-White=62295;;;; Color=144901;;;;

snmpwalk -v2c -c public 10.0.0.33 sysName sysName: Unknown Object Identifier (Sub-id not found: (top) -> sysName)

snmpwalk -v2c -c public 10.0.0.33 . iso.0.8802.1.1.1.1.1.1.0 = INTEGER: 2 iso.0.8802.1.1.1.1.1.2.1.2.1 = STRING: "2.3" iso.0.8802.1.1.1.1.1.2.1.3.1 = INTEGER: 1 ..................................

Thank you very much! PN

Tylan commented 1 year ago

Hi - The Xerox printers give back a Timeout when using SNMP V2. But SNMP its enabled.

output with parameter --consum (timeout) xxxx@icinga2:/home/navrc# perl /usr/lib/nagios/plugins/check_snmp_printer -H 10.0.0.33 -Cpublic -v2 --consum CRITICAL - Timeout after 15 seconds

output with parameter --pagecount (OK) xxxx@icinga2:/home/navrc# perl /usr/lib/nagios/plugins/check_snmp_printer -H 10.0.0.33 -Cpublic -v2 --pagecount Pagecount is 62295 Black-and-White, 144901 Color |Black-and-White=62295;;;; Color=144901;;;;

snmpwalk -v2c -c public 10.0.0.33 sysName sysName: Unknown Object Identifier (Sub-id not found: (top) -> sysName)

snmpwalk -v2c -c public 10.0.0.33 . iso.0.8802.1.1.1.1.1.1.0 = INTEGER: 2 iso.0.8802.1.1.1.1.1.2.1.2.1 = STRING: "2.3" iso.0.8802.1.1.1.1.1.2.1.3.1 = INTEGER: 1 ..................................

Thank you very much! PN

Hi - if you add -t 60 to the check_snmp_printer command does it work? I might need to change the default timeout on the new version.

edit: Does it only timeout for when you check consumables?

navratilp commented 1 year ago

Hi - The Xerox printers give back a Timeout when using SNMP V2. But SNMP its enabled. output with parameter --consum (timeout) xxxx@icinga2:/home/navrc# perl /usr/lib/nagios/plugins/check_snmp_printer -H 10.0.0.33 -Cpublic -v2 --consum CRITICAL - Timeout after 15 seconds output with parameter --pagecount (OK) xxxx@icinga2:/home/navrc# perl /usr/lib/nagios/plugins/check_snmp_printer -H 10.0.0.33 -Cpublic -v2 --pagecount Pagecount is 62295 Black-and-White, 144901 Color |Black-and-White=62295;;;; Color=144901;;;; snmpwalk -v2c -c public 10.0.0.33 sysName sysName: Unknown Object Identifier (Sub-id not found: (top) -> sysName) snmpwalk -v2c -c public 10.0.0.33 . iso.0.8802.1.1.1.1.1.1.0 = INTEGER: 2 iso.0.8802.1.1.1.1.1.2.1.2.1 = STRING: "2.3" iso.0.8802.1.1.1.1.1.2.1.3.1 = INTEGER: 1 .................................. Thank you very much! PN

Hi - if you add -t 60 to the check_snmp_printer command does it work? I might need to change the default timeout on the new version.

xxxx@icinga2:/home/navrc# perl /usr/lib/nagios/plugins/check_snmp_printer -H 10.0.0.33 -Cpublic -v2 --consum -t 60 CRITICAL - Timeout after 60 seconds

edit: Does it only timeout for when you check consumables?

Yes Yes, it only expires when checking consumables

Tylan commented 1 year ago

Okay, thanks for that info. Let me dig around and see why.

gitbro23 commented 1 year ago

Yes im my case its also happening after 60 seconds And its also happening when checking the trays. Only pagecount is working fine.

Tylan commented 1 year ago

And only certain printers, correct? You mentioned Toshiba and @navratilp mentioned Xerox. I have a Xerox printer on prem that works just fine so I will have to poke around a bit more.

navratilp commented 1 year ago

And only certain printers, correct? You mentioned Toshiba and @navratilp mentioned Xerox. I have a Xerox printer on prem that works just fine so I will have to poke around a bit more.

Yes, the xerox phaser 7500 printer has a problem, but the HP Color LaserJet Pro m252n printer works correctly

Tylan commented 1 year ago

I made a slight change in hope that corrects the issue. I'll work to enable a debugging switch next but lets see if this fixes it.

https://github.com/Tylan/check_snmp_printer/blob/devel/check_snmp_printer

Grab this version - should have the April 4 date on it

Version 2.0.1 (April 4, 2023)

gitbro23 commented 1 year ago

GREAT, Sir! You did it!!

now everything is green! And also the new switch (--ignoreoffline) is working fine!!

Thanks man. Have a great day.

Best regards from Germany!

navratilp commented 1 year ago

I made a slight change in hope that corrects the issue. I'll work to enable a debugging switch next but lets see if this fixes it.

https://github.com/Tylan/check_snmp_printer/blob/devel/check_snmp_printer

Grab this version - should have the April 4 date on it

Version 2.0.1 (April 4, 2023)

Hi Tylan Unfortunately, I keep getting the same message.

perl /usr/lib/nagios/plugins/check_snmp_printer -H 10.0.0.33 -Cpublic -v2 --consum -t 30 CRITICAL - Timeout after 30 seconds

snmpwalk -v2c -c public 10.0.0.33 .1.3.6.1.2.1.43.31 iso.3.6.1.2.1.43.31 = No Such Object available on this agent at this OID

snmpwalk -v2c -c public 10.0.0.33 .1.3.6.1.2.1.43.11.1.1.6.1 iso.3.6.1.2.1.43.11.1.1.6.1.1 = STRING: "Cyan High Capacity Toner Cartridge, Phaser 7500 D, P/N 106R01443" iso.3.6.1.2.1.43.11.1.1.6.1.2 = STRING: "Magenta High Capacity Toner Cartridge, Phaser 7500 D, P/N 106R01444" iso.3.6.1.2.1.43.11.1.1.6.1.3 = STRING: "Yellow High Capacity Toner Cartridge, Phaser 7500 D, P/N 106R01445" iso.3.6.1.2.1.43.11.1.1.6.1.4 = STRING: "Black High Capacity Toner Cartridge, Phaser 7500 D, P/N 106R01446" iso.3.6.1.2.1.43.11.1.1.6.1.5 = STRING: "Transfer Roller, Phaser 7500, P/N 059K53654" iso.3.6.1.2.1.43.11.1.1.6.1.6 = STRING: "Fuser/Belt Cleaner Assembly, Phaser 7500,P/N 115R00061(110V)/ P/N 115R00062(220V)" iso.3.6.1.2.1.43.11.1.1.6.1.7 = STRING: "Waste Cartridge, Phaser 7500, P/N 108R00865" iso.3.6.1.2.1.43.11.1.1.6.1.8 = STRING: "Accumulator Belt, Phaser 7500, P/N 604K15321" iso.3.6.1.2.1.43.11.1.1.6.1.9 = STRING: "Black Imaging Unit, Phaser 7500, P/N 108R00861" iso.3.6.1.2.1.43.11.1.1.6.1.10 = STRING: "Cyan Imaging Unit, Phaser 7500, P/N 108R00861" iso.3.6.1.2.1.43.11.1.1.6.1.11 = STRING: "Magenta Imaging Unit, Phaser 7500, P/N 108R00861" iso.3.6.1.2.1.43.11.1.1.6.1.12 = STRING: "Yellow Imaging Unit, Phaser 7500, P/N 108R00861"

snmpwalk -v2c -c public 10.0.0.33 .1.3.6.1.2.1.43.11.1.1.8.1 iso.3.6.1.2.1.43.11.1.1.8.1.1 = INTEGER: 1580 iso.3.6.1.2.1.43.11.1.1.8.1.2 = INTEGER: 2280 iso.3.6.1.2.1.43.11.1.1.8.1.3 = INTEGER: 2210 iso.3.6.1.2.1.43.11.1.1.8.1.4 = INTEGER: 2920 iso.3.6.1.2.1.43.11.1.1.8.1.5 = INTEGER: 100 iso.3.6.1.2.1.43.11.1.1.8.1.6 = INTEGER: 100 iso.3.6.1.2.1.43.11.1.1.8.1.7 = INTEGER: 100 iso.3.6.1.2.1.43.11.1.1.8.1.8 = INTEGER: 100 iso.3.6.1.2.1.43.11.1.1.8.1.9 = INTEGER: 100 iso.3.6.1.2.1.43.11.1.1.8.1.10 = INTEGER: 100 iso.3.6.1.2.1.43.11.1.1.8.1.11 = INTEGER: 100 iso.3.6.1.2.1.43.11.1.1.8.1.12 = INTEGER: 100

snmpwalk -v2c -c public 10.0.0.33 .1.3.6.1.2.1.43.11.1.1.9.1 iso.3.6.1.2.1.43.11.1.1.9.1.1 = INTEGER: 47 iso.3.6.1.2.1.43.11.1.1.9.1.2 = INTEGER: 46 iso.3.6.1.2.1.43.11.1.1.9.1.3 = INTEGER: 1238 iso.3.6.1.2.1.43.11.1.1.9.1.4 = INTEGER: 730 iso.3.6.1.2.1.43.11.1.1.9.1.5 = INTEGER: 95 iso.3.6.1.2.1.43.11.1.1.9.1.6 = INTEGER: 91 iso.3.6.1.2.1.43.11.1.1.9.1.7 = INTEGER: 100 iso.3.6.1.2.1.43.11.1.1.9.1.8 = INTEGER: 67 iso.3.6.1.2.1.43.11.1.1.9.1.9 = INTEGER: 15 iso.3.6.1.2.1.43.11.1.1.9.1.10 = INTEGER: 15 iso.3.6.1.2.1.43.11.1.1.9.1.11 = INTEGER: 15 iso.3.6.1.2.1.43.11.1.1.9.1.12 = INTEGER: 15

Thanks Petr N.

Tylan commented 1 year ago

@navratilp you're using the April 4 version, correct?

I modified some other stuff and there's an April 5 version but it just fixes cosmetic output from your printer:

https://github.com/Tylan/check_snmp_printer/blob/devel/check_snmp_printer

If I run your snmpwalk output through my simulator I retrieve correctly. Granted, my simulator isn't a Xerox Phaser.

./check_snmp_printer -H 10.56.18.63:1024 -v 2 -C xerox-phaser7500 --consum -t 30 CRITICAL: Magenta Toner is at 2.02% remaining. CRITICAL: Cyan Toner is at 2.97% remaining. WARNING: Magenta Imaging Unit is at 15.00% remaining. WARNING: Black Imaging Unit is at 15.00% remaining. WARNING: Yellow Imaging Unit is at 15.00% remaining. WARNING: Cyan Imaging Unit is at 15.00% remaining. OK: Yellow Toner is at 56.02% remaining. OK: Black Toner is at 25.00% remaining. OK: Transfer Unit is at 95.00% remaining. |Magenta_Imaging_Unit=15.00;;;; Yellow_Toner=56.02;;;; Black_Imaging_Unit=15.00;;;; Magenta_Toner=2.02;;;; Yellow_Imaging_Unit=15.00;;;; Black_Toner=25.00;;;; Cyan_Toner=2.97;;;; Cyan_Imaging_Unit=15.00;;;; Transfer_Unit=95.00;;;;

Do you have multiple Xerox Phasers? Is this the only one? If you have other Xerox printers, do they work? My last employment had 2 Phasers and they both were very picky but that was just my experience.

navratilp commented 1 year ago

Dne 05. 04. 23 v 13:52 Tylan napsal(a):

@navratilp you're using the April 4 version, correct?

Yes, I downloaded the new one now.

I modified some other stuff and there's an April 5 version but it just fixes cosmetic output from your printer:

https://github.com/Tylan/check_snmp_printer/blob/devel/check_snmp_printer

If I run your snmpwalk output through my simulator I retrieve correctly. Granted, my simulator isn't an Xerox Phaser.

./check_snmp_printer -H 10.86.128.63:1024 -v 2 -C canon-phaser7500 --consum -t 30 CRITICAL: Magenta Toner is at 2.02% remaining. CRITICAL: Cyan Toner is at 2.97% remaining. WARNING: Magenta Imaging Unit is at 15.00% remaining. WARNING: Black Imaging Unit is at 15.00% remaining. WARNING: Yellow Imaging Unit is at 15.00% remaining. WARNING: Cyan Imaging Unit is at 15.00% remaining. OK: Yellow Toner is at 56.02% remaining. OK: Black Toner is at 25.00% remaining. OK: Transfer Unit is at 95.00% remaining. |Magenta_Imaging_Unit=15.00;;;; Yellow_Toner=56.02;;;; Black_Imaging_Unit=15.00;;;; Magenta_Toner=2.02;;;; Yellow_Imaging_Unit=15.00;;;; Black_Toner=25.00;;;; Cyan_Toner=2.97;;;; Cyan_Imaging_Unit=15.00;;;; Transfer_Unit=95.00;;;;

Do you have multiple Xerox Phasers? Yes 6600 a 7500

Is this the only one? If you have other Xerox printers, do they work? My last employment had 2 Phasers and they both were very picky but that was just my experience.

Hi, after uploading the latest version, the parameter : "--consum" work on Xerox printers, start to working.

./check_snmp_printer -H 10.0.0.33 -v 2 -C public --consum CRITICAL: Cyan Toner is at 2.97% remaining. CRITICAL: Magenta Toner is at 2.02% remaining. WARNING: Yellow Imaging Unit is at 15.00% remaining. WARNING: Cyan Imaging Unit is at 15.00% remaining. WARNING: Black Imaging Unit is at 15.00% remaining. WARNING: Magenta Imaging Unit is at 15.00% remaining. OK: Yellow Toner is at 55.02% remaining. OK: Black Toner is at 25.00% remaining. OK: Transfer Unit is at 95.00% remaining. |Cyan_Toner=2.97;;;; Yellow_Imaging_Unit=15.00;;;; Cyan_Imaging_Unit=15.00;;;; Yellow_Toner=55.02;;;; Black_Toner=25.00;;;; Magenta_Toner=2.02;;;; Black_Imaging_Unit=15.00;;;; Transfer_Unit=95.00;;;; Magenta_Imaging_Unit=15.00;;;;

Thanks a lot Peter

Tylan commented 1 year ago

Great news! Glad it's all working now for both of you 😄 Marking as resolved and closing out.