Page 1 of 2

check-cisco.pl plugin

Posted: Tue Jan 07, 2014 2:27 pm
by vvz
HI!
I'm not sure this is a right place to ask about, but if anybody tried check-cisco.pl plugin, could you explain how it works with fans and power supply ckecks?
In my case if i check interface status or CPU load it works just perfectly.
But if I'm trying to check Fans or Power supply I got strange results.
Let's say I have Cisco Catalyst switch connected to my PC and run
./check-cisco.pl -H 192.168.1.205 -C public -t fan
I got reply
Fans: OK - 1 Fans are running all good | total=0 err=0
but if my switch even is not powered and I throw the same command I got reply
Fans: OK - 0 Fans are running all good | total=0 err=0
As you can see it defines that there is no Fans (which is obviously right , but they are running good!

I wasn't able to find out plugin's owner email, so somebody might have the same problem?

What was solution?

Any other info you need just let me know

Re: check-cisco.pl plugin

Posted: Tue Jan 07, 2014 2:33 pm
by slansing
I don't see this plugin on our exchange, where did you find it? Can you provide a link? You will need to make an alteration to the plugin script that will change the text output if no fans are detected to be running.

Re: check-cisco.pl plugin

Posted: Tue Jan 07, 2014 2:41 pm
by vvz
it is http://exchange.nagios.org/directory/Pl ... st/details

but code itself is placed on github

Yes, I've tried to change the code, but my perl experience is not enough :(

Re: check-cisco.pl plugin

Posted: Tue Jan 07, 2014 2:48 pm
by vvz
if you could recommend me any other plugins to check fans and power supply status for catalyst, it would be enough for me
but I need plugins to inform (warning and critical) status how many fans (ps) down and (or) how many are up.

Re: check-cisco.pl plugin

Posted: Tue Jan 07, 2014 3:45 pm
by slansing
Initially you are going to want to look at lines 345 and 348-350:

Code: Select all

345-    $err_msg = "all good";

348-    if($total_err <= $warn) {
349-                   $stat = 0;
350-                   $msg = "Fans: OK - $sum Fans are running $err_msg";
You can change the $err_msg value during the above else value which will populate $err_msg in line 350 if there is nothing causing a warning, or critical state return.

Re: check-cisco.pl plugin

Posted: Tue Jan 07, 2014 3:51 pm
by sreinhardt
Actually, I do not agree with slansing, he is correct that this is where your output is coming from. However this is perfectly acceptable for when fan states are ok, but it needs a check for no fans found, and obviously does not seem to be checking correctly if the snmp session was not created properly and recieved no information. Let me see what I can do about a quick fix for you.

Re: check-cisco.pl plugin

Posted: Tue Jan 07, 2014 4:05 pm
by sreinhardt
Try changing lines 327-367 to this:

Code: Select all

} elsif($check_type eq "fan") {
        my $R_tbl = $snmp_session->get_table($S_fan_name);
        my $total_err = 0;
        my $err_msg;
        my $sum = 0;
        foreach my $oid ( keys %$R_tbl) {
                $sum = $sum + 1;
                my $name = "$$R_tbl{$oid}";
                my $id = "$oid";
                $id =~ s/$S_fan_name\.//;
                my $R_stat = $snmp_session->get_request(-varbindlist => ["$S_fan_stat.$id"]);
                my $stat = $R_stat->{"$S_fan_stat.$id"};
                if($stat != 1) {
                        $total_err = $total_err + 1;
                        $err_msg = "$err_msg $name -> $phy_dev_status{$stat}";
                }
        }
		
		if ($sum == 0) {
			$err_msg = "Fans: Unknown, no fans were detected.";
			$stat = 3;
		} 
		else {
			
			if($total_err != 0) {
					$err_msg = ", $err_msg have an error";
			} else {
					$err_msg = "all good";
			}
			
			if($total_err <= $warn) {
					$stat = 0;
					$msg = "Fans: OK - $sum Fans are running $err_msg";
			} elsif($total_err > $warn and $total_err < $crit) {
					$stat = 1;
					$msg = "Fans: Warn - $sum Fans are running $err_msg";
			} elsif($total_err >= $crit) {
					$stat = 2;
					$msg = "Fans: Crit - $sum Fans are running $err_msg";
			}
		}
It will make any time that 0 fans are detected an unknown status, and report an message saying that fans were not detected. I would highly suggest testing this via the cli before full implementation in nagios.

Re: check-cisco.pl plugin

Posted: Tue Jan 07, 2014 4:33 pm
by vvz
I' ve tried and got this reply
| total=0 err=0
nothing before " | total=0 err=0 "

Re: check-cisco.pl plugin

Posted: Tue Jan 07, 2014 4:37 pm
by slansing
Can you upload a new attachment of your script as you have edited it?

Re: check-cisco.pl plugin

Posted: Tue Jan 07, 2014 4:40 pm
by vvz
Yes, it is attached