Page 1 of 1

check_snmp_printer

Posted: Tue Feb 17, 2015 5:56 pm
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

Re: check_snmp_printer

Posted: Tue Feb 17, 2015 6:09 pm
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?

Re: check_snmp_printer

Posted: Tue Feb 17, 2015 6:18 pm
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$
	}

Re: check_snmp_printer

Posted: Tue Feb 17, 2015 7:33 pm
by Pikmin
Sorry for the double post

Re: check_snmp_printer

Posted: Tue Feb 17, 2015 7:37 pm
by Pikmin
and the triple post

Re: check_snmp_printer

Posted: Wed Feb 18, 2015 11:48 am
by tgriep
Did changing to single quotes fix the issue?

If you are still having problems, please post the full error.

Re: check_snmp_printer

Posted: Wed Feb 18, 2015 3:32 pm
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

Re: check_snmp_printer

Posted: Wed Feb 18, 2015 3:38 pm
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.