[Nagios-users] nagios plugins return code issue
Hello all, I've googled around everywhere trying to find an answer here and came up unsuccessful, so if anyone has had experience in this situation, I'd appreciate help! Basically, the issue that I'm having is that I have a couple of temperature plugins that are reporting errors in Nagios and at the command line they're exiting in 0: check7204temp.pl - Return code of 255 is out of bounds and checkciscotemp.pl - Return code of 9 is out of bounds If I run a echo $? at the command line after running the command successfully, I get 0. Thanks for any help anyone can provide!! My perms are 755 and nagios user owns the plugins and I've run successfully with nagios user and got 0 output. I'm really stumped!! Here's the code for the plugins: *** check7204temp.pl: #!/usr/bin/perl -w # check_ciscotemp.pl # # Copyright (C) 2000 Leland E. Vandervort lel...@mmania.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # you should have received a copy of the GNU General Public License # along with this program (or with Nagios); if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA # Nagios pluging to check inlet and outlet temperatures on # Cisco router platforms which support environmental monitoring # (7200, 7500, GSR12000...) # default temperature thresholds are 30C for inlet, 40C outlet. # if input or output is less than thresholds, returns OK # if equal to (the temps don't change that rapidly) returns WARNING # if greater than threshold, returns CRITICAL # if undetermined, or cannot access environmental, returns UNKNOWN # (in accordance with the plugin coding guidelines) use Net::SNMP; use Getopt::Long; #use strict; Getopt::Long::config('auto_abbrev'); #my $critical_vals; #my $warning_vals; #my $inlet_warn; #my $outlet_warn; #my $status; my $response = ; my $timeout = 10; my $community = blah; my $port = 161; my $INTAKE_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.1; my $OUTLET_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.3; my $in_temp; my $out_temp; my $inlet_thresh = 30; my $outlet_thresh = 34; my $hostnm; #my $OID; #my $session; #my $state; #my $error; my %STATUSCODE = ( 'UNKNOWN' = '-1', 'OK' = '0', 'WARNING' = '1', 'CRITICAL' = '2'); my $state = UNKNOWN; $SIG{'ALRM'} = sub { print ERROR: No snmp response from $hostnm (sigALRM)\n; exit($STATUSCODE{UNKNOWN}); }; Getopt::Long::Configure('bundling'); $status = GetOptions (community=s, \$community, C=s, \$community, H=s, \$hostnm, hostname=s, \$hostnm, port=i, \$port, timeout=i, \$timeout, c=s, \$critical_vals, w=s, \$warning_vals, ithresh=i, \$inlet_thresh, othresh=i, \$outlet_thresh); if($status == 0) { show_help; } unless (defined($hostnm)) { $hostnm = shift || show_help; } if (defined($critical_vals)) { if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) { ($inlet_thresh,$outlet_thresh) = ($1, $2); } else { die Cannot Parse Critical Thresholds\n; } } if (defined($warning_vals)) { if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) { ($inlet_warn,$outlet_warn) = ($1, $2); } else { die Cannot Parse Warning Thresholds\n; } }else{ $inlet_warn=$inlet_thresh; $outlet_warn=$outlet_thresh; } alarm($timeout); $in_temp = SNMPGET($INTAKE_TEMP); $out_temp = SNMPGET($OUTLET_TEMP); if (($in_temp $inlet_thresh) ($out_temp $outlet_thresh)) { $state = OK; } elsif (($in_temp == $inlet_thresh) || ($out_temp == $outlet_thresh)) { if(($in_temp $inlet_thresh) || ($out_temp $outlet_thresh)) { $state = CRITICAL; } else { $state = WARNING; } } elsif (($in_temp $inlet_thresh) || ($out_temp $outlet_thresh)) { $state = CRITICAL; } else { $state = WARNING; } print $state Inlet Temp: $in_temp Outlet Temp: $out_temp\n; exit($STATUSCODE{$state}); sub show_help { printf(\nPerl envmon temperature plugin for Nagios\n); printf(Usage:\n); printf( check_ciscotemp [options] hostname Options: -C snmp-community -p snmp-port -i input temperature threshold -o output temperature threshold ); printf(Copyright (C)2000 Leland E. Vandervort\n); printf(check_ciscotemp comes with absolutely NO WARRANTY either implied or explicit\n); printf(This program is licensed under the terms of the\n); printf(GNU General Public License\n(check source code for details)\n\n\n); exit($STATUSCODE{UNKNOWN}); } sub SNMPGET { $OID = shift;
Re: [Nagios-users] nagios plugins return code issue
Sorry - accidentally resent! Melissa A. Huber Linux-Unix Administrator ASCENTDATA Advanced, Secure, Data Centers www.ascentdata.com http://www.ascentdata.com/ mhu...@ascentdata.com 412-968-4030 From: Huber, Melissa Sent: Tuesday, August 17, 2010 2:41 PM To: 'nagios-users@lists.sourceforge.net' Subject: nagios plugins return code issue Hello all, I've googled around everywhere trying to find an answer here and came up unsuccessful, so if anyone has had experience in this situation, I'd appreciate help! Basically, the issue that I'm having is that I have a couple of temperature plugins that are reporting errors in Nagios and at the command line they're exiting in 0: check7204temp.pl - Return code of 255 is out of bounds and checkciscotemp.pl - Return code of 9 is out of bounds If I run a echo $? at the command line after running the command successfully, I get 0. Thanks for any help anyone can provide!! My perms are 755 and nagios user owns the plugins and I've run successfully with nagios user and got 0 output. I'm really stumped!! Here's the code for the plugins: *** check7204temp.pl: #!/usr/bin/perl -w # check_ciscotemp.pl # # Copyright (C) 2000 Leland E. Vandervort lel...@mmania.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # you should have received a copy of the GNU General Public License # along with this program (or with Nagios); if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA # Nagios pluging to check inlet and outlet temperatures on # Cisco router platforms which support environmental monitoring # (7200, 7500, GSR12000...) # default temperature thresholds are 30C for inlet, 40C outlet. # if input or output is less than thresholds, returns OK # if equal to (the temps don't change that rapidly) returns WARNING # if greater than threshold, returns CRITICAL # if undetermined, or cannot access environmental, returns UNKNOWN # (in accordance with the plugin coding guidelines) use Net::SNMP; use Getopt::Long; #use strict; Getopt::Long::config('auto_abbrev'); #my $critical_vals; #my $warning_vals; #my $inlet_warn; #my $outlet_warn; #my $status; my $response = ; my $timeout = 10; my $community = blah; my $port = 161; my $INTAKE_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.1; my $OUTLET_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.3; my $in_temp; my $out_temp; my $inlet_thresh = 30; my $outlet_thresh = 34; my $hostnm; #my $OID; #my $session; #my $state; #my $error; my %STATUSCODE = ( 'UNKNOWN' = '-1', 'OK' = '0', 'WARNING' = '1', 'CRITICAL' = '2'); my $state = UNKNOWN; $SIG{'ALRM'} = sub { print ERROR: No snmp response from $hostnm (sigALRM)\n; exit($STATUSCODE{UNKNOWN}); }; Getopt::Long::Configure('bundling'); $status = GetOptions (community=s, \$community, C=s, \$community, H=s, \$hostnm, hostname=s, \$hostnm, port=i, \$port, timeout=i, \$timeout, c=s, \$critical_vals, w=s, \$warning_vals, ithresh=i, \$inlet_thresh, othresh=i, \$outlet_thresh); if($status == 0) { show_help; } unless (defined($hostnm)) { $hostnm = shift || show_help; } if (defined($critical_vals)) { if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) { ($inlet_thresh,$outlet_thresh) = ($1, $2); } else { die Cannot Parse Critical Thresholds\n; } } if (defined($warning_vals)) { if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) { ($inlet_warn,$outlet_warn) = ($1, $2); } else { die Cannot Parse Warning Thresholds\n; } }else{ $inlet_warn=$inlet_thresh; $outlet_warn=$outlet_thresh; } alarm($timeout); $in_temp = SNMPGET($INTAKE_TEMP); $out_temp = SNMPGET($OUTLET_TEMP); if (($in_temp $inlet_thresh) ($out_temp $outlet_thresh)) { $state = OK; } elsif (($in_temp == $inlet_thresh) || ($out_temp == $outlet_thresh)) { if(($in_temp $inlet_thresh) || ($out_temp $outlet_thresh)) { $state = CRITICAL; } else { $state = WARNING; } } elsif (($in_temp $inlet_thresh) || ($out_temp $outlet_thresh)) { $state = CRITICAL; } else { $state = WARNING; } print $state Inlet Temp: $in_temp Outlet Temp: $out_temp\n; exit($STATUSCODE{$state}); sub show_help { printf(\nPerl envmon temperature plugin for Nagios\n); printf(Usage:\n); printf( check_ciscotemp [options] hostname Options: -C snmp-community -p snmp-port -i input temperature
Re: [Nagios-users] nagios plugins return code issue
For starters, why is use strict commented out? From: Huber, Melissa mhu...@ascentdata.com To: nagios-users@lists.sourceforge.net Sent: Tue, August 17, 2010 2:41:23 PM Subject: [Nagios-users] nagios plugins return code issue Hello all, I've googled around everywhere trying to find an answer here and came up unsuccessful, so if anyone has had experience in this situation, I'd appreciate help! Basically, the issue that I'm having is that I have a couple of temperature plugins that are reporting errors in Nagios and at the command line they're exiting in 0: check7204temp.pl - Return code of 255 is out of bounds and checkciscotemp.pl - Return code of 9 is out of bounds If I run a echo $? at the command line after running the command successfully, I get 0. Thanks for any help anyone can provide!! My perms are 755 and nagios user owns the plugins and I've run successfully with nagios user and got 0 output. I'm really stumped!! Here's the code for the plugins: *** check7204temp.pl: #!/usr/bin/perl -w # check_ciscotemp.pl # # Copyright (C) 2000 Leland E. Vandervort lel...@mmania.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # you should have received a copy of the GNU General Public License # along with this program (or with Nagios); if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA # Nagios pluging to check inlet and outlet temperatures on # Cisco router platforms which support environmental monitoring # (7200, 7500, GSR12000...) # default temperature thresholds are 30C for inlet, 40C outlet. # if input or output is less than thresholds, returns OK # if equal to (the temps don't change that rapidly) returns WARNING # if greater than threshold, returns CRITICAL # if undetermined, or cannot access environmental, returns UNKNOWN # (in accordance with the plugin coding guidelines) use Net::SNMP; use Getopt::Long; #use strict; Getopt::Long::config('auto_abbrev'); #my $critical_vals; #my $warning_vals; #my $inlet_warn; #my $outlet_warn; #my $status; my $response = ; my $timeout = 10; my $community = blah; my $port = 161; my $INTAKE_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.1; my $OUTLET_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.3; my $in_temp; my $out_temp; my $inlet_thresh = 30; my $outlet_thresh = 34; my $hostnm; #my $OID; #my $session; #my $state; #my $error; my %STATUSCODE = ( 'UNKNOWN' = '-1', 'OK' = '0', 'WARNING' = '1', 'CRITICAL' = '2'); my $state = UNKNOWN; $SIG{'ALRM'} = sub { print ERROR: No snmp response from $hostnm (sigALRM)\n; exit($STATUSCODE{UNKNOWN}); }; Getopt::Long::Configure('bundling'); $status = GetOptions (community=s, \$community, C=s, \$community, H=s, \$hostnm, hostname=s, \$hostnm, port=i, \$port, timeout=i, \$timeout, c=s, \$critical_vals, w=s, \$warning_vals, ithresh=i, \$inlet_thresh, othresh=i, \$outlet_thresh); if($status == 0) { show_help; } unless (defined($hostnm)) { $hostnm = shift || show_help; } if (defined($critical_vals)) { if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) { ($inlet_thresh,$outlet_thresh) = ($1, $2); } else { die Cannot Parse Critical Thresholds\n; } } if (defined($warning_vals)) { if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) { ($inlet_warn,$outlet_warn) = ($1, $2); } else { die Cannot Parse Warning Thresholds\n; } }else{ $inlet_warn=$inlet_thresh; $outlet_warn=$outlet_thresh; } alarm($timeout); $in_temp = SNMPGET($INTAKE_TEMP); $out_temp = SNMPGET($OUTLET_TEMP); if (($in_temp $inlet_thresh) ($out_temp $outlet_thresh)) { $state = OK; } elsif (($in_temp == $inlet_thresh) || ($out_temp == $outlet_thresh)) { if(($in_temp $inlet_thresh) || ($out_temp $outlet_thresh)) { $state = CRITICAL; } else { $state = WARNING; } } elsif (($in_temp $inlet_thresh) || ($out_temp $outlet_thresh)) { $state = CRITICAL; } else { $state = WARNING; } print $state Inlet Temp: $in_temp Outlet Temp: $out_temp\n; exit($STATUSCODE{$state}); sub show_help { printf(\nPerl envmon temperature plugin for Nagios\n); printf(Usage:\n); printf( check_ciscotemp [options] hostname Options: -C snmp-community -p snmp-port -i input temperature threshold -o output temperature threshold ); printf(Copyright (C)2000 Leland E. Vandervort\n); printf(check_ciscotemp comes with absolutely NO WARRANTY either implied or explicit
Re: [Nagios-users] nagios plugins return code issue
Umm... Not sure. I just tried uncommenting and got the same results though. I'm taking over managing the nagios server that we have from another collegue who left the company. I've actually migrated everything over to another server that is now running the latest nagios. The previous server was 3.0.6 I believe. I tried searching for an updated version of these plugins, but couldn't find any. I'm not that great with perl scripting either. :/ Missy -Original Message- From: Matthew J. Salerno [mailto:vagabond_k...@yahoo.com] Sent: Tuesday, August 17, 2010 2:58 PM To: Nagios Users List Cc: Huber, Melissa Subject: Re: [Nagios-users] nagios plugins return code issue For starters, why is use strict commented out? From: Huber, Melissa mhu...@ascentdata.com To: nagios-users@lists.sourceforge.net Sent: Tue, August 17, 2010 2:41:23 PM Subject: [Nagios-users] nagios plugins return code issue Hello all, I've googled around everywhere trying to find an answer here and came up unsuccessful, so if anyone has had experience in this situation, I'd appreciate help! Basically, the issue that I'm having is that I have a couple of temperature plugins that are reporting errors in Nagios and at the command line they're exiting in 0: check7204temp.pl - Return code of 255 is out of bounds and checkciscotemp.pl - Return code of 9 is out of bounds If I run a echo $? at the command line after running the command successfully, I get 0. Thanks for any help anyone can provide!! My perms are 755 and nagios user owns the plugins and I've run successfully with nagios user and got 0 output. I'm really stumped!! Here's the code for the plugins: *** check7204temp.pl: #!/usr/bin/perl -w # check_ciscotemp.pl # # Copyright (C) 2000 Leland E. Vandervort lel...@mmania.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # you should have received a copy of the GNU General Public License # along with this program (or with Nagios); if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA # Nagios pluging to check inlet and outlet temperatures on # Cisco router platforms which support environmental monitoring # (7200, 7500, GSR12000...) # default temperature thresholds are 30C for inlet, 40C outlet. # if input or output is less than thresholds, returns OK # if equal to (the temps don't change that rapidly) returns WARNING # if greater than threshold, returns CRITICAL # if undetermined, or cannot access environmental, returns UNKNOWN # (in accordance with the plugin coding guidelines) use Net::SNMP; use Getopt::Long; #use strict; Getopt::Long::config('auto_abbrev'); #my $critical_vals; #my $warning_vals; #my $inlet_warn; #my $outlet_warn; #my $status; my $response = ; my $timeout = 10; my $community = blah; my $port = 161; my $INTAKE_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.1; my $OUTLET_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.3; my $in_temp; my $out_temp; my $inlet_thresh = 30; my $outlet_thresh = 34; my $hostnm; #my $OID; #my $session; #my $state; #my $error; my %STATUSCODE = ( 'UNKNOWN' = '-1', 'OK' = '0', 'WARNING' = '1', 'CRITICAL' = '2'); my $state = UNKNOWN; $SIG{'ALRM'} = sub { print ERROR: No snmp response from $hostnm (sigALRM)\n; exit($STATUSCODE{UNKNOWN}); }; Getopt::Long::Configure('bundling'); $status = GetOptions (community=s, \$community, C=s, \$community, H=s, \$hostnm, hostname=s, \$hostnm, port=i, \$port, timeout=i, \$timeout, c=s, \$critical_vals, w=s, \$warning_vals, ithresh=i, \$inlet_thresh, othresh=i, \$outlet_thresh); if($status == 0) { show_help; } unless (defined($hostnm)) { $hostnm = shift || show_help; } if (defined($critical_vals)) { if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) { ($inlet_thresh,$outlet_thresh) = ($1, $2); } else { die Cannot Parse Critical Thresholds\n; } } if (defined($warning_vals)) { if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) { ($inlet_warn,$outlet_warn) = ($1, $2); } else { die Cannot Parse Warning Thresholds\n; } }else{ $inlet_warn=$inlet_thresh; $outlet_warn=$outlet_thresh; } alarm($timeout); $in_temp = SNMPGET($INTAKE_TEMP); $out_temp = SNMPGET($OUTLET_TEMP); if (($in_temp $inlet_thresh) ($out_temp $outlet_thresh)) { $state = OK; } elsif (($in_temp == $inlet_thresh
Re: [Nagios-users] nagios plugins return code issue
What is your command line? Are you calling the script directly or is it wrapped in a shell script? I took a quick look at the script, and it needs quite a bit of improvement. Not sure if it was a result of my copy and paste, but there is only so much I can blame on bad formatting. I would recommend looking for a different script that does the same thing. - Original Message From: Huber, Melissa mhu...@ascentdata.com To: Matthew J. Salerno vagabond_k...@yahoo.com; Nagios Users List nagios-users@lists.sourceforge.net Sent: Tue, August 17, 2010 3:20:42 PM Subject: RE: [Nagios-users] nagios plugins return code issue Umm... Not sure. I just tried uncommenting and got the same results though. I'm taking over managing the nagios server that we have from another collegue who left the company. I've actually migrated everything over to another server that is now running the latest nagios. The previous server was 3.0.6 I believe. I tried searching for an updated version of these plugins, but couldn't find any. I'm not that great with perl scripting either. :/ Missy -Original Message- From: Matthew J. Salerno [mailto:vagabond_k...@yahoo.com] Sent: Tuesday, August 17, 2010 2:58 PM To: Nagios Users List Cc: Huber, Melissa Subject: Re: [Nagios-users] nagios plugins return code issue For starters, why is use strict commented out? From: Huber, Melissa mhu...@ascentdata.com To: nagios-users@lists.sourceforge.net Sent: Tue, August 17, 2010 2:41:23 PM Subject: [Nagios-users] nagios plugins return code issue Hello all, I've googled around everywhere trying to find an answer here and came up unsuccessful, so if anyone has had experience in this situation, I'd appreciate help! Basically, the issue that I'm having is that I have a couple of temperature plugins that are reporting errors in Nagios and at the command line they're exiting in 0: check7204temp.pl - Return code of 255 is out of bounds and checkciscotemp.pl - Return code of 9 is out of bounds If I run a echo $? at the command line after running the command successfully, I get 0. Thanks for any help anyone can provide!! My perms are 755 and nagios user owns the plugins and I've run successfully with nagios user and got 0 output. I'm really stumped!! Here's the code for the plugins: *** check7204temp.pl: #!/usr/bin/perl -w # check_ciscotemp.pl # # Copyright (C) 2000 Leland E. Vandervort lel...@mmania.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # you should have received a copy of the GNU General Public License # along with this program (or with Nagios); if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA # Nagios pluging to check inlet and outlet temperatures on # Cisco router platforms which support environmental monitoring # (7200, 7500, GSR12000...) # default temperature thresholds are 30C for inlet, 40C outlet. # if input or output is less than thresholds, returns OK # if equal to (the temps don't change that rapidly) returns WARNING # if greater than threshold, returns CRITICAL # if undetermined, or cannot access environmental, returns UNKNOWN # (in accordance with the plugin coding guidelines) use Net::SNMP; use Getopt::Long; #use strict; Getopt::Long::config('auto_abbrev'); #my $critical_vals; #my $warning_vals; #my $inlet_warn; #my $outlet_warn; #my $status; my $response = ; my $timeout = 10; my $community = blah; my $port = 161; my $INTAKE_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.1; my $OUTLET_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.3; my $in_temp; my $out_temp; my $inlet_thresh = 30; my $outlet_thresh = 34; my $hostnm; #my $OID; #my $session; #my $state; #my $error; my %STATUSCODE = ( 'UNKNOWN' = '-1', 'OK' = '0', 'WARNING' = '1', 'CRITICAL' = '2'); my $state = UNKNOWN; $SIG{'ALRM'} = sub { print ERROR: No snmp response from $hostnm (sigALRM)\n; exit($STATUSCODE{UNKNOWN}); }; Getopt::Long::Configure('bundling'); $status = GetOptions (community=s, \$community, C=s, \$community, H=s, \$hostnm, hostname=s, \$hostnm, port=i, \$port, timeout=i, \$timeout, c=s, \$critical_vals, w=s, \$warning_vals, ithresh=i, \$inlet_thresh, othresh=i, \$outlet_thresh); if($status == 0) { show_help; } unless (defined($hostnm)) { $hostnm = shift || show_help
Re: [Nagios-users] nagios plugins return code issue
Ahh - I just realized something... I got the same response in Nagios when I uncommented use strict;, but not at the command line. I get the following at the command line with it commented out: If I run: ./checkciscotemp.pl -C 'community' -H ipaddress I get: OK Inlet Temp: 18 Outlet Temp: 22 Then if I do a: echo $? I get: 0 But with use strict; uncommented at the command line I get a whole range of requirements that I need to define for global symbols such as: Global symbol $hostname requires explicit package name at checkciscotemp.pl line 59. I can try defining them and see where that gets me first. I did try looking a little for another script, but I guess I'll have to try harder as this seems to be most likely too outdated for the new version of nagios. Missy -Original Message- From: Matthew J. Salerno [mailto:vagabond_k...@yahoo.com] Sent: Tuesday, August 17, 2010 3:45 PM To: Huber, Melissa; Nagios Users List Subject: Re: [Nagios-users] nagios plugins return code issue What is your command line? Are you calling the script directly or is it wrapped in a shell script? I took a quick look at the script, and it needs quite a bit of improvement. Not sure if it was a result of my copy and paste, but there is only so much I can blame on bad formatting. I would recommend looking for a different script that does the same thing. - Original Message From: Huber, Melissa mhu...@ascentdata.com To: Matthew J. Salerno vagabond_k...@yahoo.com; Nagios Users List nagios-users@lists.sourceforge.net Sent: Tue, August 17, 2010 3:20:42 PM Subject: RE: [Nagios-users] nagios plugins return code issue Umm... Not sure. I just tried uncommenting and got the same results though. I'm taking over managing the nagios server that we have from another collegue who left the company. I've actually migrated everything over to another server that is now running the latest nagios. The previous server was 3.0.6 I believe. I tried searching for an updated version of these plugins, but couldn't find any. I'm not that great with perl scripting either. :/ Missy -Original Message- From: Matthew J. Salerno [mailto:vagabond_k...@yahoo.com] Sent: Tuesday, August 17, 2010 2:58 PM To: Nagios Users List Cc: Huber, Melissa Subject: Re: [Nagios-users] nagios plugins return code issue For starters, why is use strict commented out? From: Huber, Melissa mhu...@ascentdata.com To: nagios-users@lists.sourceforge.net Sent: Tue, August 17, 2010 2:41:23 PM Subject: [Nagios-users] nagios plugins return code issue Hello all, I've googled around everywhere trying to find an answer here and came up unsuccessful, so if anyone has had experience in this situation, I'd appreciate help! Basically, the issue that I'm having is that I have a couple of temperature plugins that are reporting errors in Nagios and at the command line they're exiting in 0: check7204temp.pl - Return code of 255 is out of bounds and checkciscotemp.pl - Return code of 9 is out of bounds If I run a echo $? at the command line after running the command successfully, I get 0. Thanks for any help anyone can provide!! My perms are 755 and nagios user owns the plugins and I've run successfully with nagios user and got 0 output. I'm really stumped!! Here's the code for the plugins: *** check7204temp.pl: #!/usr/bin/perl -w # check_ciscotemp.pl # # Copyright (C) 2000 Leland E. Vandervort lel...@mmania.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # you should have received a copy of the GNU General Public License # along with this program (or with Nagios); if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA # Nagios pluging to check inlet and outlet temperatures on # Cisco router platforms which support environmental monitoring # (7200, 7500, GSR12000...) # default temperature thresholds are 30C for inlet, 40C outlet. # if input or output is less than thresholds, returns OK # if equal to (the temps don't change that rapidly) returns WARNING # if greater than threshold, returns CRITICAL # if undetermined, or cannot access environmental, returns UNKNOWN # (in accordance with the plugin coding guidelines) use Net::SNMP; use Getopt::Long; #use strict; Getopt::Long::config('auto_abbrev'); #my
Re: [Nagios-users] nagios plugins return code issue
Hi Melissa, if you disable the embedded perl interpreter in nagios.cfg, does the script start to work? Diego Sent from my BlackBerry® wireless device -Original Message- From: Matthew J. Salerno vagabond_k...@yahoo.com Date: Tue, 17 Aug 2010 12:45:29 To: Huber, Melissamhu...@ascentdata.com; Nagios Users Listnagios-users@lists.sourceforge.net Reply-To: Matthew J. Salerno vagabond_k...@yahoo.com, Nagios Users List nagios-users@lists.sourceforge.net Subject: Re: [Nagios-users] nagios plugins return code issue What is your command line? Are you calling the script directly or is it wrapped in a shell script? I took a quick look at the script, and it needs quite a bit of improvement. Not sure if it was a result of my copy and paste, but there is only so much I can blame on bad formatting. I would recommend looking for a different script that does the same thing. - Original Message From: Huber, Melissa mhu...@ascentdata.com To: Matthew J. Salerno vagabond_k...@yahoo.com; Nagios Users List nagios-users@lists.sourceforge.net Sent: Tue, August 17, 2010 3:20:42 PM Subject: RE: [Nagios-users] nagios plugins return code issue Umm... Not sure. I just tried uncommenting and got the same results though. I'm taking over managing the nagios server that we have from another collegue who left the company. I've actually migrated everything over to another server that is now running the latest nagios. The previous server was 3.0.6 I believe. I tried searching for an updated version of these plugins, but couldn't find any. I'm not that great with perl scripting either. :/ Missy -Original Message- From: Matthew J. Salerno [mailto:vagabond_k...@yahoo.com] Sent: Tuesday, August 17, 2010 2:58 PM To: Nagios Users List Cc: Huber, Melissa Subject: Re: [Nagios-users] nagios plugins return code issue For starters, why is use strict commented out? From: Huber, Melissa mhu...@ascentdata.com To: nagios-users@lists.sourceforge.net Sent: Tue, August 17, 2010 2:41:23 PM Subject: [Nagios-users] nagios plugins return code issue Hello all, I've googled around everywhere trying to find an answer here and came up unsuccessful, so if anyone has had experience in this situation, I'd appreciate help! Basically, the issue that I'm having is that I have a couple of temperature plugins that are reporting errors in Nagios and at the command line they're exiting in 0: check7204temp.pl - Return code of 255 is out of bounds and checkciscotemp.pl - Return code of 9 is out of bounds If I run a echo $? at the command line after running the command successfully, I get 0. Thanks for any help anyone can provide!! My perms are 755 and nagios user owns the plugins and I've run successfully with nagios user and got 0 output. I'm really stumped!! Here's the code for the plugins: *** check7204temp.pl: #!/usr/bin/perl -w # check_ciscotemp.pl # # Copyright (C) 2000 Leland E. Vandervort lel...@mmania.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # you should have received a copy of the GNU General Public License # along with this program (or with Nagios); if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA # Nagios pluging to check inlet and outlet temperatures on # Cisco router platforms which support environmental monitoring # (7200, 7500, GSR12000...) # default temperature thresholds are 30C for inlet, 40C outlet. # if input or output is less than thresholds, returns OK # if equal to (the temps don't change that rapidly) returns WARNING # if greater than threshold, returns CRITICAL # if undetermined, or cannot access environmental, returns UNKNOWN # (in accordance with the plugin coding guidelines) use Net::SNMP; use Getopt::Long; #use strict; Getopt::Long::config('auto_abbrev'); #my $critical_vals; #my $warning_vals; #my $inlet_warn; #my $outlet_warn; #my $status; my $response = ; my $timeout = 10; my $community = blah; my $port = 161; my $INTAKE_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.1; my $OUTLET_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.3; my $in_temp; my $out_temp; my $inlet_thresh = 30; my $outlet_thresh = 34; my $hostnm; #my $OID; #my $session; #my $state; #my $error; my %STATUSCODE = ( 'UNKNOWN' = '-1', 'OK' = '0', 'WARNING' = '1', 'CRITICAL
Re: [Nagios-users] nagios plugins return code issue
Are you sure you are trying to test plugin execution with the nagios user? Try that. On Tue, Aug 17, 2010 at 5:57 PM, diego.roc...@gmail.com wrote: Hi Melissa, if you disable the embedded perl interpreter in nagios.cfg, does the script start to work? Diego Sent from my BlackBerry® wireless device -Original Message- From: Matthew J. Salerno vagabond_k...@yahoo.com Date: Tue, 17 Aug 2010 12:45:29 To: Huber, Melissamhu...@ascentdata.com; Nagios Users List nagios-users@lists.sourceforge.net Reply-To: Matthew J. Salerno vagabond_k...@yahoo.com, Nagios Users List nagios-users@lists.sourceforge.net Subject: Re: [Nagios-users] nagios plugins return code issue What is your command line? Are you calling the script directly or is it wrapped in a shell script? I took a quick look at the script, and it needs quite a bit of improvement. Not sure if it was a result of my copy and paste, but there is only so much I can blame on bad formatting. I would recommend looking for a different script that does the same thing. - Original Message From: Huber, Melissa mhu...@ascentdata.com To: Matthew J. Salerno vagabond_k...@yahoo.com; Nagios Users List nagios-users@lists.sourceforge.net Sent: Tue, August 17, 2010 3:20:42 PM Subject: RE: [Nagios-users] nagios plugins return code issue Umm... Not sure. I just tried uncommenting and got the same results though. I'm taking over managing the nagios server that we have from another collegue who left the company. I've actually migrated everything over to another server that is now running the latest nagios. The previous server was 3.0.6 I believe. I tried searching for an updated version of these plugins, but couldn't find any. I'm not that great with perl scripting either. :/ Missy -Original Message- From: Matthew J. Salerno [mailto:vagabond_k...@yahoo.com] Sent: Tuesday, August 17, 2010 2:58 PM To: Nagios Users List Cc: Huber, Melissa Subject: Re: [Nagios-users] nagios plugins return code issue For starters, why is use strict commented out? From: Huber, Melissa mhu...@ascentdata.com To: nagios-users@lists.sourceforge.net Sent: Tue, August 17, 2010 2:41:23 PM Subject: [Nagios-users] nagios plugins return code issue Hello all, I've googled around everywhere trying to find an answer here and came up unsuccessful, so if anyone has had experience in this situation, I'd appreciate help! Basically, the issue that I'm having is that I have a couple of temperature plugins that are reporting errors in Nagios and at the command line they're exiting in 0: check7204temp.pl - Return code of 255 is out of bounds and checkciscotemp.pl - Return code of 9 is out of bounds If I run a echo $? at the command line after running the command successfully, I get 0. Thanks for any help anyone can provide!! My perms are 755 and nagios user owns the plugins and I've run successfully with nagios user and got 0 output. I'm really stumped!! Here's the code for the plugins: *** check7204temp.pl: #!/usr/bin/perl -w # check_ciscotemp.pl # # Copyright (C) 2000 Leland E. Vandervort lel...@mmania.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # you should have received a copy of the GNU General Public License # along with this program (or with Nagios); if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA # Nagios pluging to check inlet and outlet temperatures on # Cisco router platforms which support environmental monitoring # (7200, 7500, GSR12000...) # default temperature thresholds are 30C for inlet, 40C outlet. # if input or output is less than thresholds, returns OK # if equal to (the temps don't change that rapidly) returns WARNING # if greater than threshold, returns CRITICAL # if undetermined, or cannot access environmental, returns UNKNOWN # (in accordance with the plugin coding guidelines) use Net::SNMP; use Getopt::Long; #use strict; Getopt::Long::config('auto_abbrev'); #my $critical_vals; #my $warning_vals; #my $inlet_warn; #my $outlet_warn; #my $status; my $response = ; my $timeout = 10; my $community = blah; my $port = 161; my $INTAKE_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.1; my $OUTLET_TEMP
[Nagios-users] nagios plugins return code issue
Hello all, I've googled around everywhere trying to find an answer here and came up unsuccessful, so if anyone has had experience in this situation, I'd appreciate help! Basically, the issue that I'm having is that I have a couple of temperature plugins that are reporting errors in Nagios and at the command line they're exiting in 0: check7204temp.pl - Return code of 255 is out of bounds and checkciscotemp.pl - Return code of 9 is out of bounds If I run a echo $? at the command line after running the command successfully, I get 0. Thanks for any help anyone can provide!! My perms are 755 and nagios user owns the plugins and I've run successfully with nagios user and got 0 output. I'm really stumped!! Here's the code for the plugins: *** check7204temp.pl: #!/usr/bin/perl -w # check_ciscotemp.pl # # Copyright (C) 2000 Leland E. Vandervort lel...@mmania.com # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # you should have received a copy of the GNU General Public License # along with this program (or with Nagios); if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA # Nagios pluging to check inlet and outlet temperatures on # Cisco router platforms which support environmental monitoring # (7200, 7500, GSR12000...) # default temperature thresholds are 30C for inlet, 40C outlet. # if input or output is less than thresholds, returns OK # if equal to (the temps don't change that rapidly) returns WARNING # if greater than threshold, returns CRITICAL # if undetermined, or cannot access environmental, returns UNKNOWN # (in accordance with the plugin coding guidelines) use Net::SNMP; use Getopt::Long; #use strict; Getopt::Long::config('auto_abbrev'); #my $critical_vals; #my $warning_vals; #my $inlet_warn; #my $outlet_warn; #my $status; my $response = ; my $timeout = 10; my $community = blah; my $port = 161; my $INTAKE_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.1; my $OUTLET_TEMP = 1.3.6.1.4.1.9.9.13.1.3.1.3.3; my $in_temp; my $out_temp; my $inlet_thresh = 30; my $outlet_thresh = 34; my $hostnm; #my $OID; #my $session; #my $state; #my $error; my %STATUSCODE = ( 'UNKNOWN' = '-1', 'OK' = '0', 'WARNING' = '1', 'CRITICAL' = '2'); my $state = UNKNOWN; $SIG{'ALRM'} = sub { print ERROR: No snmp response from $hostnm (sigALRM)\n; exit($STATUSCODE{UNKNOWN}); }; Getopt::Long::Configure('bundling'); $status = GetOptions (community=s, \$community, C=s, \$community, H=s, \$hostnm, hostname=s, \$hostnm, port=i, \$port, timeout=i, \$timeout, c=s, \$critical_vals, w=s, \$warning_vals, ithresh=i, \$inlet_thresh, othresh=i, \$outlet_thresh); if($status == 0) { show_help; } unless (defined($hostnm)) { $hostnm = shift || show_help; } if (defined($critical_vals)) { if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) { ($inlet_thresh,$outlet_thresh) = ($1, $2); } else { die Cannot Parse Critical Thresholds\n; } } if (defined($warning_vals)) { if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) { ($inlet_warn,$outlet_warn) = ($1, $2); } else { die Cannot Parse Warning Thresholds\n; } }else{ $inlet_warn=$inlet_thresh; $outlet_warn=$outlet_thresh; } alarm($timeout); $in_temp = SNMPGET($INTAKE_TEMP); $out_temp = SNMPGET($OUTLET_TEMP); if (($in_temp $inlet_thresh) ($out_temp $outlet_thresh)) { $state = OK; } elsif (($in_temp == $inlet_thresh) || ($out_temp == $outlet_thresh)) { if(($in_temp $inlet_thresh) || ($out_temp $outlet_thresh)) { $state = CRITICAL; } else { $state = WARNING; } } elsif (($in_temp $inlet_thresh) || ($out_temp $outlet_thresh)) { $state = CRITICAL; } else { $state = WARNING; } print $state Inlet Temp: $in_temp Outlet Temp: $out_temp\n; exit($STATUSCODE{$state}); sub show_help { printf(\nPerl envmon temperature plugin for Nagios\n); printf(Usage:\n); printf( check_ciscotemp [options] hostname Options: -C snmp-community -p snmp-port -i input temperature threshold -o output temperature threshold ); printf(Copyright (C)2000 Leland E. Vandervort\n); printf(check_ciscotemp comes with absolutely NO WARRANTY either implied or explicit\n); printf(This program is licensed under the terms of the\n); printf(GNU General Public License\n(check source code for details)\n\n\n); exit($STATUSCODE{UNKNOWN}); } sub SNMPGET { $OID = shift;
Re: [Nagios-users] nagios plugins return code issue
This probably means that a subroutine from one of the used perl libraries is bailing out with an error, although why I don't know. Are you sure you're passing all of the arguments the same on the command line as Nagios is? One thing that I can tell you is that those plugins are out of date, since they use the old value of -1 for Unknown which should be 3 now, so who knows what other issues there are. (Sorry I can't tell you more - I don't really do Perl.) -- Tony Yarusso Technical Team ___ Nagios Enterprises, LLC Email: tyaru...@nagios.com Web:www.nagios.com -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Nagios-users mailing list Nagios-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nagios-users ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. ::: Messages without supporting info will risk being sent to /dev/null
Re: [Nagios-users] nagios plugins return code issue
Additionally, Nagios is really sensitive about how the Perl script is written. It should be written well-enough to run with use strict without any errors. (I see that it is commented out of both of your scripts.) Additionally, the embedded Perl interpreter causes the scripts to be run in what I consider to be a somewhat non-standard way in regards to how the parameters are sent to the script. (In our installation we have to surround host and service macros with quotes before sending them to any plugins written in Perl.) The copyright date on that file is 2000, so you will definitely want to find (or write) a more up to date version. On 08/16/2010 05:37 PM, Tony Yarusso wrote: This probably means that a subroutine from one of the used perl libraries is bailing out with an error, although why I don't know. Are you sure you're passing all of the arguments the same on the command line as Nagios is? One thing that I can tell you is that those plugins are out of date, since they use the old value of -1 for Unknown which should be 3 now, so who knows what other issues there are. (Sorry I can't tell you more - I don't really do Perl.) -- This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev ___ Nagios-users mailing list Nagios-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nagios-users ::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. ::: Messages without supporting info will risk being sent to /dev/null