check-cisco.pl plugin

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.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: check-cisco.pl plugin

Post by sreinhardt »

I see what the issue is, the print statement uses $msg not $err_msg. Just change this(lines 351-354):

Code: Select all

	if($sum == 0) {
		$err_msg = "Fans: unknown, no fans were detected.";
		$stat = 3;
	}
to this:

Code: Select all

	if($sum == 0) {
		$err_msg = "Fans: unknown, no fans were detected.";
		$msg = "$err_msg";
		$stat = 3;
	}
or:

Code: Select all

	if($sum == 0) {
		$msg = "Fans: unknown, no fans were detected.";
		$stat = 3;
	}
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

Re: check-cisco.pl plugin

Post by vvz »

still the same, if switch is not powered.
| total=0 err=0
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: check-cisco.pl plugin

Post by sreinhardt »

Well, its clearly catching correctly on the if statement we added, which of the options above did you use this time, could you post the script one more time as you have it? I see no reason that this shouldn't be working for you from the last script to now. Also if you could post exactly how your are running the command to test it. In the statement "total = 0" that 0 is $sum, just so you know why I feel its definitely catching the if statement.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

Re: check-cisco.pl plugin

Post by vvz »

I've added print statement in your code ( I also playing here with script),
script is attached

switch is not connected and this line is copied directly from terminal

Code: Select all

  ./check-cisco.pl -H 192.168.1.205 -C public -t fan  
got output

Code: Select all

  | total=0 err=0  

when switch is connected everything is ok
Attachments
check-cisco.pl
(13.83 KiB) Downloaded 522 times
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: check-cisco.pl plugin

Post by sreinhardt »

This works perfectly on my system, including both prints. So, what OS are you presently running, and what perl packages do you have?

Code: Select all

rpm -qa | grep -i perl 
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

Re: check-cisco.pl plugin

Post by vvz »

linux-mint 15, perl-base 5.14.2-21 perl-modules 5.14.2-21
OK thnx, if it works on your PC earlier or later it will work on my
thank you for your help
vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

Re: check-cisco.pl plugin

Post by vvz »

thank you, slansing
you were extremly helpful
now it works

it was because i'm absolutely newbie in perl
vvz
Posts: 187
Joined: Wed Oct 30, 2013 5:15 pm

Re: check-cisco.pl plugin

Post by vvz »

thank you sreinhardt for your help
you saved a lot of time for me
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: check-cisco.pl plugin

Post by sreinhardt »

You're welcome, glad it's working for you now! Going to lock this up then.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked