1
0
mirror of https://github.com/ranl/monitor-utils.git synced 2025-04-18 20:33:41 +02:00
This commit is contained in:
dufourl 2017-08-07 13:27:54 +00:00 committed by GitHub
commit f296f7465f

View File

@ -30,8 +30,21 @@
## AUTOSUPPORTSTATUS|NFSOPS| ## AUTOSUPPORTSTATUS|NFSOPS|
## CIFSOPS|SHELFINFO|... ## CIFSOPS|SHELFINFO|...
## ##
##################################### ##
##################################### ##
## CLARIFICATION FOR TIMEOUTS
## There are multiples timeouts we depend on
##
## Perl plugins timeout (utils.pm)--- > $TIMEOUT --- > originally 15 sec --> recommandation to raise it to 180
##
## Net::SNMP timeout --- > Used in Net::SNMP->session --- > originally 5 sec --> recommandation to raise it to 60
## Beware that the max value 60 seconds. If set above you get the error message "Can't create snmp session"
##
## Do not forget that in nagios you need to increase service_check_timeout to a value above $TIMEOUT_PLUGINS
## Nagios service check timeout (nagios.cfg) --- > service_check_timeout=240 --- > originally 30 sec
##
####################################################################################################################################################
####################################################################################################################################################
use strict; use strict;
@ -47,13 +60,16 @@ use Getopt::Long;
use Time::Local; use Time::Local;
use IPC::Cmd qw(run_forked); use IPC::Cmd qw(run_forked);
Getopt::Long::Configure('bundling'); Getopt::Long::Configure('bundling');
my $TIMEOUT_PLUGINS=$TIMEOUT;
my $stat = 0; my $stat = 0;
my $msg; my $msg;
my $perf; my $perf;
my $script_name = basename($0); my $script_name = basename($0);
my $script_version = 1.3; my $script_version = 1.3.1;
my $counterFilePath="/tmp"; my $counterFilePath="/tmp";
my $counterFile; my $counterFile;
@ -339,9 +355,7 @@ sub FSyntaxError($) {
my $err = shift; my $err = shift;
print <<EOU; print <<EOU;
$err $err
This is $script_name in version $script_version. This is $script_name in version $script_version.
Syntax: Syntax:
-H <IP_or_Hostname> Ip/Dns Name of the Filer -H <IP_or_Hostname> Ip/Dns Name of the Filer
-C <community_name> SNMP Community Name for read -C <community_name> SNMP Community Name for read
@ -356,7 +370,6 @@ This is $script_name in version $script_version.
-e <vol1[,vol2[,...]]> Exclude volumes from snap check (SNAPSHOT/SNAPSHOTAGE) -e <vol1[,vol2[,...]]> Exclude volumes from snap check (SNAPSHOT/SNAPSHOTAGE)
-I Inform only, return OK every time (ignore -w and -c values) -I Inform only, return OK every time (ignore -w and -c values)
-h This help -h This help
Available check types: Available check types:
TEMP - Temperature TEMP - Temperature
FAN - Fan Fail FAN - Fan Fail
@ -382,20 +395,15 @@ This is $script_name in version $script_version.
UPTIME - Only show\'s uptime UPTIME - Only show\'s uptime
CACHEAGE - Cache Age (-w -c) CACHEAGE - Cache Age (-w -c)
FSSTATUS - Overall file system health FSSTATUS - Overall file system health
Examples: Examples:
$script_name -H netapp.mydomain -C public -T UPTIME $script_name -H netapp.mydomain -C public -T UPTIME
UPTIME: 2 days, 23:03:21.09 | uptime=255801s UPTIME: 2 days, 23:03:21.09 | uptime=255801s
$script_name -H netapp.mydomain -C public -T DISKUSED -v /vol/data/ -w 90 -c 95 -V 2c $script_name -H netapp.mydomain -C public -T DISKUSED -v /vol/data/ -w 90 -c 95 -V 2c
OK: DISKUSED 79% | /vol/data/=8104595240k OK: DISKUSED 79% | /vol/data/=8104595240k
$script_name -H netapp.mydomain -C public -T GLOBALSTATUS $script_name -H netapp.mydomain -C public -T GLOBALSTATUS
CRIT: GLOBALSTATUS nonCritical 4 Disk on adapter 1a, shelf 1, bay 9, failed. | globalstatus=4 CRIT: GLOBALSTATUS nonCritical 4 Disk on adapter 1a, shelf 1, bay 9, failed. | globalstatus=4
$script_name -H netapp.mydomain -C public -T DISKUSED -v wtf $script_name -H netapp.mydomain -C public -T DISKUSED -v wtf
WARN: Unknown volume path or aggregate name 'wtf'. Available values: aggr_p1a_sas2_mirror /vol/vol0/ /vol/esx/ /vol/xen_a/ WARN: Unknown volume path or aggregate name 'wtf'. Available values: aggr_p1a_sas2_mirror /vol/vol0/ /vol/esx/ /vol/xen_a/
EOU EOU
exit($ERRORS{'UNKNOWN'}); exit($ERRORS{'UNKNOWN'});
} }
@ -493,6 +501,8 @@ $opt{'crit'} = 500;
$opt{'warn'} = 500; $opt{'warn'} = 500;
$opt{'version'} = 2; $opt{'version'} = 2;
$opt{'timeout'} = 60; $opt{'timeout'} = 60;
$TIMEOUT_PLUGINS = 180 ;
my $result = GetOptions(\%opt, my $result = GetOptions(\%opt,
'filer|H=s', 'filer|H=s',
'community|C=s', 'community|C=s',
@ -507,6 +517,17 @@ my $result = GetOptions(\%opt,
"help|h", "help|h",
); );
if ( $opt{'timeout'} > 60)
{
#Set timeout for plugin to the parameter received via command line, but set snmp timeout to the max (60 seconds) if CLI timeout is above 60 seconds
$TIMEOUT_PLUGINS=$opt{'timeout'};
$opt{'timeout'}=60;
} else
{
$TIMEOUT_PLUGINS=$opt{'timeout'};
}
FSyntaxError("") if defined $opt{'help'}; FSyntaxError("") if defined $opt{'help'};
FSyntaxError("Missing -H") unless defined $opt{'filer'}; FSyntaxError("Missing -H") unless defined $opt{'filer'};
FSyntaxError("Missing -C") unless defined $opt{'community'}; FSyntaxError("Missing -C") unless defined $opt{'community'};
@ -536,9 +557,16 @@ if (!defined($counterFilePath)) {
# Just in case of problems, let's not hang Nagios
# with "Return code of 142 is out of bounds", instead we set the message "No response in time"
$SIG{'ALRM'} = sub {
print ("CRITICAL: No response in time\n");
exit $ERRORS{"CRITICAL"};
};
# Starting Alarm # Starting Alarm
alarm($TIMEOUT); alarm($TIMEOUT_PLUGINS);
# Establish SNMP Session # Establish SNMP Session
our $snmp_session = _create_session($opt{'filer'},$opt{'community'},$opt{'version'},$opt{'timeout'}); our $snmp_session = _create_session($opt{'filer'},$opt{'community'},$opt{'version'},$opt{'timeout'});
@ -1149,3 +1177,4 @@ $msg =~ s/\n//g;
$perf ? print "$msg | $perf\n" : print "$msg\n"; $perf ? print "$msg | $perf\n" : print "$msg\n";
exit($stat); exit($stat);