check_snmp_printer

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Pikmin
Posts: 80
Joined: Tue Feb 17, 2015 5:32 pm

check_snmp_printer

Post by Pikmin »

I'm using FAN (Nagios Core 3.4.4)
Trying to get this plugin to work http://exchange.nagios.org/index.php?op ... &Itemid=74

/etc/nagios/objects/commands.cfg

Code: Select all

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

Code: Select all

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

Code: Select all

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

EDIT: It's been a few hours and my replies are still not approved.
Thanks for your reply
I checked to make sure I can run the command as nagios user and works fine, nagios is the owner of the check_snmp_printer script, I have removed the extra service in /etc/nagios/command_plugins.cfg
Last edited by Pikmin on Tue Feb 17, 2015 10:10 pm, edited 1 time in total.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: check_snmp_printer

Post by Box293 »

A couple of things to try:

Run the test as the nagios user:

Code: Select all

su nagios
./check_snmp_printer -H 192.168.4.50 -C public -x "CONSUM ALL" -w 20 -c 10
Does the host object Test-Printer have the address 192.168.4.50 ?

For $ARG2$ use single quotes instead:

Code: Select all

define service{
   use             generic-service
   host_name         Test-Printer
   service_description Toner Supply
   check_command       check_snmp_printer!public!'CONSUM Toners'!20!10
   } 
Have a look in objects.cache for the service 'Toner Supply', this will show you the final config nagios is using.

I'm not sure why you have the command defined in commands.cfg and then again in command-plugins.cfg ... is this a FAN thing?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Pikmin
Posts: 80
Joined: Tue Feb 17, 2015 5:32 pm

Re: check_snmp_printer

Post by Pikmin »

Hi Box293
Thank you for your reply, appreciate the help. Will try with single quotes

Code: Select all

[root@localhost plugins]# su nagios
sh-3.2$ ./check_snmp_printer -H 192.168.4.50 -C public -x "CONSUM ALL" -w 20 -c 10
Black Toner [K] Cartridge;SN1220AA80E00004A0 is at 98% - OK! Yellow Toner [Y] Cartridge;SN04156480E0000478 is at 89% - OK! Magenta Toner [M] Cartridge;SN11338080E0000479 is at 82% - OK! Cyan Toner [C] Cartridge;SN0F2DD980E000047A is at 81% - 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=98;20;10; Yellow Toner [Y] Cartridge;SN04156480E0000478=89;20;10; Magenta Toner [M] Cartridge;SN11338080E0000479=82;20;10; Cyan Toner [C] Cartridge;SN0F2DD980E000047A=81;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;
It might be a FAN thing, without it I was getting an error when starting the nagios service, that the command is not there

/var/log/nagios/objects.cache

Code: Select all

define command {
	command_name	check_snmp_printer
	command_line	$USER1$/check_snmp_printer -H $HOSTADDRESS$ -C $ARG1$ -x $ARG2 -w $ARG3$ -c $ARG4$
	}
Pikmin
Posts: 80
Joined: Tue Feb 17, 2015 5:32 pm

Re: check_snmp_printer

Post by Pikmin »

Sorry for the double post
Last edited by Pikmin on Wed Feb 18, 2015 3:30 pm, edited 1 time in total.
Pikmin
Posts: 80
Joined: Tue Feb 17, 2015 5:32 pm

Re: check_snmp_printer

Post by Pikmin »

and the triple post
Last edited by Pikmin on Wed Feb 18, 2015 3:30 pm, edited 1 time in total.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: check_snmp_printer

Post by tgriep »

Did changing to single quotes fix the issue?

If you are still having problems, please post the full error.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Pikmin
Posts: 80
Joined: Tue Feb 17, 2015 5:32 pm

Re: check_snmp_printer

Post by Pikmin »

Yes Box293 was kind enough to point out the problem- I was missing a $ sign on ARG2 as can be seen
Solved!
Thank you kindly
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_snmp_printer

Post by ssax »

That's great to hear, I will be locking the topic, if you have any additional questions feel free to create another one.
Locked