diff options
Diffstat (limited to 'plugins-scripts')
-rw-r--r-- | plugins-scripts/Makefile.am | 2 | ||||
-rwxr-xr-x | plugins-scripts/check_breeze.pl | 3 | ||||
-rw-r--r--[-rwxr-xr-x] | plugins-scripts/check_disk_smb.pl | 23 | ||||
-rwxr-xr-x | plugins-scripts/check_file_age.pl | 2 | ||||
-rwxr-xr-x | plugins-scripts/check_ifoperstatus.pl | 10 | ||||
-rwxr-xr-x | plugins-scripts/check_ifstatus.pl | 2 | ||||
-rwxr-xr-x | plugins-scripts/check_ircd.pl | 8 | ||||
-rwxr-xr-x | plugins-scripts/check_log.sh | 168 | ||||
-rwxr-xr-x | plugins-scripts/check_mailq.pl | 84 | ||||
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 244 | ||||
-rwxr-xr-x | plugins-scripts/check_rpc.pl | 2 | ||||
-rwxr-xr-x | plugins-scripts/check_sensors.sh | 34 | ||||
-rwxr-xr-x | plugins-scripts/check_uptime.pl | 328 | ||||
-rwxr-xr-x | plugins-scripts/check_wave.pl | 15 | ||||
-rw-r--r-- | plugins-scripts/t/check_file_age.t | 103 | ||||
-rw-r--r-- | plugins-scripts/t/check_log.t | 82 | ||||
-rw-r--r-- | plugins-scripts/t/check_uptime.t | 135 | ||||
-rw-r--r-- | plugins-scripts/utils.pm.in | 1 |
18 files changed, 924 insertions, 322 deletions
diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am index ea65aed..7879791 100644 --- a/plugins-scripts/Makefile.am +++ b/plugins-scripts/Makefile.am | |||
@@ -16,11 +16,13 @@ VPATH=$(top_srcdir) $(top_srcdir)/plugins-scripts $(top_srcdir)/plugins-scripts/ | |||
16 | libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \ | 16 | libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \ |
17 | check_log check_oracle check_rpc check_sensors check_wave \ | 17 | check_log check_oracle check_rpc check_sensors check_wave \ |
18 | check_ifstatus check_ifoperstatus check_mailq check_file_age \ | 18 | check_ifstatus check_ifoperstatus check_mailq check_file_age \ |
19 | check_uptime check_mssql \ | ||
19 | utils.sh utils.pm | 20 | utils.sh utils.pm |
20 | 21 | ||
21 | EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \ | 22 | EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \ |
22 | check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \ | 23 | check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \ |
23 | check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \ | 24 | check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \ |
25 | check_uptime.pl check_mssql.pl \ | ||
24 | utils.sh.in utils.pm.in t | 26 | utils.sh.in utils.pm.in t |
25 | 27 | ||
26 | EDIT = sed \ | 28 | EDIT = sed \ |
diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl index 05b9920..531625c 100755 --- a/plugins-scripts/check_breeze.pl +++ b/plugins-scripts/check_breeze.pl | |||
@@ -14,8 +14,9 @@ sub print_help (); | |||
14 | sub print_usage (); | 14 | sub print_usage (); |
15 | 15 | ||
16 | $ENV{'PATH'}='@TRUSTED_PATH@'; | 16 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
17 | $ENV{'BASH_ENV'}=''; | 17 | $ENV{'BASH_ENV'}=''; |
18 | $ENV{'ENV'}=''; | 18 | $ENV{'ENV'}=''; |
19 | $ENV{'CDPATH'}=''; | ||
19 | 20 | ||
20 | Getopt::Long::Configure('bundling'); | 21 | Getopt::Long::Configure('bundling'); |
21 | GetOptions | 22 | GetOptions |
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl index 28c49e8..f4d33a7 100755..100644 --- a/plugins-scripts/check_disk_smb.pl +++ b/plugins-scripts/check_disk_smb.pl | |||
@@ -22,13 +22,13 @@ require 5.004; | |||
22 | use POSIX qw(setsid); | 22 | use POSIX qw(setsid); |
23 | use strict; | 23 | use strict; |
24 | use Getopt::Long; | 24 | use Getopt::Long; |
25 | use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $verbose); | 25 | use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $opt_C $opt_t $verbose); |
26 | use vars qw($PROGNAME); | 26 | use vars qw($PROGNAME); |
27 | use FindBin; | 27 | use FindBin; |
28 | use lib "$FindBin::Bin"; | 28 | use lib "$FindBin::Bin"; |
29 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | 29 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); |
30 | 30 | ||
31 | # make us session leader which makes all childs exit if we do | 31 | # make us session leader which makes all children exit if we do |
32 | setsid; | 32 | setsid; |
33 | 33 | ||
34 | sub print_help (); | 34 | sub print_help (); |
@@ -43,6 +43,7 @@ $ENV{'ENV'}=''; | |||
43 | Getopt::Long::Configure('bundling'); | 43 | Getopt::Long::Configure('bundling'); |
44 | GetOptions | 44 | GetOptions |
45 | ("v" => \$verbose, "verbose" => \$verbose, | 45 | ("v" => \$verbose, "verbose" => \$verbose, |
46 | "t=i" => \$opt_t, "timeout=i" => \$opt_t, | ||
46 | "P=s" => \$opt_P, "port=s" => \$opt_P, | 47 | "P=s" => \$opt_P, "port=s" => \$opt_P, |
47 | "V" => \$opt_V, "version" => \$opt_V, | 48 | "V" => \$opt_V, "version" => \$opt_V, |
48 | "h" => \$opt_h, "help" => \$opt_h, | 49 | "h" => \$opt_h, "help" => \$opt_h, |
@@ -53,7 +54,8 @@ GetOptions | |||
53 | "s=s" => \$opt_s, "share=s" => \$opt_s, | 54 | "s=s" => \$opt_s, "share=s" => \$opt_s, |
54 | "W=s" => \$opt_W, "workgroup=s" => \$opt_W, | 55 | "W=s" => \$opt_W, "workgroup=s" => \$opt_W, |
55 | "H=s" => \$opt_H, "hostname=s" => \$opt_H, | 56 | "H=s" => \$opt_H, "hostname=s" => \$opt_H, |
56 | "a=s" => \$opt_a, "address=s" => \$opt_a); | 57 | "a=s" => \$opt_a, "address=s" => \$opt_a, |
58 | "C=s" => \$opt_C, "configfile=s" => \$opt_C); | ||
57 | 59 | ||
58 | if ($opt_V) { | 60 | if ($opt_V) { |
59 | print_revision($PROGNAME,'@NP_VERSION@'); #' | 61 | print_revision($PROGNAME,'@NP_VERSION@'); #' |
@@ -91,6 +93,12 @@ my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); | |||
91 | my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); | 93 | my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); |
92 | ($crit) || usage("Invalid critical threshold: $opt_c\n"); | 94 | ($crit) || usage("Invalid critical threshold: $opt_c\n"); |
93 | 95 | ||
96 | ($opt_C) || ($opt_C = shift @ARGV) || ($opt_C = ""); | ||
97 | my $configfile = $opt_C if ($opt_C); | ||
98 | usage("Unable to read config file $configfile\n") if ($configfile) && (! -r $configfile); | ||
99 | |||
100 | if ($opt_t && $opt_t =~ /^([0-9]+)$/) { $TIMEOUT = $1; } | ||
101 | |||
94 | # Execute the given command line and return anything it writes to STDOUT and/or | 102 | # Execute the given command line and return anything it writes to STDOUT and/or |
95 | # STDERR. (This might be useful for other plugins, too, so it should possibly | 103 | # STDERR. (This might be useful for other plugins, too, so it should possibly |
96 | # be moved to utils.pm.) | 104 | # be moved to utils.pm.) |
@@ -193,6 +201,7 @@ my @cmd = ( | |||
193 | defined($workgroup) ? ("-W", $workgroup) : (), | 201 | defined($workgroup) ? ("-W", $workgroup) : (), |
194 | defined($address) ? ("-I", $address) : (), | 202 | defined($address) ? ("-I", $address) : (), |
195 | defined($opt_P) ? ("-p", $opt_P) : (), | 203 | defined($opt_P) ? ("-p", $opt_P) : (), |
204 | defined($configfile) ? ("-s", $configfile) : (), | ||
196 | "-c", "du" | 205 | "-c", "du" |
197 | ); | 206 | ); |
198 | 207 | ||
@@ -292,7 +301,8 @@ exit $ERRORS{$state}; | |||
292 | 301 | ||
293 | sub print_usage () { | 302 | sub print_usage () { |
294 | print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> | 303 | print "Usage: $PROGNAME -H <host> -s <share> -u <user> -p <password> |
295 | -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>]\n"; | 304 | -w <warn> -c <crit> [-W <workgroup>] [-P <port>] [-a <IP>] [-t timeout] |
305 | [-C <configfile>]\n"; | ||
296 | } | 306 | } |
297 | 307 | ||
298 | sub print_help () { | 308 | sub print_help () { |
@@ -318,11 +328,14 @@ Perl Check SMB Disk plugin for monitoring | |||
318 | Password to log in to server. (Defaults to an empty password) | 328 | Password to log in to server. (Defaults to an empty password) |
319 | -w, --warning=INTEGER or INTEGER[kMG] | 329 | -w, --warning=INTEGER or INTEGER[kMG] |
320 | Percent of used space at which a warning will be generated (Default: 85%) | 330 | Percent of used space at which a warning will be generated (Default: 85%) |
321 | |||
322 | -c, --critical=INTEGER or INTEGER[kMG] | 331 | -c, --critical=INTEGER or INTEGER[kMG] |
323 | Percent of used space at which a critical will be generated (Defaults: 95%) | 332 | Percent of used space at which a critical will be generated (Defaults: 95%) |
333 | -t, --timeout=INTEGER | ||
334 | Seconds before connection times out (Default: 15) | ||
324 | -P, --port=INTEGER | 335 | -P, --port=INTEGER |
325 | Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) | 336 | Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) |
337 | -C, --configfile=STRING | ||
338 | Path to configfile which should be used by smbclient (Defaults to smb.conf of your smb installation) | ||
326 | 339 | ||
327 | If thresholds are followed by either a k, M, or G then check to see if that | 340 | If thresholds are followed by either a k, M, or G then check to see if that |
328 | much disk space is available (kilobytes, Megabytes, Gigabytes) | 341 | much disk space is available (kilobytes, Megabytes, Gigabytes) |
diff --git a/plugins-scripts/check_file_age.pl b/plugins-scripts/check_file_age.pl index 01b854a..26281dd 100755 --- a/plugins-scripts/check_file_age.pl +++ b/plugins-scripts/check_file_age.pl | |||
@@ -147,7 +147,7 @@ sub print_help () { | |||
147 | print "\n"; | 147 | print "\n"; |
148 | print " -i | --ignore-missing : return OK if the file does not exist\n"; | 148 | print " -i | --ignore-missing : return OK if the file does not exist\n"; |
149 | print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; | 149 | print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; |
150 | print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n\n"; | 150 | print " <size> File must be at least this many bytes long (default: file size is ignored (0 bytes))\n\n"; |
151 | print " Both <secs> and <size> can specify a range using the standard plugin syntax\n"; | 151 | print " Both <secs> and <size> can specify a range using the standard plugin syntax\n"; |
152 | print " If any of the warning and critical arguments are in range syntax (not just bare numbers)\n"; | 152 | print " If any of the warning and critical arguments are in range syntax (not just bare numbers)\n"; |
153 | print " then all warning and critical arguments will be interpreted as ranges.\n"; | 153 | print " then all warning and critical arguments will be interpreted as ranges.\n"; |
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl index 9ede163..e335cda 100755 --- a/plugins-scripts/check_ifoperstatus.pl +++ b/plugins-scripts/check_ifoperstatus.pl | |||
@@ -124,17 +124,17 @@ if (!defined($session)) { | |||
124 | ## map ifdescr to ifindex - should look at being able to cache this value | 124 | ## map ifdescr to ifindex - should look at being able to cache this value |
125 | 125 | ||
126 | if (defined $ifdescr || defined $iftype) { | 126 | if (defined $ifdescr || defined $iftype) { |
127 | # escape "/" in ifdescr - very common in the Cisco world | ||
128 | if (defined $iftype) { | 127 | if (defined $iftype) { |
129 | $status=fetch_ifindex($snmpIfType, $iftype); | 128 | $status=fetch_ifindex($snmpIfType, $iftype); |
130 | } else { | 129 | } else { |
130 | # escape "/" in ifdescr - very common in the Cisco world | ||
131 | $ifdescr =~ s/\//\\\//g; | 131 | $ifdescr =~ s/\//\\\//g; |
132 | $status=fetch_ifindex($snmpIfDescr, $ifdescr); # if using on device with large number of interfaces | 132 | $status=fetch_ifindex($snmpIfDescr, $ifdescr); # if using on device with large number of interfaces |
133 | # recommend use of SNMP v2 (get-bulk) | 133 | # recommend use of SNMP v2 (get-bulk) |
134 | } | 134 | } |
135 | if ($status==0) { | 135 | if ($status==0) { |
136 | $state = "UNKNOWN"; | 136 | $state = "UNKNOWN"; |
137 | printf "$state: could not retrive ifdescr/iftype snmpkey - $status-$snmpkey\n"; | 137 | printf "$state: could not retrieve ifdescr/iftype snmpkey - $status-$snmpkey\n"; |
138 | $session->close; | 138 | $session->close; |
139 | exit $ERRORS{$state}; | 139 | exit $ERRORS{$state}; |
140 | } | 140 | } |
@@ -187,7 +187,7 @@ if (defined $ifXTable) { | |||
187 | $name = $response->{$snmpIfDescr} ; | 187 | $name = $response->{$snmpIfDescr} ; |
188 | } | 188 | } |
189 | 189 | ||
190 | ## if AdminStatus is down - some one made a consious effort to change config | 190 | ## if AdminStatus is down - some one made a conscious effort to change config |
191 | ## | 191 | ## |
192 | if ( not ($response->{$snmpIfAdminStatus} == 1) ) { | 192 | if ( not ($response->{$snmpIfAdminStatus} == 1) ) { |
193 | $answer = "Interface $name (index $snmpkey) is administratively down."; | 193 | $answer = "Interface $name (index $snmpkey) is administratively down."; |
@@ -286,7 +286,7 @@ sub print_usage() { | |||
286 | printf "check_ifoperstatus -k <IF_KEY> -H <HOSTNAME> [-C <community>]\n"; | 286 | printf "check_ifoperstatus -k <IF_KEY> -H <HOSTNAME> [-C <community>]\n"; |
287 | printf "Copyright (C) 2000 Christoph Kron\n"; | 287 | printf "Copyright (C) 2000 Christoph Kron\n"; |
288 | printf "check_ifoperstatus.pl comes with ABSOLUTELY NO WARRANTY\n"; | 288 | printf "check_ifoperstatus.pl comes with ABSOLUTELY NO WARRANTY\n"; |
289 | printf "This programm is licensed under the terms of the "; | 289 | printf "This program is licensed under the terms of the "; |
290 | printf "GNU General Public License\n(check source code for details)\n"; | 290 | printf "GNU General Public License\n(check source code for details)\n"; |
291 | printf "\n\n"; | 291 | printf "\n\n"; |
292 | } | 292 | } |
@@ -424,7 +424,7 @@ sub process_arguments() { | |||
424 | if (defined $seclevel && defined $secname) { | 424 | if (defined $seclevel && defined $secname) { |
425 | $session_opts{'-username'} = $secname; | 425 | $session_opts{'-username'} = $secname; |
426 | 426 | ||
427 | # Must define a security level even though defualt is noAuthNoPriv | 427 | # Must define a security level even though default is noAuthNoPriv |
428 | unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) { | 428 | unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) { |
429 | usage("Must define a valid security level even though default is noAuthNoPriv"); | 429 | usage("Must define a valid security level even though default is noAuthNoPriv"); |
430 | } | 430 | } |
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl index 32984e5..38b87fc 100755 --- a/plugins-scripts/check_ifstatus.pl +++ b/plugins-scripts/check_ifstatus.pl | |||
@@ -354,7 +354,7 @@ sub process_arguments() { | |||
354 | if (defined $seclevel && defined $secname) { | 354 | if (defined $seclevel && defined $secname) { |
355 | $session_opts{'-username'} = $secname; | 355 | $session_opts{'-username'} = $secname; |
356 | 356 | ||
357 | # Must define a security level even though defualt is noAuthNoPriv | 357 | # Must define a security level even though default is noAuthNoPriv |
358 | unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) { | 358 | unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) { |
359 | usage("Must define a valid security level even though default is noAuthNoPriv"); | 359 | usage("Must define a valid security level even though default is noAuthNoPriv"); |
360 | } | 360 | } |
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl index 22d21c2..84f2022 100755 --- a/plugins-scripts/check_ircd.pl +++ b/plugins-scripts/check_ircd.pl | |||
@@ -60,7 +60,7 @@ sub print_usage (); | |||
60 | sub connection ($$$$); | 60 | sub connection ($$$$); |
61 | sub bindRemote ($$); | 61 | sub bindRemote ($$); |
62 | 62 | ||
63 | # -------------------------------------------------------------[ Enviroment ]-- | 63 | # -------------------------------------------------------------[ Environment ]-- |
64 | 64 | ||
65 | $ENV{'PATH'}='@TRUSTED_PATH@'; | 65 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
66 | $ENV{'BASH_ENV'}=''; | 66 | $ENV{'BASH_ENV'}=''; |
@@ -69,7 +69,9 @@ $ENV{'ENV'}=''; | |||
69 | # -----------------------------------------------------------------[ Global ]-- | 69 | # -----------------------------------------------------------------[ Global ]-- |
70 | 70 | ||
71 | $PROGNAME = "check_ircd"; | 71 | $PROGNAME = "check_ircd"; |
72 | my $NICK="ircd$$"; | 72 | # nickname shouldn't be longer than 9 chars, this might happen with large PIDs |
73 | # To prevent this, we cut of the part over 10000 | ||
74 | my $NICK="ircd" . $$ % 10000; | ||
73 | my $USER_INFO="monitor localhost localhost : "; | 75 | my $USER_INFO="monitor localhost localhost : "; |
74 | 76 | ||
75 | # -------------------------------------------------------------[ connection ]-- | 77 | # -------------------------------------------------------------[ connection ]-- |
@@ -206,7 +208,7 @@ MAIN: | |||
206 | 208 | ||
207 | # Just in case of problems, let's not hang the monitoring system | 209 | # Just in case of problems, let's not hang the monitoring system |
208 | $SIG{'ALRM'} = sub { | 210 | $SIG{'ALRM'} = sub { |
209 | print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n"; | 211 | print "Something is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n"; |
210 | exit $ERRORS{"UNKNOWN"}; | 212 | exit $ERRORS{"UNKNOWN"}; |
211 | }; | 213 | }; |
212 | 214 | ||
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh index d28c8d0..8ecdd31 100755 --- a/plugins-scripts/check_log.sh +++ b/plugins-scripts/check_log.sh | |||
@@ -1,8 +1,7 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # | 2 | # |
3 | # Log file pattern detector plugin for monitoring | 3 | # Log file pattern detector plugin for monitoring |
4 | # Written by Ethan Galstad (nagios@nagios.org) | 4 | # Written originally by Ethan Galstad (nagios@nagios.org) |
5 | # Last Modified: 07-31-1999 | ||
6 | # | 5 | # |
7 | # Usage: ./check_log <log_file> <old_log_file> <pattern> | 6 | # Usage: ./check_log <log_file> <old_log_file> <pattern> |
8 | # | 7 | # |
@@ -19,7 +18,7 @@ | |||
19 | # On the first run of the plugin, it will return an OK state with a message | 18 | # On the first run of the plugin, it will return an OK state with a message |
20 | # of "Log check data initialized". On successive runs, it will return an OK | 19 | # of "Log check data initialized". On successive runs, it will return an OK |
21 | # state if *no* pattern matches have been found in the *difference* between the | 20 | # state if *no* pattern matches have been found in the *difference* between the |
22 | # log file and the older copy of the log file. If the plugin detects any | 21 | # log file and the older copy of the log file. If the plugin detects any |
23 | # pattern matches in the log diff, it will return a CRITICAL state and print | 22 | # pattern matches in the log diff, it will return a CRITICAL state and print |
24 | # out a message is the following format: "(x) last_match", where "x" is the | 23 | # out a message is the following format: "(x) last_match", where "x" is the |
25 | # total number of pattern matches found in the file and "last_match" is the | 24 | # total number of pattern matches found in the file and "last_match" is the |
@@ -44,6 +43,10 @@ | |||
44 | # check the same <log_file> for pattern matches. This is necessary | 43 | # check the same <log_file> for pattern matches. This is necessary |
45 | # because of the way the script operates. | 44 | # because of the way the script operates. |
46 | # | 45 | # |
46 | # 4. This plugin does NOT have an understanding of logrotation or similar | ||
47 | # mechanisms. Therefore bad timing could lead to missing events | ||
48 | # | ||
49 | # | ||
47 | # Examples: | 50 | # Examples: |
48 | # | 51 | # |
49 | # Check for login failures in the syslog... | 52 | # Check for login failures in the syslog... |
@@ -60,20 +63,26 @@ | |||
60 | 63 | ||
61 | PATH="@TRUSTED_PATH@" | 64 | PATH="@TRUSTED_PATH@" |
62 | export PATH | 65 | export PATH |
63 | PROGNAME=`basename $0` | 66 | PROGNAME=$(basename "$0") |
64 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 67 | PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,') |
65 | REVISION="@NP_VERSION@" | 68 | REVISION="@NP_VERSION@" |
66 | 69 | ||
67 | . $PROGPATH/utils.sh | 70 | . "$PROGPATH"/utils.sh |
68 | 71 | ||
69 | print_usage() { | 72 | print_usage() { |
70 | echo "Usage: $PROGNAME -F logfile -O oldlog -q query" | 73 | echo "Usage: $PROGNAME -F logfile -O oldlog -q query" |
71 | echo "Usage: $PROGNAME --help" | 74 | echo "Usage: $PROGNAME --help" |
72 | echo "Usage: $PROGNAME --version" | 75 | echo "Usage: $PROGNAME --version" |
76 | echo "" | ||
77 | echo "Other parameters:" | ||
78 | echo " -a|--all : Print all matching lines" | ||
79 | echo " --exclude: Exclude a pattern (-p or -e also applies here when used)" | ||
80 | echo " -p|--perl-regex : Use perl style regular expressions in the query" | ||
81 | echo " -e|--extended-regex : Use extended style regular expressions in the query (not necessary for GNU grep)" | ||
73 | } | 82 | } |
74 | 83 | ||
75 | print_help() { | 84 | print_help() { |
76 | print_revision $PROGNAME $REVISION | 85 | print_revision "$PROGNAME" "$REVISION" |
77 | echo "" | 86 | echo "" |
78 | print_usage | 87 | print_usage |
79 | echo "" | 88 | echo "" |
@@ -87,81 +96,89 @@ print_help() { | |||
87 | 96 | ||
88 | if [ $# -lt 1 ]; then | 97 | if [ $# -lt 1 ]; then |
89 | print_usage | 98 | print_usage |
90 | exit $STATE_UNKNOWN | 99 | exit "$STATE_UNKNOWN" |
91 | fi | 100 | fi |
92 | 101 | ||
93 | # Grab the command line arguments | 102 | # Grab the command line arguments |
94 | |||
95 | #logfile=$1 | ||
96 | #oldlog=$2 | ||
97 | #query=$3 | ||
98 | exitstatus=$STATE_WARNING #default | 103 | exitstatus=$STATE_WARNING #default |
99 | while test -n "$1"; do | 104 | while test -n "$1"; do |
100 | case "$1" in | 105 | case "$1" in |
101 | --help) | 106 | -h | --help) |
102 | print_help | 107 | print_help |
103 | exit $STATE_OK | 108 | exit "$STATE_UNKNOWN" |
104 | ;; | 109 | ;; |
105 | -h) | 110 | -V | --version) |
106 | print_help | 111 | print_revision "$PROGNAME" "$REVISION" |
107 | exit $STATE_OK | 112 | exit "$STATE_UNKNOWN" |
108 | ;; | ||
109 | --version) | ||
110 | print_revision $PROGNAME $REVISION | ||
111 | exit $STATE_OK | ||
112 | ;; | ||
113 | -V) | ||
114 | print_revision $PROGNAME $REVISION | ||
115 | exit $STATE_OK | ||
116 | ;; | ||
117 | --filename) | ||
118 | logfile=$2 | ||
119 | shift | ||
120 | ;; | 113 | ;; |
121 | -F) | 114 | -F | --filename) |
122 | logfile=$2 | 115 | logfile=$2 |
123 | shift | 116 | shift 2 |
124 | ;; | 117 | ;; |
125 | --oldlog) | 118 | -O | --oldlog) |
126 | oldlog=$2 | 119 | oldlog=$2 |
127 | shift | 120 | shift 2 |
128 | ;; | 121 | ;; |
129 | -O) | 122 | -q | --query) |
130 | oldlog=$2 | ||
131 | shift | ||
132 | ;; | ||
133 | --query) | ||
134 | query=$2 | 123 | query=$2 |
135 | shift | 124 | shift 2 |
136 | ;; | 125 | ;; |
137 | -q) | 126 | --exclude) |
138 | query=$2 | 127 | exclude=$2 |
139 | shift | 128 | shift 2 |
140 | ;; | 129 | ;; |
141 | -x) | 130 | -x | --exitstatus) |
142 | exitstatus=$2 | 131 | exitstatus=$2 |
132 | shift 2 | ||
133 | ;; | ||
134 | -e | --extended-regex) | ||
135 | ERE=1 | ||
143 | shift | 136 | shift |
144 | ;; | 137 | ;; |
145 | --exitstatus) | 138 | -p | --perl-regex) |
146 | exitstatus=$2 | 139 | PRE=1 |
140 | shift | ||
141 | ;; | ||
142 | -a | --all) | ||
143 | ALL=1 | ||
147 | shift | 144 | shift |
148 | ;; | 145 | ;; |
149 | *) | 146 | *) |
150 | echo "Unknown argument: $1" | 147 | echo "Unknown argument: $1" |
151 | print_usage | 148 | print_usage |
152 | exit $STATE_UNKNOWN | 149 | exit "$STATE_UNKNOWN" |
153 | ;; | 150 | ;; |
154 | esac | 151 | esac |
155 | shift | ||
156 | done | 152 | done |
157 | 153 | ||
154 | # Parameter sanity check | ||
155 | if [ $ERE ] && [ $PRE ] ; then | ||
156 | echo "Can not use extended and perl regex at the same time" | ||
157 | exit "$STATE_UNKNOWN" | ||
158 | fi | ||
159 | |||
160 | GREP="grep" | ||
161 | |||
162 | if [ $ERE ]; then | ||
163 | GREP="grep -E" | ||
164 | fi | ||
165 | |||
166 | if [ $PRE ]; then | ||
167 | GREP="grep -P" | ||
168 | fi | ||
169 | |||
158 | # If the source log file doesn't exist, exit | 170 | # If the source log file doesn't exist, exit |
159 | 171 | ||
160 | if [ ! -e $logfile ]; then | 172 | if [ ! -e "$logfile" ]; then |
161 | echo "Log check error: Log file $logfile does not exist!" | 173 | echo "Log check error: Log file $logfile does not exist!" |
162 | exit $STATE_UNKNOWN | 174 | exit "$STATE_UNKNOWN" |
163 | elif [ ! -r $logfile ] ; then | 175 | elif [ ! -r "$logfile" ] ; then |
164 | echo "Log check error: Log file $logfile is not readable!" | 176 | echo "Log check error: Log file $logfile is not readable!" |
177 | exit "$STATE_UNKNOWN" | ||
178 | fi | ||
179 | # If no oldlog was given this can not work properly, abort then | ||
180 | if [ -z "$oldlog" ]; then | ||
181 | echo "Oldlog parameter is needed" | ||
165 | exit $STATE_UNKNOWN | 182 | exit $STATE_UNKNOWN |
166 | fi | 183 | fi |
167 | 184 | ||
@@ -169,10 +186,10 @@ fi | |||
169 | # we're running this test, so copy the original log file over to | 186 | # we're running this test, so copy the original log file over to |
170 | # the old diff file and exit | 187 | # the old diff file and exit |
171 | 188 | ||
172 | if [ ! -e $oldlog ]; then | 189 | if [ ! -e "$oldlog" ]; then |
173 | cat $logfile > $oldlog | 190 | cat "$logfile" > "$oldlog" |
174 | echo "Log check data initialized..." | 191 | echo "Log check data initialized..." |
175 | exit $STATE_OK | 192 | exit "$STATE_OK" |
176 | fi | 193 | fi |
177 | 194 | ||
178 | # The old log file exists, so compare it to the original log now | 195 | # The old log file exists, so compare it to the original log now |
@@ -180,31 +197,48 @@ fi | |||
180 | # The temporary file that the script should use while | 197 | # The temporary file that the script should use while |
181 | # processing the log file. | 198 | # processing the log file. |
182 | if [ -x /bin/mktemp ]; then | 199 | if [ -x /bin/mktemp ]; then |
183 | tempdiff=`/bin/mktemp /tmp/check_log.XXXXXXXXXX` | 200 | |
201 | tempdiff=$(/bin/mktemp /tmp/check_log.XXXXXXXXXX) | ||
184 | else | 202 | else |
185 | tempdiff=`/bin/date '+%H%M%S'` | 203 | tempdiff=$(/bin/date '+%H%M%S') |
186 | tempdiff="/tmp/check_log.${tempdiff}" | 204 | tempdiff="/tmp/check_log.${tempdiff}" |
187 | touch $tempdiff | 205 | touch "$tempdiff" |
188 | chmod 600 $tempdiff | 206 | chmod 600 "$tempdiff" |
189 | fi | 207 | fi |
190 | 208 | ||
191 | diff $logfile $oldlog | grep -v "^>" > $tempdiff | 209 | diff "$logfile" "$oldlog" | grep -v "^>" > "$tempdiff" |
210 | |||
192 | 211 | ||
193 | # Count the number of matching log entries we have | 212 | if [ $ALL ]; then |
194 | count=`grep -c "$query" $tempdiff` | 213 | # Get all matching entries in the diff file |
214 | if [ -n "$exclude" ]; then | ||
215 | entry=$($GREP "$query" "$tempdiff" | $GREP -v "$exclude") | ||
216 | count=$($GREP "$query" "$tempdiff" | $GREP -vc "$exclude") | ||
217 | else | ||
218 | entry=$($GREP "$query" "$tempdiff") | ||
219 | count=$($GREP -c "$query" "$tempdiff") | ||
220 | fi | ||
195 | 221 | ||
196 | # Get the last matching entry in the diff file | 222 | else |
197 | lastentry=`grep "$query" $tempdiff | tail -1` | 223 | # Get the last matching entry in the diff file |
224 | if [ -n "$exclude" ]; then | ||
225 | entry=$($GREP "$query" "$tempdiff" | $GREP -v "$exclude" | tail -1) | ||
226 | count=$($GREP "$query" "$tempdiff" | $GREP -vc "$exclude") | ||
227 | else | ||
228 | entry=$($GREP "$query" "$tempdiff" | tail -1) | ||
229 | count=$($GREP -c "$query" "$tempdiff") | ||
230 | fi | ||
231 | fi | ||
198 | 232 | ||
199 | rm -f $tempdiff | 233 | rm -f "$tempdiff" |
200 | cat $logfile > $oldlog | 234 | cat "$logfile" > "$oldlog" |
201 | 235 | ||
202 | if [ "$count" = "0" ]; then # no matches, exit with no error | 236 | if [ "$count" = "0" ]; then # no matches, exit with no error |
203 | echo "Log check ok - 0 pattern matches found" | 237 | echo "Log check ok - 0 pattern matches found" |
204 | exitstatus=$STATE_OK | 238 | exitstatus=$STATE_OK |
205 | else # Print total matche count and the last entry we found | 239 | else # Print total match count and the last entry we found |
206 | echo "($count) $lastentry" | 240 | echo "($count) $entry" |
207 | exitstatus=$STATE_CRITICAL | 241 | exitstatus=$STATE_CRITICAL |
208 | fi | 242 | fi |
209 | 243 | ||
210 | exit $exitstatus | 244 | exit "$exitstatus" |
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl index 32f498d..49156af 100755 --- a/plugins-scripts/check_mailq.pl +++ b/plugins-scripts/check_mailq.pl | |||
@@ -4,7 +4,7 @@ | |||
4 | # transmittal. | 4 | # transmittal. |
5 | # | 5 | # |
6 | # Initial version support sendmail's mailq command | 6 | # Initial version support sendmail's mailq command |
7 | # Support for mutiple sendmail queues (Carlos Canau) | 7 | # Support for multiple sendmail queues (Carlos Canau) |
8 | # Support for qmail (Benjamin Schmid) | 8 | # Support for qmail (Benjamin Schmid) |
9 | 9 | ||
10 | # License Information: | 10 | # License Information: |
@@ -28,9 +28,9 @@ | |||
28 | use POSIX; | 28 | use POSIX; |
29 | use strict; | 29 | use strict; |
30 | use Getopt::Long; | 30 | use Getopt::Long; |
31 | use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s | 31 | use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s $opt_d |
32 | $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines | 32 | $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq $mailq_args |
33 | %srcdomains %dstdomains); | 33 | @lines %srcdomains %dstdomains); |
34 | use FindBin; | 34 | use FindBin; |
35 | use lib "$FindBin::Bin"; | 35 | use lib "$FindBin::Bin"; |
36 | use utils qw(%ERRORS &print_revision &support &usage ); | 36 | use utils qw(%ERRORS &print_revision &support &usage ); |
@@ -48,6 +48,8 @@ $PROGNAME = "check_mailq"; | |||
48 | $mailq = 'sendmail'; # default | 48 | $mailq = 'sendmail'; # default |
49 | $msg_q = 0 ; | 49 | $msg_q = 0 ; |
50 | $msg_p = 0 ; | 50 | $msg_p = 0 ; |
51 | # If appended, must start with a space | ||
52 | $mailq_args = '' ; | ||
51 | $state = $ERRORS{'UNKNOWN'}; | 53 | $state = $ERRORS{'UNKNOWN'}; |
52 | 54 | ||
53 | Getopt::Long::Configure('bundling'); | 55 | Getopt::Long::Configure('bundling'); |
@@ -68,6 +70,10 @@ if ($opt_s) { | |||
68 | $sudo = ""; | 70 | $sudo = ""; |
69 | } | 71 | } |
70 | 72 | ||
73 | if ($opt_d) { | ||
74 | $mailq_args = $mailq_args . ' -C ' . $opt_d; | ||
75 | } | ||
76 | |||
71 | $SIG{'ALRM'} = sub { | 77 | $SIG{'ALRM'} = sub { |
72 | print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n"); | 78 | print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n"); |
73 | exit $ERRORS{"WARNING"}; | 79 | exit $ERRORS{"WARNING"}; |
@@ -143,7 +149,26 @@ if ($mailq eq "sendmail") { | |||
143 | ##/var/spool/mqueue/qF/df is empty | 149 | ##/var/spool/mqueue/qF/df is empty |
144 | ## Total Requests: 1 | 150 | ## Total Requests: 1 |
145 | 151 | ||
146 | 152 | # separate submission/transport queues, empty | |
153 | ## MSP Queue status... | ||
154 | ## /var/spool/mqueue-client is empty | ||
155 | ## Total requests: 0 | ||
156 | ## MTA Queue status... | ||
157 | ## /var/spool/mqueue is empty | ||
158 | ## Total requests: 0 | ||
159 | # separate submission/transport queues: 1 | ||
160 | ## MSP Queue status... | ||
161 | ## /var/spool/mqueue-client (1 request) | ||
162 | ## -----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient----------- | ||
163 | ## oAJEfhdW014123 5 Fri Nov 19 14:41 jwm | ||
164 | ## (Deferred: Connection refused by [127.0.0.1]) | ||
165 | ## root | ||
166 | ## Total requests: 1 | ||
167 | ## MTA Queue status... | ||
168 | ## /var/spool/mqueue is empty | ||
169 | ## Total requests: 0 | ||
170 | |||
171 | my $this_msg_q = 0; | ||
147 | while (<MAILQ>) { | 172 | while (<MAILQ>) { |
148 | 173 | ||
149 | # match email addr on queue listing | 174 | # match email addr on queue listing |
@@ -183,13 +208,18 @@ if ($mailq eq "sendmail") { | |||
183 | # | 208 | # |
184 | # single queue: first line | 209 | # single queue: first line |
185 | # multi queue: one for each queue. overwrite on multi queue below | 210 | # multi queue: one for each queue. overwrite on multi queue below |
186 | $msg_q = $1 ; | 211 | $this_msg_q = $1 ; |
212 | $msg_q += $1 ; | ||
187 | } | 213 | } |
188 | } elsif (/^\s+Total\sRequests:\s(\d+)$/i) { | 214 | } elsif (/^\s+Total\sRequests:\s(\d+)$/i) { |
189 | print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ; | 215 | if ($this_msg_q) { |
190 | # | 216 | $this_msg_q = 0 ; |
191 | # multi queue: last line | 217 | } else { |
192 | $msg_q = $1 ; | 218 | print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ; |
219 | # | ||
220 | # multi queue: last line | ||
221 | $msg_q += $1 ; | ||
222 | } | ||
193 | } | 223 | } |
194 | 224 | ||
195 | } | 225 | } |
@@ -309,8 +339,8 @@ elsif ( $mailq eq "postfix" ) { | |||
309 | 339 | ||
310 | ## open mailq | 340 | ## open mailq |
311 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | 341 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { |
312 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { | 342 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ$mailq_args | " ) ) { |
313 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | 343 | print "ERROR: could not open $utils::PATH_TO_MAILQ$mailq_args \n"; |
314 | exit $ERRORS{'UNKNOWN'}; | 344 | exit $ERRORS{'UNKNOWN'}; |
315 | } | 345 | } |
316 | }elsif( defined $utils::PATH_TO_MAILQ){ | 346 | }elsif( defined $utils::PATH_TO_MAILQ){ |
@@ -330,7 +360,7 @@ elsif ( $mailq eq "postfix" ) { | |||
330 | close MAILQ; | 360 | close MAILQ; |
331 | 361 | ||
332 | if ( $? ) { | 362 | if ( $? ) { |
333 | print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/; | 363 | print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ$mailq_args",$/; |
334 | exit $ERRORS{CRITICAL}; | 364 | exit $ERRORS{CRITICAL}; |
335 | } | 365 | } |
336 | 366 | ||
@@ -343,7 +373,7 @@ elsif ( $mailq eq "postfix" ) { | |||
343 | }elsif ($lines[0]=~/Mail queue is empty/) { | 373 | }elsif ($lines[0]=~/Mail queue is empty/) { |
344 | $msg_q = 0; | 374 | $msg_q = 0; |
345 | }else{ | 375 | }else{ |
346 | print "Couldn't match $utils::PATH_TO_MAILQ output\n"; | 376 | print "Couldn't match $utils::PATH_TO_MAILQ$mailq_args output\n"; |
347 | exit $ERRORS{'UNKNOWN'}; | 377 | exit $ERRORS{'UNKNOWN'}; |
348 | } | 378 | } |
349 | 379 | ||
@@ -531,9 +561,9 @@ elsif ( $mailq eq "nullmailer" ) { | |||
531 | } | 561 | } |
532 | 562 | ||
533 | while (<MAILQ>) { | 563 | while (<MAILQ>) { |
534 | #2006-06-22 16:00:00 282 bytes | 564 | #2022-08-25 01:30:40 502 bytes from <user@example.com> |
535 | 565 | ||
536 | if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-2][0-9]\:[0-2][0-9]\s{2}[0-9]+\sbytes$/) { | 566 | if (/^\d{4}-\d{2}-\d{2}\s+\d{2}\:\d{2}\:\d{2}\s+\d+\sbytes/) { |
537 | $msg_q++ ; | 567 | $msg_q++ ; |
538 | } | 568 | } |
539 | } | 569 | } |
@@ -561,14 +591,17 @@ exit $state; | |||
561 | 591 | ||
562 | sub process_arguments(){ | 592 | sub process_arguments(){ |
563 | GetOptions | 593 | GetOptions |
564 | ("V" => \$opt_V, "version" => \$opt_V, | 594 | ("V" => \$opt_V, "version" => \$opt_V, |
565 | "v" => \$opt_v, "verbose" => \$opt_v, | 595 | "v" => \$opt_v, "verbose" => \$opt_v, |
566 | "h" => \$opt_h, "help" => \$opt_h, | 596 | "h" => \$opt_h, "help" => \$opt_h, |
567 | "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail) | 597 | "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail) |
568 | "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number | 598 | "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number |
569 | "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number | 599 | "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number |
600 | "W=i" => \$opt_W, "warning-domain=i" => \$opt_W, # Warning if above this number | ||
601 | "C=i" => \$opt_C, "critical-domain=i" => \$opt_C, # Critical if above this number | ||
570 | "t=i" => \$opt_t, "timeout=i" => \$opt_t, | 602 | "t=i" => \$opt_t, "timeout=i" => \$opt_t, |
571 | "s" => \$opt_s, "sudo" => \$opt_s | 603 | "s" => \$opt_s, "sudo" => \$opt_s, |
604 | "d:s" => \$opt_d, "configdir:s" => \$opt_d, | ||
572 | ); | 605 | ); |
573 | 606 | ||
574 | if ($opt_V) { | 607 | if ($opt_V) { |
@@ -649,7 +682,7 @@ sub process_arguments(){ | |||
649 | } | 682 | } |
650 | 683 | ||
651 | sub print_usage () { | 684 | sub print_usage () { |
652 | print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-v]\n"; | 685 | print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-d <CONFIGDIR>] [-v]\n"; |
653 | } | 686 | } |
654 | 687 | ||
655 | sub print_help () { | 688 | sub print_help () { |
@@ -662,14 +695,15 @@ sub print_help () { | |||
662 | print " Feedback/patches to support non-sendmail mailqueue welcome\n\n"; | 695 | print " Feedback/patches to support non-sendmail mailqueue welcome\n\n"; |
663 | print "-w (--warning) = Min. number of messages in queue to generate warning\n"; | 696 | print "-w (--warning) = Min. number of messages in queue to generate warning\n"; |
664 | print "-c (--critical) = Min. number of messages in queue to generate critical alert ( w < c )\n"; | 697 | print "-c (--critical) = Min. number of messages in queue to generate critical alert ( w < c )\n"; |
665 | print "-W (--Warning) = Min. number of messages for same domain in queue to generate warning\n"; | 698 | print "-W (--warning-domain) = Min. number of messages for same domain in queue to generate warning\n"; |
666 | print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; | 699 | print "-C (--critical-domain) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; |
667 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; | 700 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; |
668 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; | 701 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; |
669 | print "-s (--sudo) = Use sudo to call the mailq command\n"; | 702 | print "-s (--sudo) = Use sudo to call the mailq command\n"; |
703 | print "-d (--configdir) = Config file or directory\n"; | ||
670 | print "-h (--help)\n"; | 704 | print "-h (--help)\n"; |
671 | print "-V (--version)\n"; | 705 | print "-V (--version)\n"; |
672 | print "-v (--verbose) = debugging output\n"; | 706 | print "-v (--verbose) = debugging output\n"; |
673 | print "\n\n"; | 707 | print "\n\n"; |
674 | print "Note: -w and -c are required arguments. -W and -C are optional.\n"; | 708 | print "Note: -w and -c are required arguments. -W and -C are optional.\n"; |
675 | print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n"; | 709 | print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n"; |
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index 96078ac..5998138 100755 --- a/plugins-scripts/check_oracle.sh +++ b/plugins-scripts/check_oracle.sh | |||
@@ -8,11 +8,11 @@ | |||
8 | 8 | ||
9 | PATH="@TRUSTED_PATH@" | 9 | PATH="@TRUSTED_PATH@" |
10 | export PATH | 10 | export PATH |
11 | PROGNAME=`basename $0` | 11 | PROGNAME=$(basename "$0") |
12 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 12 | PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,') |
13 | REVISION="@NP_VERSION@" | 13 | REVISION="@NP_VERSION@" |
14 | 14 | ||
15 | . $PROGPATH/utils.sh | 15 | . "$PROGPATH"/utils.sh |
16 | 16 | ||
17 | 17 | ||
18 | print_usage() { | 18 | print_usage() { |
@@ -29,7 +29,7 @@ print_usage() { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | print_help() { | 31 | print_help() { |
32 | print_revision $PROGNAME $REVISION | 32 | print_revision "$PROGNAME" "$REVISION" |
33 | echo "" | 33 | echo "" |
34 | print_usage | 34 | print_usage |
35 | echo "" | 35 | echo "" |
@@ -86,48 +86,48 @@ esac | |||
86 | # Information options | 86 | # Information options |
87 | case "$cmd" in | 87 | case "$cmd" in |
88 | --help) | 88 | --help) |
89 | print_help | 89 | print_help |
90 | exit $STATE_OK | 90 | exit "$STATE_UNKNOWN" |
91 | ;; | 91 | ;; |
92 | -h) | 92 | -h) |
93 | print_help | 93 | print_help |
94 | exit $STATE_OK | 94 | exit "$STATE_UNKNOWN" |
95 | ;; | 95 | ;; |
96 | --version) | 96 | --version) |
97 | print_revision $PROGNAME $REVISION | 97 | print_revision "$PROGNAME" "$REVISION" |
98 | exit $STATE_OK | 98 | exit "$STATE_UNKNOWN" |
99 | ;; | 99 | ;; |
100 | -V) | 100 | -V) |
101 | print_revision $PROGNAME $REVISION | 101 | print_revision "$PROGNAME" "$REVISION" |
102 | exit $STATE_OK | 102 | exit "$STATE_UNKNOWN" |
103 | ;; | 103 | ;; |
104 | esac | 104 | esac |
105 | 105 | ||
106 | # Hunt down a reasonable ORACLE_HOME | 106 | # Hunt down a reasonable ORACLE_HOME |
107 | if [ -z "$ORACLE_HOME" ] ; then | 107 | if [ -z "$ORACLE_HOME" ] ; then |
108 | # Adjust to taste | 108 | # Adjust to taste |
109 | for oratab in /var/opt/oracle/oratab /etc/oratab | 109 | for oratab in /var/opt/oracle/oratab /etc/oratab |
110 | do | 110 | do |
111 | [ ! -f $oratab ] && continue | 111 | [ ! -f $oratab ] && continue |
112 | ORACLE_HOME=`IFS=: | 112 | ORACLE_HOME=`IFS=: |
113 | while read SID ORACLE_HOME junk; | 113 | while read -r SID ORACLE_HOME junk; |
114 | do | 114 | do |
115 | if [ "$SID" = "$2" -o "$SID" = "*" ] ; then | 115 | if [ "$SID" = "$2" ] || [ "$SID" = "*" ] ; then |
116 | echo $ORACLE_HOME; | 116 | echo "$ORACLE_HOME"; |
117 | exit; | 117 | exit; |
118 | fi; | 118 | fi; |
119 | done < $oratab` | 119 | done < $oratab` |
120 | [ -n "$ORACLE_HOME" ] && break | 120 | [ -n "$ORACLE_HOME" ] && break |
121 | done | 121 | done |
122 | fi | 122 | fi |
123 | # Last resort | 123 | # Last resort |
124 | [ -z "$ORACLE_HOME" -a -d $PROGPATH/oracle ] && ORACLE_HOME=$PROGPATH/oracle | 124 | [ -z "$ORACLE_HOME" ] && [ -d "$PROGPATH"/oracle ] && ORACLE_HOME=$PROGPATH/oracle |
125 | 125 | ||
126 | if [ "$cmd" != "--db" ]; then | 126 | if [ "$cmd" != "--db" ]; then |
127 | if [ -z "$ORACLE_HOME" -o ! -d "$ORACLE_HOME" ] ; then | 127 | if [ -z "$ORACLE_HOME" ] || [ ! -d "$ORACLE_HOME" ] ; then |
128 | echo "Cannot determine ORACLE_HOME for sid $2" | 128 | echo "Cannot determine ORACLE_HOME for sid $2" |
129 | exit $STATE_UNKNOWN | 129 | exit "$STATE_UNKNOWN" |
130 | fi | 130 | fi |
131 | fi | 131 | fi |
132 | PATH=$PATH:$ORACLE_HOME/bin | 132 | PATH=$PATH:$ORACLE_HOME/bin |
133 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib | 133 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib |
@@ -135,81 +135,81 @@ export ORACLE_HOME PATH LD_LIBRARY_PATH | |||
135 | 135 | ||
136 | case "$cmd" in | 136 | case "$cmd" in |
137 | --tns) | 137 | --tns) |
138 | tnschk=` tnsping $2` | 138 | tnschk=$(tnsping "$2") |
139 | tnschk2=` echo $tnschk | grep -c OK` | 139 | tnschk2=$(echo "$tnschk" | grep -c OK) |
140 | if [ ${tnschk2} -eq 1 ] ; then | 140 | if [ "${tnschk2}" -eq 1 ] ; then |
141 | tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*} | 141 | tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*} |
142 | echo "OK - reply time ${tnschk3} from $2" | 142 | echo "OK - reply time ${tnschk3} from $2" |
143 | exit $STATE_OK | 143 | exit "$STATE_OK" |
144 | else | 144 | else |
145 | echo "No TNS Listener on $2" | 145 | echo "No TNS Listener on $2" |
146 | exit $STATE_CRITICAL | 146 | exit "$STATE_CRITICAL" |
147 | fi | 147 | fi |
148 | ;; | 148 | ;; |
149 | --oranames) | 149 | --oranames) |
150 | namesctl status $2 | awk ' | 150 | namesctl status "$2" | awk ' |
151 | /Server has been running for:/ { | 151 | /Server has been running for:/ { |
152 | msg = "OK: Up" | 152 | msg = "OK: Up" |
153 | for (i = 6; i <= NF; i++) { | 153 | for (i = 6; i <= NF; i++) { |
154 | msg = msg " " $i | 154 | msg = msg " " $i |
155 | } | 155 | } |
156 | status = '$STATE_OK' | 156 | status = '"$STATE_OK"' |
157 | } | 157 | } |
158 | /error/ { | 158 | /error/ { |
159 | msg = "CRITICAL: " $0 | 159 | msg = "CRITICAL: " $0 |
160 | status = '$STATE_CRITICAL' | 160 | status = '"$STATE_CRITICAL"' |
161 | } | 161 | } |
162 | END { | 162 | END { |
163 | print msg | 163 | print msg |
164 | exit status | 164 | exit status |
165 | }' | 165 | }' |
166 | ;; | 166 | ;; |
167 | --db) | 167 | --db) |
168 | pmonchk=`ps -ef | grep -v grep | grep -E -c "(asm|ora)_pmon_${2}$"` | 168 | pmonchk=$(pgrep -f "(asm|ora)_pmon_${2}$") |
169 | if [ ${pmonchk} -ge 1 ] ; then | 169 | if [ "${pmonchk}" -ge 1 ] ; then |
170 | echo "${2} OK - ${pmonchk} PMON process(es) running" | 170 | echo "${2} OK - ${pmonchk} PMON process(es) running" |
171 | exit $STATE_OK | 171 | exit "$STATE_OK" |
172 | #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then | 172 | #if [ -f $ORACLE_HOME/dbs/sga*${2}* ] ; then |
173 | #if [ ${pmonchk} -eq 1 ] ; then | 173 | #if [ ${pmonchk} -eq 1 ] ; then |
174 | #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` | 174 | #utime=`ls -la $ORACLE_HOME/dbs/sga*$2* | cut -c 43-55` |
175 | #echo "${2} OK - running since ${utime}" | 175 | #echo "${2} OK - running since ${utime}" |
176 | #exit $STATE_OK | 176 | #exit $STATE_OK |
177 | #fi | 177 | #fi |
178 | else | 178 | else |
179 | echo "${2} Database is DOWN" | 179 | echo "${2} Database is DOWN" |
180 | exit $STATE_CRITICAL | 180 | exit "$STATE_CRITICAL" |
181 | fi | 181 | fi |
182 | ;; | 182 | ;; |
183 | --login) | 183 | --login) |
184 | loginchk=`sqlplus dummy/user@$2 < /dev/null` | 184 | loginchk=$(sqlplus dummy/user@"$2" < /dev/null) |
185 | loginchk2=` echo $loginchk | grep -c ORA-01017` | 185 | loginchk2=$(echo "$loginchk" | grep -c ORA-01017) |
186 | if [ ${loginchk2} -eq 1 ] ; then | 186 | if [ "${loginchk2}" -eq 1 ] ; then |
187 | echo "OK - dummy login connected" | 187 | echo "OK - dummy login connected" |
188 | exit $STATE_OK | 188 | exit "$STATE_OK" |
189 | else | 189 | else |
190 | loginchk3=` echo "$loginchk" | grep "ORA-" | head -1` | 190 | loginchk3=$(echo "$loginchk" | grep "ORA-" | head -1) |
191 | echo "CRITICAL - $loginchk3" | 191 | echo "CRITICAL - $loginchk3" |
192 | exit $STATE_CRITICAL | 192 | exit "$STATE_CRITICAL" |
193 | fi | 193 | fi |
194 | ;; | 194 | ;; |
195 | --connect) | 195 | --connect) |
196 | connectchk=`sqlplus $2 < /dev/null` | 196 | connectchk=$(sqlplus "$2" < /dev/null) |
197 | connectchk2=` echo $connectchk | grep -c ORA-` | 197 | connectchk2=$(echo "$connectchk" | grep -c ORA-) |
198 | if [ ${connectchk2} -eq 0 ] ; then | 198 | if [ "${connectchk2}" -eq 0 ] ; then |
199 | echo "OK - login successful" | 199 | echo "OK - login successful" |
200 | exit $STATE_OK | 200 | exit "$STATE_OK" |
201 | else | 201 | else |
202 | connectchk3=` echo "$connectchk" | grep "ORA-" | head -1` | 202 | connectchk3=$(echo "$connectchk" | grep "ORA-" | head -1) |
203 | echo "CRITICAL - $connectchk3" | 203 | echo "CRITICAL - $connectchk3" |
204 | exit $STATE_CRITICAL | 204 | exit "$STATE_CRITICAL" |
205 | fi | 205 | fi |
206 | ;; | 206 | ;; |
207 | --cache) | 207 | --cache) |
208 | if [ ${5} -gt ${6} ] ; then | 208 | if [ "${5}" -gt "${6}" ] ; then |
209 | echo "UNKNOWN - Warning level is less then Crit" | 209 | echo "UNKNOWN - Warning level is less then Crit" |
210 | exit $STATE_UNKNOWN | 210 | exit "$STATE_UNKNOWN" |
211 | fi | 211 | fi |
212 | result=`sqlplus -s ${3}/${4}@${2} << EOF | 212 | result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF |
213 | set pagesize 0 | 213 | set pagesize 0 |
214 | set numf '9999999.99' | 214 | set numf '9999999.99' |
215 | select (1-(pr.value/(dbg.value+cg.value)))*100 | 215 | select (1-(pr.value/(dbg.value+cg.value)))*100 |
@@ -219,48 +219,48 @@ and dbg.name='db block gets' | |||
219 | and cg.name='consistent gets'; | 219 | and cg.name='consistent gets'; |
220 | EOF` | 220 | EOF` |
221 | 221 | ||
222 | if [ -n "`echo $result | grep ORA-`" ] ; then | 222 | if echo "$result" | grep -q 'ORA-' ; then |
223 | error=` echo "$result" | grep "ORA-" | head -1` | 223 | error=$(echo "$result" | grep "ORA-" | head -1) |
224 | echo "CRITICAL - $error" | 224 | echo "CRITICAL - $error" |
225 | exit $STATE_CRITICAL | 225 | exit "$STATE_CRITICAL" |
226 | fi | 226 | fi |
227 | 227 | ||
228 | buf_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` | 228 | buf_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}') |
229 | buf_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` | 229 | buf_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}') |
230 | result=`sqlplus -s ${3}/${4}@${2} << EOF | 230 | result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF |
231 | set pagesize 0 | 231 | set pagesize 0 |
232 | set numf '9999999.99' | 232 | set numf '9999999.99' |
233 | select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 | 233 | select sum(lc.pins)/(sum(lc.pins)+sum(lc.reloads))*100 |
234 | from v\\$librarycache lc; | 234 | from v\\$librarycache lc; |
235 | EOF` | 235 | EOF` |
236 | 236 | ||
237 | if [ -n "`echo $result | grep ORA-`" ] ; then | 237 | if echo "$result" | grep -q 'ORA-' ; then |
238 | error=` echo "$result" | grep "ORA-" | head -1` | 238 | error=$(echo "$result" | grep "ORA-" | head -1) |
239 | echo "CRITICAL - $error" | 239 | echo "CRITICAL - $error" |
240 | exit $STATE_CRITICAL | 240 | exit "$STATE_CRITICAL" |
241 | fi | 241 | fi |
242 | 242 | ||
243 | lib_hr=`echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}'` | 243 | lib_hr=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print int($1)}') |
244 | lib_hrx=`echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}'` | 244 | lib_hrx=$(echo "$result" | awk '/^[0-9\. \t]+$/ {print $1}') |
245 | 245 | ||
246 | if [ $buf_hr -le ${5} -o $lib_hr -le ${5} ] ; then | 246 | if [ "$buf_hr" -le "${5}" ] || [ "$lib_hr" -le "${5}" ] ; then |
247 | echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" | 247 | echo "${2} CRITICAL - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" |
248 | exit $STATE_CRITICAL | 248 | exit "$STATE_CRITICAL" |
249 | fi | 249 | fi |
250 | if [ $buf_hr -le ${6} -o $lib_hr -le ${6} ] ; then | 250 | if [ "$buf_hr" -le "${6}" ] || [ "$lib_hr" -le "${6}" ] ; then |
251 | echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" | 251 | echo "${2} WARNING - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" |
252 | exit $STATE_WARNING | 252 | exit "$STATE_WARNING" |
253 | fi | 253 | fi |
254 | echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" | 254 | echo "${2} OK - Cache Hit Rates: $lib_hrx% Lib -- $buf_hrx% Buff|lib=$lib_hrx%;${6};${5};0;100 buffer=$buf_hrx%;${6};${5};0;100" |
255 | 255 | ||
256 | exit $STATE_OK | 256 | exit "$STATE_OK" |
257 | ;; | 257 | ;; |
258 | --tablespace) | 258 | --tablespace) |
259 | if [ ${6} -lt ${7} ] ; then | 259 | if [ "${6}" -lt "${7}" ] ; then |
260 | echo "UNKNOWN - Warning level is more then Crit" | 260 | echo "UNKNOWN - Warning level is more then Crit" |
261 | exit $STATE_UNKNOWN | 261 | exit "$STATE_UNKNOWN" |
262 | fi | 262 | fi |
263 | result=`sqlplus -s ${3}/${4}@${2} << EOF | 263 | result=`sqlplus -s "${3}"/"${4}"@"${2}" << EOF |
264 | set pagesize 0 | 264 | set pagesize 0 |
265 | set numf '9999999.99' | 265 | set numf '9999999.99' |
266 | select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc | 266 | select NVL(b.free,0.0),a.total,100 - trunc(NVL(b.free,0.0)/a.total * 1000) / 10 prc |
@@ -273,32 +273,32 @@ from dba_free_space group by tablespace_name) B | |||
273 | ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}'; | 273 | ON a.tablespace_name=b.tablespace_name WHERE a.tablespace_name='${5}'; |
274 | EOF` | 274 | EOF` |
275 | 275 | ||
276 | if [ -n "`echo $result | grep ORA-`" ] ; then | 276 | if echo "$result" | grep -q 'ORA-' ; then |
277 | error=` echo "$result" | grep "ORA-" | head -1` | 277 | error=$(echo "$result" | grep "ORA-" | head -1) |
278 | echo "CRITICAL - $error" | 278 | echo "CRITICAL - $error" |
279 | exit $STATE_CRITICAL | 279 | exit "$STATE_CRITICAL" |
280 | fi | 280 | fi |
281 | 281 | ||
282 | ts_free=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}'` | 282 | ts_free=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($1)}') |
283 | ts_total=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}'` | 283 | ts_total=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($2)}') |
284 | ts_pct=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}'` | 284 | ts_pct=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print int($3)}') |
285 | ts_pctx=`echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}'` | 285 | ts_pctx=$(echo "$result" | awk '/^[ 0-9\.\t ]+$/ {print $3}') |
286 | if [ "$ts_free" -eq 0 -a "$ts_total" -eq 0 -a "$ts_pct" -eq 0 ] ; then | 286 | if [ "$ts_free" -eq 0 ] && [ "$ts_total" -eq 0 ] && [ "$ts_pct" -eq 0 ] ; then |
287 | echo "No data returned by Oracle - tablespace $5 not found?" | 287 | echo "No data returned by Oracle - tablespace $5 not found?" |
288 | exit $STATE_UNKNOWN | 288 | exit "$STATE_UNKNOWN" |
289 | fi | 289 | fi |
290 | if [ "$ts_pct" -ge ${6} ] ; then | 290 | if [ "$ts_pct" -ge "${6}" ] ; then |
291 | echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" | 291 | echo "${2} : ${5} CRITICAL - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" |
292 | exit $STATE_CRITICAL | 292 | exit "$STATE_CRITICAL" |
293 | fi | 293 | fi |
294 | if [ "$ts_pct" -ge ${7} ] ; then | 294 | if [ "$ts_pct" -ge "${7}" ] ; then |
295 | echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" | 295 | echo "${2} : ${5} WARNING - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" |
296 | exit $STATE_WARNING | 296 | exit "$STATE_WARNING" |
297 | fi | 297 | fi |
298 | echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" | 298 | echo "${2} : ${5} OK - $ts_pctx% used [ $ts_free / $ts_total MB available ]|${5}=$ts_pctx%;${7};${6};0;100" |
299 | exit $STATE_OK | 299 | exit "$STATE_OK" |
300 | ;; | 300 | ;; |
301 | *) | 301 | *) |
302 | print_usage | 302 | print_usage |
303 | exit $STATE_UNKNOWN | 303 | exit "$STATE_UNKNOWN" |
304 | esac | 304 | esac |
diff --git a/plugins-scripts/check_rpc.pl b/plugins-scripts/check_rpc.pl index 47d6e49..8a56b9f 100755 --- a/plugins-scripts/check_rpc.pl +++ b/plugins-scripts/check_rpc.pl | |||
@@ -5,7 +5,7 @@ | |||
5 | # usage: | 5 | # usage: |
6 | # check_rpc host service | 6 | # check_rpc host service |
7 | # | 7 | # |
8 | # Check if an rpc serice is registered and running | 8 | # Check if an rpc service is registered and running |
9 | # using rpcinfo - $proto $host $prognum 2>&1 |"; | 9 | # using rpcinfo - $proto $host $prognum 2>&1 |"; |
10 | # | 10 | # |
11 | # Use these hosts.cfg entries as examples | 11 | # Use these hosts.cfg entries as examples |
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh index f742830..866e0e0 100755 --- a/plugins-scripts/check_sensors.sh +++ b/plugins-scripts/check_sensors.sh | |||
@@ -2,57 +2,57 @@ | |||
2 | 2 | ||
3 | PATH="@TRUSTED_PATH@" | 3 | PATH="@TRUSTED_PATH@" |
4 | export PATH | 4 | export PATH |
5 | PROGNAME=`basename $0` | 5 | PROGNAME=$(basename "$0") |
6 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 6 | PROGPATH=$(echo "$0" | sed -e 's,[\\/][^\\/][^\\/]*$,,') |
7 | REVISION="@NP_VERSION@" | 7 | REVISION="@NP_VERSION@" |
8 | 8 | ||
9 | . $PROGPATH/utils.sh | 9 | . "$PROGPATH"/utils.sh |
10 | 10 | ||
11 | print_usage() { | 11 | print_usage() { |
12 | echo "Usage: $PROGNAME" [--ignore-fault] | 12 | echo "Usage: $PROGNAME" [--ignore-fault] |
13 | } | 13 | } |
14 | 14 | ||
15 | print_help() { | 15 | print_help() { |
16 | print_revision $PROGNAME $REVISION | 16 | print_revision "$PROGNAME" "$REVISION" |
17 | echo "" | 17 | echo "" |
18 | print_usage | 18 | print_usage |
19 | echo "" | 19 | echo "" |
20 | echo "This plugin checks hardware status using the lm_sensors package." | 20 | echo "This plugin checks hardware status using the lm_sensors package." |
21 | echo "" | 21 | echo "" |
22 | support | 22 | support |
23 | exit $STATE_OK | 23 | exit "$STATE_OK" |
24 | } | 24 | } |
25 | 25 | ||
26 | case "$1" in | 26 | case "$1" in |
27 | --help) | 27 | --help) |
28 | print_help | 28 | print_help |
29 | exit $STATE_OK | 29 | exit "$STATE_UNKNOWN" |
30 | ;; | 30 | ;; |
31 | -h) | 31 | -h) |
32 | print_help | 32 | print_help |
33 | exit $STATE_OK | 33 | exit "$STATE_UNKNOWN" |
34 | ;; | 34 | ;; |
35 | --version) | 35 | --version) |
36 | print_revision $PROGNAME $REVISION | 36 | print_revision "$PROGNAME" "$REVISION" |
37 | exit $STATE_OK | 37 | exit "$STATE_UNKNOWN" |
38 | ;; | 38 | ;; |
39 | -V) | 39 | -V) |
40 | print_revision $PROGNAME $REVISION | 40 | print_revision "$PROGNAME" "$REVISION" |
41 | exit $STATE_OK | 41 | exit "$STATE_UNKNOWN" |
42 | ;; | 42 | ;; |
43 | *) | 43 | *) |
44 | sensordata=`sensors 2>&1` | 44 | sensordata=$(sensors 2>&1) |
45 | status=$? | 45 | status=$? |
46 | if test ${status} -eq 127; then | 46 | if test ${status} -eq 127; then |
47 | text="SENSORS UNKNOWN - command not found (did you install lmsensors?)" | 47 | text="SENSORS UNKNOWN - command not found (did you install lmsensors?)" |
48 | exit=$STATE_UNKNOWN | 48 | exit=$STATE_UNKNOWN |
49 | elif test ${status} -ne 0; then | 49 | elif test "${status}" -ne 0; then |
50 | text="WARNING - sensors returned state $status" | 50 | text="WARNING - sensors returned state $status" |
51 | exit=$STATE_WARNING | 51 | exit=$STATE_WARNING |
52 | elif echo ${sensordata} | egrep ALARM > /dev/null; then | 52 | elif echo "${sensordata}" | grep -E ALARM > /dev/null; then |
53 | text="SENSOR CRITICAL - Sensor alarm detected!" | 53 | text="SENSOR CRITICAL - Sensor alarm detected!" |
54 | exit=$STATE_CRITICAL | 54 | exit=$STATE_CRITICAL |
55 | elif echo ${sensordata} | egrep FAULT > /dev/null \ | 55 | elif echo "${sensordata}" | grep -E FAULT > /dev/null \ |
56 | && test "$1" != "-i" -a "$1" != "--ignore-fault"; then | 56 | && test "$1" != "-i" -a "$1" != "--ignore-fault"; then |
57 | text="SENSOR UNKNOWN - Sensor reported fault" | 57 | text="SENSOR UNKNOWN - Sensor reported fault" |
58 | exit=$STATE_UNKNOWN | 58 | exit=$STATE_UNKNOWN |
@@ -63,8 +63,8 @@ case "$1" in | |||
63 | 63 | ||
64 | echo "$text" | 64 | echo "$text" |
65 | if test "$1" = "-v" -o "$1" = "--verbose"; then | 65 | if test "$1" = "-v" -o "$1" = "--verbose"; then |
66 | echo ${sensordata} | 66 | echo "${sensordata}" |
67 | fi | 67 | fi |
68 | exit $exit | 68 | exit "$exit" |
69 | ;; | 69 | ;; |
70 | esac | 70 | esac |
diff --git a/plugins-scripts/check_uptime.pl b/plugins-scripts/check_uptime.pl new file mode 100755 index 0000000..d73e40e --- /dev/null +++ b/plugins-scripts/check_uptime.pl | |||
@@ -0,0 +1,328 @@ | |||
1 | #!@PERL@ -w | ||
2 | |||
3 | # check_uptime - check uptime to see how long the system is running. | ||
4 | # | ||
5 | |||
6 | # License Information: | ||
7 | # This program is free software; you can redistribute it and/or modify | ||
8 | # it under the terms of the GNU General Public License as published by | ||
9 | # the Free Software Foundation; either version 2 of the License, or | ||
10 | # (at your option) any later version. | ||
11 | # | ||
12 | # This program is distributed in the hope that it will be useful, | ||
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | # GNU General Public License for more details. | ||
16 | # | ||
17 | # You should have received a copy of the GNU General Public License | ||
18 | # along with this program; if not, write to the Free Software | ||
19 | # Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
20 | # USA | ||
21 | # | ||
22 | ############################################################################ | ||
23 | |||
24 | use POSIX; | ||
25 | use strict; | ||
26 | use Getopt::Long; | ||
27 | use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c | ||
28 | $opt_f $opt_s $opt_d | ||
29 | $lower_warn_threshold $upper_warn_threshold | ||
30 | $lower_crit_threshold $upper_crit_threshold | ||
31 | $status $state $msg); | ||
32 | use FindBin; | ||
33 | use lib "$FindBin::Bin"; | ||
34 | use utils qw(%ERRORS &print_revision &support &usage ); | ||
35 | |||
36 | sub print_help (); | ||
37 | sub print_usage (); | ||
38 | sub process_arguments (); | ||
39 | |||
40 | $ENV{'PATH'}='@TRUSTED_PATH@'; | ||
41 | $ENV{'BASH_ENV'}=''; | ||
42 | $ENV{'ENV'}=''; | ||
43 | $PROGNAME = "check_uptime"; | ||
44 | $state = $ERRORS{'UNKNOWN'}; | ||
45 | |||
46 | my $uptime_file = "/proc/uptime"; | ||
47 | |||
48 | |||
49 | # Process arguments | ||
50 | |||
51 | Getopt::Long::Configure('bundling'); | ||
52 | $status = process_arguments(); | ||
53 | if ($status){ | ||
54 | print "ERROR: processing arguments\n"; | ||
55 | exit $ERRORS{"UNKNOWN"}; | ||
56 | } | ||
57 | |||
58 | |||
59 | # Get uptime info from file | ||
60 | |||
61 | if ( ! -r $uptime_file ) { | ||
62 | print "ERROR: file '$uptime_file' is not readable\n"; | ||
63 | exit $ERRORS{"UNKNOWN"}; | ||
64 | } | ||
65 | |||
66 | if ( ! open FILE, "<", $uptime_file ) { | ||
67 | print "ERROR: cannot read from file '$uptime_file'\n"; | ||
68 | exit $ERRORS{"UNKNOWN"}; | ||
69 | } | ||
70 | |||
71 | chomp( my $file_content = <FILE> ); | ||
72 | close FILE; | ||
73 | |||
74 | print "$uptime_file: $file_content\n" if $verbose; | ||
75 | |||
76 | # Get first digit value (without fraction) | ||
77 | my ( $uptime_seconds ) = $file_content =~ /^([\d]+)/; | ||
78 | |||
79 | # Bail out if value is not numeric | ||
80 | if ( $uptime_seconds !~ /^\d+$/ ) { | ||
81 | print "ERROR: no numeric value: $uptime_seconds\n"; | ||
82 | exit $ERRORS{"UNKNOWN"}; | ||
83 | } | ||
84 | |||
85 | |||
86 | # Do calculations for a "pretty" format (2 weeks, 5 days, ...) | ||
87 | |||
88 | my ( $secs, $mins, $hours, $days, $weeks ); | ||
89 | $secs = $uptime_seconds; | ||
90 | $mins = $hours = $days = $weeks = 0; | ||
91 | if ( $secs > 100 ) { | ||
92 | $mins = int( $secs / 60 ); | ||
93 | $secs -= $mins * 60; | ||
94 | } | ||
95 | if ( $mins > 100 ) { | ||
96 | $hours = int( $mins / 60 ); | ||
97 | $mins -= $hours * 60; | ||
98 | } | ||
99 | if ( $hours > 48 ) { | ||
100 | $days = int( $hours / 24 ); | ||
101 | $hours -= $days * 24; | ||
102 | } | ||
103 | if ( $days > 14 ) { | ||
104 | $weeks = int( $days / 7 ); | ||
105 | $days -= $weeks * 7; | ||
106 | } | ||
107 | |||
108 | my $pretty_uptime = ""; | ||
109 | $pretty_uptime .= sprintf( "%d week%s, ", $weeks, $weeks == 1 ? "" : "s" ) if $weeks; | ||
110 | $pretty_uptime .= sprintf( "%d day%s, ", $days, $days == 1 ? "" : "s" ) if $days; | ||
111 | $pretty_uptime .= sprintf( "%d hour%s, ", $hours, $hours == 1 ? "" : "s" ) if $hours; | ||
112 | $pretty_uptime .= sprintf( "%d minute%s, ", $mins, $mins == 1 ? "" : "s" ) if $mins; | ||
113 | # Replace last occurrence of comma with "and" | ||
114 | $pretty_uptime =~ s/, $/ and /; | ||
115 | # Always print the seconds (though it may be 0 seconds) | ||
116 | $pretty_uptime .= sprintf( "%d second%s", $secs, $secs == 1 ? "" : "s" ); | ||
117 | |||
118 | |||
119 | # Default to catch errors in program | ||
120 | my $state_str = "UNKNOWN"; | ||
121 | |||
122 | # Check values | ||
123 | my $out_of_bounds_text = ""; | ||
124 | if ( $uptime_seconds > $upper_crit_threshold ) { | ||
125 | $state_str = "CRITICAL"; | ||
126 | $out_of_bounds_text = "upper crit"; | ||
127 | } elsif ( $uptime_seconds < $lower_crit_threshold ) { | ||
128 | $state_str = "CRITICAL"; | ||
129 | $out_of_bounds_text = "lower crit"; | ||
130 | } elsif ( $uptime_seconds > $upper_warn_threshold ) { | ||
131 | $state_str = "WARNING"; | ||
132 | $out_of_bounds_text = "upper warn"; | ||
133 | } elsif ( $uptime_seconds < $lower_warn_threshold ) { | ||
134 | $state_str = "WARNING"; | ||
135 | $out_of_bounds_text = "lower warn"; | ||
136 | } else { | ||
137 | $state_str = "OK"; | ||
138 | } | ||
139 | |||
140 | # Prepare uptime value (seconds or days) | ||
141 | my $uptime_text = ""; | ||
142 | my $uptime_unit = ""; | ||
143 | if ( $opt_d ) { | ||
144 | $uptime_text = floor($uptime_seconds / 60 / 60 / 24); | ||
145 | $uptime_unit = "days"; | ||
146 | } else { | ||
147 | $uptime_text = $uptime_seconds; | ||
148 | $uptime_unit = "seconds"; | ||
149 | } | ||
150 | |||
151 | $msg = "$state_str: "; | ||
152 | |||
153 | $msg .= "Uptime is $uptime_text $uptime_unit. "; | ||
154 | $msg .= "Exceeds $out_of_bounds_text threshold. " if $out_of_bounds_text; | ||
155 | $msg .= "Running for $pretty_uptime. " if $opt_f; | ||
156 | if ( $opt_s ) { | ||
157 | my $up_since = strftime( "%Y-%m-%d %H:%M:%S", localtime( time - $uptime_seconds ) ); | ||
158 | $msg .= "Running since $up_since. "; | ||
159 | } | ||
160 | |||
161 | $state = $ERRORS{$state_str}; | ||
162 | |||
163 | # Perfdata support | ||
164 | print "$msg|uptime=${uptime_seconds}s;$upper_warn_threshold;$upper_crit_threshold;0\n"; | ||
165 | exit $state; | ||
166 | |||
167 | |||
168 | ##################################### | ||
169 | #### subs | ||
170 | |||
171 | |||
172 | sub process_arguments(){ | ||
173 | GetOptions | ||
174 | ("V" => \$opt_V, "version" => \$opt_V, | ||
175 | "v" => \$opt_v, "verbose" => \$opt_v, | ||
176 | "h" => \$opt_h, "help" => \$opt_h, | ||
177 | "w=s" => \$opt_w, "warning=s" => \$opt_w, # warning if above this number | ||
178 | "c=s" => \$opt_c, "critical=s" => \$opt_c, # critical if above this number | ||
179 | "f" => \$opt_f, "for" => \$opt_f, # show "running for ..." | ||
180 | "s" => \$opt_s, "since" => \$opt_s, # show "running since ..." | ||
181 | "d" => \$opt_d, "days" => \$opt_d, # report uptime in days | ||
182 | ); | ||
183 | |||
184 | if ($opt_V) { | ||
185 | print_revision($PROGNAME,'@NP_VERSION@'); | ||
186 | exit $ERRORS{'UNKNOWN'}; | ||
187 | } | ||
188 | |||
189 | if ($opt_h) { | ||
190 | print_help(); | ||
191 | exit $ERRORS{'UNKNOWN'}; | ||
192 | } | ||
193 | |||
194 | if (defined $opt_v) { | ||
195 | $verbose = $opt_v; | ||
196 | } | ||
197 | |||
198 | unless ( defined $opt_w && defined $opt_c ) { | ||
199 | print_usage(); | ||
200 | exit $ERRORS{'UNKNOWN'}; | ||
201 | } | ||
202 | |||
203 | # Check if a range was supplied ("lowvalue:highvalue") for warning and critical | ||
204 | # Otherwise, set 0 as the lower threshold and the parameter value as upper threshold | ||
205 | # (the uptime should always be positive, so there should be no issue) | ||
206 | if ( $opt_w =~ /^(.+):(.+)$/ ) { | ||
207 | $lower_warn_threshold = $1; | ||
208 | $upper_warn_threshold = $2; | ||
209 | } else { | ||
210 | $lower_warn_threshold = 0; | ||
211 | $upper_warn_threshold = $opt_w; | ||
212 | } | ||
213 | if ( $opt_c =~ /^(.+):(.+)$/ ) { | ||
214 | $lower_crit_threshold = $1; | ||
215 | $upper_crit_threshold = $2; | ||
216 | } else { | ||
217 | $lower_crit_threshold = 0; | ||
218 | $upper_crit_threshold = $opt_c; | ||
219 | } | ||
220 | |||
221 | # Set as seconds (calculate if suffix present) | ||
222 | $lower_warn_threshold = calc_as_seconds( $lower_warn_threshold ); | ||
223 | $lower_crit_threshold = calc_as_seconds( $lower_crit_threshold ); | ||
224 | $upper_warn_threshold = calc_as_seconds( $upper_warn_threshold ); | ||
225 | $upper_crit_threshold = calc_as_seconds( $upper_crit_threshold ); | ||
226 | |||
227 | # Check for numeric value of warning parameter | ||
228 | if ( $lower_warn_threshold !~ /^\d+$/ ) { | ||
229 | print "Lower warning (-w) is not numeric\n"; | ||
230 | exit $ERRORS{'UNKNOWN'}; | ||
231 | } | ||
232 | if ( $upper_warn_threshold !~ /^\d+$/ ) { | ||
233 | print "Upper warning (-w) is not numeric\n"; | ||
234 | exit $ERRORS{'UNKNOWN'}; | ||
235 | } | ||
236 | # Check for numeric value of critical parameter | ||
237 | if ( $lower_crit_threshold !~ /^\d+$/ ) { | ||
238 | print "Lower critical (-c) is not numeric\n"; | ||
239 | exit $ERRORS{'UNKNOWN'}; | ||
240 | } | ||
241 | if ( $upper_crit_threshold !~ /^\d+$/ ) { | ||
242 | print "Upper critical (-c) is not numeric\n"; | ||
243 | exit $ERRORS{'UNKNOWN'}; | ||
244 | } | ||
245 | |||
246 | # Check boundaries | ||
247 | if ( $upper_warn_threshold >= $upper_crit_threshold ) { | ||
248 | print "Upper Warning (-w) cannot be greater than Critical (-c)!\n"; | ||
249 | exit $ERRORS{'UNKNOWN'}; | ||
250 | } | ||
251 | # No "<=" since both values are zero if no range (only upper threshold values) is given | ||
252 | if ( $lower_warn_threshold < $lower_crit_threshold ) { | ||
253 | print "Lower Warning (-w) cannot be less than Critical (-c)!\n"; | ||
254 | exit $ERRORS{'UNKNOWN'}; | ||
255 | } | ||
256 | |||
257 | return $ERRORS{'OK'}; | ||
258 | } | ||
259 | |||
260 | sub print_usage () { | ||
261 | print "Usage: $PROGNAME -w <warn> -c <crit> [-v]\n"; | ||
262 | } | ||
263 | |||
264 | sub print_help () { | ||
265 | print_revision($PROGNAME,'@NP_VERSION@'); | ||
266 | print "Copyright (c) 2002 Subhendu Ghosh/Carlos Canau/Benjamin Schmid\n"; | ||
267 | print "Copyright (c) 2018 Bernd Arnold\n"; | ||
268 | print "\n"; | ||
269 | print_usage(); | ||
270 | print "\n"; | ||
271 | print " Checks the uptime of the system using $uptime_file\n"; | ||
272 | print "\n"; | ||
273 | print "-w (--warning) = Min. number of uptime to generate warning\n"; | ||
274 | print "-c (--critical) = Min. number of uptime to generate critical alert ( w < c )\n"; | ||
275 | print "-f (--for) = Show uptime in a pretty format (Running for x weeks, x days, ...)\n"; | ||
276 | print "-s (--since) = Show last boot in yyyy-mm-dd HH:MM:SS format (output from 'uptime -s')\n"; | ||
277 | print "-d (--days) = Show uptime in days\n"; | ||
278 | print "-h (--help)\n"; | ||
279 | print "-V (--version)\n"; | ||
280 | print "-v (--verbose) = debugging output\n"; | ||
281 | print "\n\n"; | ||
282 | print "Note: -w and -c are required arguments.\n"; | ||
283 | print " You can suffix both values with s for seconds (default), m (minutes), h (hours), d (days) or w (weeks).\n"; | ||
284 | print "\n"; | ||
285 | print "Range support: You may specify a range for both warning and critical thresholds.\n"; | ||
286 | print " This works without additional Perl modules.\n"; | ||
287 | print "Example: ./check_uptime -w 10m:4w -c 1m:8w\n"; | ||
288 | print " Results in a critical state when uptime is below 60 seconds or higher than 8 weeks,\n"; | ||
289 | print " and in a warning state when uptime is below 10 minutes or above 4 weeks.\n"; | ||
290 | print "\n\n"; | ||
291 | support(); | ||
292 | } | ||
293 | |||
294 | sub calc_as_seconds () { | ||
295 | |||
296 | my $parameter = shift; | ||
297 | |||
298 | # Check if suffix is present | ||
299 | # Calculate parameter to seconds (to get an integer value finally) | ||
300 | # If no suffix is present, just return the value | ||
301 | |||
302 | # Possible suffixes: | ||
303 | # s = seconds | ||
304 | # m = minutes | ||
305 | # h = hours | ||
306 | # d = days | ||
307 | # w = weeks | ||
308 | my %factor = ( "s" => 1, | ||
309 | "m" => 60, | ||
310 | "h" => 60 * 60, | ||
311 | "d" => 60 * 60 * 24, | ||
312 | "w" => 60 * 60 * 24 * 7, | ||
313 | ); | ||
314 | |||
315 | if ( $parameter =~ /^(\d+)([a-z])$/ ) { | ||
316 | my $value = $1; | ||
317 | my $suffix = $2; | ||
318 | print "detected: value=$value, suffix=$suffix\n" if $verbose; | ||
319 | if ( ! defined $factor{$suffix} ) { | ||
320 | print "Error: wrong suffix ($suffix) for value '$parameter'"; | ||
321 | exit $ERRORS{'UNKNOWN'}; | ||
322 | } | ||
323 | $parameter = $value * $factor{$suffix}; | ||
324 | } | ||
325 | |||
326 | return $parameter; | ||
327 | |||
328 | } | ||
diff --git a/plugins-scripts/check_wave.pl b/plugins-scripts/check_wave.pl index 41e15f5..c24015c 100755 --- a/plugins-scripts/check_wave.pl +++ b/plugins-scripts/check_wave.pl | |||
@@ -19,6 +19,7 @@ sub print_usage (); | |||
19 | $ENV{'PATH'}='@TRUSTED_PATH@'; | 19 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
20 | $ENV{'BASH_ENV'}=''; | 20 | $ENV{'BASH_ENV'}=''; |
21 | $ENV{'ENV'}=''; | 21 | $ENV{'ENV'}=''; |
22 | $ENV{'CDPATH'}=''; | ||
22 | 23 | ||
23 | Getopt::Long::Configure('bundling'); | 24 | Getopt::Long::Configure('bundling'); |
24 | GetOptions | 25 | GetOptions |
@@ -50,34 +51,34 @@ my $critical = $1 if ($opt_c =~ /([0-9]+)/); | |||
50 | ($opt_w) || ($opt_w = shift) || ($opt_w = 60); | 51 | ($opt_w) || ($opt_w = shift) || ($opt_w = 60); |
51 | my $warning = $1 if ($opt_w =~ /([0-9]+)/); | 52 | my $warning = $1 if ($opt_w =~ /([0-9]+)/); |
52 | 53 | ||
53 | $low1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; | 54 | $low1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; |
54 | @test = split(/ /,$low1); | 55 | @test = split(/ /,$low1); |
55 | $low1 = $test[2]; | 56 | $low1 = $test[2]; |
56 | 57 | ||
57 | $med1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; | 58 | $med1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; |
58 | @test = split(/ /,$med1); | 59 | @test = split(/ /,$med1); |
59 | $med1 = $test[2]; | 60 | $med1 = $test[2]; |
60 | 61 | ||
61 | $high1 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; | 62 | $high1 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; |
62 | @test = split(/ /,$high1); | 63 | @test = split(/ /,$high1); |
63 | $high1 = $test[2]; | 64 | $high1 = $test[2]; |
64 | 65 | ||
65 | sleep(2); | 66 | sleep(2); |
66 | 67 | ||
67 | $snr = `snmpget $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`; | 68 | $snr = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.762.2.5.2.1.17.1`; |
68 | @test = split(/ /,$snr); | 69 | @test = split(/ /,$snr); |
69 | $snr = $test[2]; | 70 | $snr = $test[2]; |
70 | $snr = int($snr*25); | 71 | $snr = int($snr*25); |
71 | 72 | ||
72 | $low2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; | 73 | $low2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; |
73 | @test = split(/ /,$low2); | 74 | @test = split(/ /,$low2); |
74 | $low2 = $test[2]; | 75 | $low2 = $test[2]; |
75 | 76 | ||
76 | $med2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; | 77 | $med2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; |
77 | @test = split(/ /,$med2); | 78 | @test = split(/ /,$med2); |
78 | $med2 = $test[2]; | 79 | $med2 = $test[2]; |
79 | 80 | ||
80 | $high2 = `snmpget $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; | 81 | $high2 = `$utils::PATH_TO_SNMPGET $host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; |
81 | @test = split(/ /,$high2); | 82 | @test = split(/ /,$high2); |
82 | $high2 = $test[2]; | 83 | $high2 = $test[2]; |
83 | 84 | ||
diff --git a/plugins-scripts/t/check_file_age.t b/plugins-scripts/t/check_file_age.t index ebf673f..8b87670 100644 --- a/plugins-scripts/t/check_file_age.t +++ b/plugins-scripts/t/check_file_age.t | |||
@@ -20,105 +20,74 @@ my $temp_link = "/tmp/check_file_age.link.tmp"; | |||
20 | 20 | ||
21 | unlink $temp_file, $temp_link; | 21 | unlink $temp_file, $temp_link; |
22 | 22 | ||
23 | $result = NPTest->testCmd( | 23 | $result = NPTest->testCmd("./check_file_age"); |
24 | "./check_file_age" | ||
25 | ); | ||
26 | cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); | 24 | cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); |
27 | like ( $result->output, $unknownOutput, "Output for unknown correct" ); | 25 | like ( $result->output, $unknownOutput, "Output for unknown correct" ); |
28 | 26 | ||
29 | $result = NPTest->testCmd( | 27 | $result = NPTest->testCmd("./check_file_age -f $temp_file"); |
30 | "./check_file_age -f $temp_file" | ||
31 | ); | ||
32 | cmp_ok( $result->return_code, '==', 2, "File not exists" ); | 28 | cmp_ok( $result->return_code, '==', 2, "File not exists" ); |
33 | like ( $result->output, $criticalOutput, "Output for file missing correct" ); | 29 | like ( $result->output, $criticalOutput, "Output for file missing correct" ); |
34 | 30 | ||
35 | write_chars(100); | 31 | write_chars(100); |
36 | $result = NPTest->testCmd( | 32 | $result = NPTest->testCmd("./check_file_age -f $temp_file"); |
37 | "./check_file_age -f $temp_file" | ||
38 | ); | ||
39 | cmp_ok( $result->return_code, '==', 0, "File is new enough" ); | 33 | cmp_ok( $result->return_code, '==', 0, "File is new enough" ); |
40 | like ( $result->output, $successOutput, "Output for success correct" ); | 34 | like ( $result->output, $successOutput, "Output for success correct" ); |
41 | 35 | ||
42 | sleep 2; | 36 | sleep 2; |
43 | 37 | ||
44 | $result = NPTest->testCmd( | 38 | $result = NPTest->testCmd("./check_file_age -f $temp_file -w 1"); |
45 | "./check_file_age -f $temp_file -w 1" | ||
46 | ); | ||
47 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" ); | 39 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" ); |
48 | like ( $result->output, $warningOutput, "Output for warning correct" ); | 40 | like ( $result->output, $warningOutput, "Output for warning correct" ); |
49 | 41 | ||
50 | $result = NPTest->testCmd( | 42 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1"); |
51 | "./check_file_age -f $temp_file -w 0:1" | ||
52 | ); | ||
53 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old by range" ); | ||
54 | like ( $result->output, $warningOutput, "Output for warning by range correct" ); | ||
55 | |||
56 | $result = NPTest->testCmd( | ||
57 | "./check_file_age -f $temp_file -c 1" | ||
58 | ); | ||
59 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" ); | 43 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" ); |
60 | like ( $result->output, $criticalOutput, "Output for critical correct" ); | 44 | like ( $result->output, $criticalOutput, "Output for critical correct" ); |
61 | 45 | ||
62 | $result = NPTest->testCmd( | 46 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100"); |
63 | "./check_file_age -f $temp_file -c 0:1" | ||
64 | ); | ||
65 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old by range" ); | ||
66 | like ( $result->output, $criticalOutput, "Output for critical by range correct" ); | ||
67 | |||
68 | $result = NPTest->testCmd( | ||
69 | "./check_file_age -f $temp_file -c 1000 -W 100" | ||
70 | ); | ||
71 | cmp_ok( $result->return_code, '==', 0, "Checking file size" ); | 47 | cmp_ok( $result->return_code, '==', 0, "Checking file size" ); |
72 | 48 | ||
73 | $result = NPTest->testCmd( | 49 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100"); |
74 | "./check_file_age -f $temp_file -c 0:1000 -W 0:100" | ||
75 | ); | ||
76 | cmp_ok( $result->return_code, '==', 0, "Checking file size by range" ); | ||
77 | |||
78 | $result = NPTest->testCmd( | ||
79 | "./check_file_age -f $temp_file -c 1000 -W 100" | ||
80 | ); | ||
81 | like( $result->output, $performanceOutput, "Checking for performance Output" ); | 50 | like( $result->output, $performanceOutput, "Checking for performance Output" ); |
82 | 51 | ||
83 | $result = NPTest->testCmd( | 52 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100"); |
84 | "./check_file_age -f $temp_file -c 1000 -W 100" | ||
85 | ); | ||
86 | like( $result->output, $performanceOutput, "Checking for performance Output from range" ); | 53 | like( $result->output, $performanceOutput, "Checking for performance Output from range" ); |
87 | 54 | ||
88 | $result = NPTest->testCmd( | 55 | $result = NPTest->testCmd("./check_file_age -f /non/existent --ignore-missing"); |
89 | "./check_file_age -f /non/existent --ignore-missing" | ||
90 | ); | ||
91 | cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); | 56 | cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); |
92 | 57 | ||
93 | $result = NPTest->testCmd( | 58 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101"); |
94 | "./check_file_age -f $temp_file -c 1000 -W 101" | ||
95 | ); | ||
96 | cmp_ok( $result->return_code, '==', 1, "One byte too short" ); | 59 | cmp_ok( $result->return_code, '==', 1, "One byte too short" ); |
97 | 60 | ||
98 | $result = NPTest->testCmd( | 61 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101"); |
99 | "./check_file_age -f $temp_file -c 1000 -W 101:" | ||
100 | ); | ||
101 | cmp_ok( $result->return_code, '==', 1, "One byte too short by range" ); | ||
102 | |||
103 | $result = NPTest->testCmd( | ||
104 | "./check_file_age -f $temp_file -c 1000 -C 101" | ||
105 | ); | ||
106 | cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" ); | 62 | cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" ); |
107 | 63 | ||
108 | $result = NPTest->testCmd( | 64 | SKIP: { |
109 | "./check_file_age -f $temp_file -c 1000 -C 101:" | 65 | eval 'use Monitoring::Plugin::Range'; |
110 | ); | 66 | skip "Monitoring::Plugin::Range module require", 9 if $@; |
111 | cmp_ok( $result->return_code, '==', 2, "One byte too short by range - critical" ); | 67 | |
68 | $result = NPTest->testCmd("./check_file_age -f $temp_file -w 0:1"); | ||
69 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old by range" ); | ||
70 | like ( $result->output, $warningOutput, "Output for warning by range correct" ); | ||
71 | |||
72 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1"); | ||
73 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old by range" ); | ||
74 | like ( $result->output, $criticalOutput, "Output for critical by range correct" ); | ||
75 | |||
76 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1000 -W 0:100"); | ||
77 | cmp_ok( $result->return_code, '==', 0, "Checking file size by range" ); | ||
78 | |||
79 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101:"); | ||
80 | cmp_ok( $result->return_code, '==', 1, "One byte too short by range" ); | ||
81 | |||
82 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 0:99"); | ||
83 | cmp_ok( $result->return_code, '==', 1, "One byte too long by range" ); | ||
112 | 84 | ||
113 | $result = NPTest->testCmd( | 85 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101:"); |
114 | "./check_file_age -f $temp_file -c 1000 -W 0:99" | 86 | cmp_ok( $result->return_code, '==', 2, "One byte too short by range - critical" ); |
115 | ); | ||
116 | cmp_ok( $result->return_code, '==', 1, "One byte too long by range" ); | ||
117 | 87 | ||
118 | $result = NPTest->testCmd( | 88 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 0:99"); |
119 | "./check_file_age -f $temp_file -c 1000 -C 0:99" | 89 | cmp_ok( $result->return_code, '==', 2, "One byte too long by range - critical" ); |
120 | ); | 90 | }; |
121 | cmp_ok( $result->return_code, '==', 2, "One byte too long by range - critical" ); | ||
122 | 91 | ||
123 | symlink $temp_file, $temp_link or die "Cannot create symlink"; | 92 | symlink $temp_file, $temp_link or die "Cannot create symlink"; |
124 | $result = NPTest->testCmd("./check_file_age -f $temp_link -c 10"); | 93 | $result = NPTest->testCmd("./check_file_age -f $temp_link -c 10"); |
diff --git a/plugins-scripts/t/check_log.t b/plugins-scripts/t/check_log.t new file mode 100644 index 0000000..b66e0fd --- /dev/null +++ b/plugins-scripts/t/check_log.t | |||
@@ -0,0 +1,82 @@ | |||
1 | #!/usr/bin/perl -w -I .. | ||
2 | # | ||
3 | # check_log tests | ||
4 | # | ||
5 | # | ||
6 | |||
7 | use strict; | ||
8 | use Test::More; | ||
9 | use NPTest; | ||
10 | |||
11 | my $tests = 18; | ||
12 | plan tests => $tests; | ||
13 | |||
14 | my $firstTimeOutput ='/^Log check data initialized/'; | ||
15 | my $okOutput = '/^Log check ok - 0 pattern matches found/'; | ||
16 | my $criticalOutput = '/^\(\d+\) < /'; | ||
17 | my $multilineOutput = '/\(3\) <.*\n.*\n.*$/'; | ||
18 | my $unknownOutput = '/^Usage: /'; | ||
19 | my $unknownArgOutput = '/^Unknown argument: /'; | ||
20 | my $bothRegexOutput = '/^Can not use extended and perl regex/'; | ||
21 | |||
22 | my $result; | ||
23 | my $temp_file = "/tmp/check_log.tmp"; | ||
24 | my $oldlog = "/tmp/oldlog.tmp"; | ||
25 | |||
26 | open(FH, '>', $temp_file) or die $!; | ||
27 | close(FH); | ||
28 | |||
29 | $result = NPTest->testCmd("./check_log"); | ||
30 | cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); | ||
31 | like ( $result->output, $unknownOutput, "Output for unknown correct" ); | ||
32 | |||
33 | $result = NPTest->testCmd("./check_log -f"); | ||
34 | cmp_ok( $result->return_code, '==', 3, "Wrong parameters" ); | ||
35 | like ( $result->output, $unknownArgOutput, "Output for unknown correct" ); | ||
36 | |||
37 | $result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Simple match' -e -p"); | ||
38 | cmp_ok( $result->return_code, '==', 3, "Both regex parameters" ); | ||
39 | like ( $result->output, $bothRegexOutput, "Output for unknown correct" ); | ||
40 | |||
41 | $result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Simple match'"); | ||
42 | cmp_ok( $result->return_code, '==', 0, "First time executing" ); | ||
43 | like ( $result->output, $firstTimeOutput, "Output for first time executing correct" ); | ||
44 | |||
45 | open(FH, '>>', $temp_file) or die $!; | ||
46 | print FH "This is some text, that should not match\n"; | ||
47 | close(FH); | ||
48 | |||
49 | $result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'No match'"); | ||
50 | cmp_ok( $result->return_code, '==', 0, "No match" ); | ||
51 | like ( $result->output, $okOutput, "Output for no match correct" ); | ||
52 | |||
53 | open(FH, '>>', $temp_file) or die $!; | ||
54 | print FH "This text should match\n"; | ||
55 | close(FH); | ||
56 | |||
57 | $result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'should match'"); | ||
58 | cmp_ok( $result->return_code, '==', 2, "Pattern match" ); | ||
59 | like ( $result->output, $criticalOutput, "Output for match correct" ); | ||
60 | |||
61 | open(FH, '>>', $temp_file) or die $!; | ||
62 | print FH "This text should not match, because it is excluded\n"; | ||
63 | close(FH); | ||
64 | |||
65 | $result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'match' --exclude 'because'"); | ||
66 | cmp_ok( $result->return_code, '==', 0, "Exclude a pattern" ); | ||
67 | like ( $result->output, $okOutput, "Output for no match correct" ); | ||
68 | |||
69 | open(FH, '>>', $temp_file) or die $!; | ||
70 | print FH "Trying\nwith\nmultiline\nignore me\n"; | ||
71 | close(FH); | ||
72 | |||
73 | $result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'Trying\\|with\\|multiline\\|ignore' --exclude 'me' --all"); | ||
74 | cmp_ok( $result->return_code, '==', 2, "Multiline pattern match with --all" ); | ||
75 | like ( $result->output, $multilineOutput, "Output for multiline match correct" ); | ||
76 | |||
77 | $result = NPTest->testCmd("./check_log -F ".$temp_file." -O ".$oldlog." -q 'match' -a"); | ||
78 | cmp_ok( $result->return_code, '==', 0, "Non matching --all" ); | ||
79 | like ( $result->output, $okOutput, "Output for no match correct" ); | ||
80 | |||
81 | unlink($oldlog); | ||
82 | unlink($temp_file); | ||
diff --git a/plugins-scripts/t/check_uptime.t b/plugins-scripts/t/check_uptime.t new file mode 100644 index 0000000..6e81db3 --- /dev/null +++ b/plugins-scripts/t/check_uptime.t | |||
@@ -0,0 +1,135 @@ | |||
1 | #!/usr/bin/perl -w -I .. | ||
2 | # | ||
3 | # check_uptime tests | ||
4 | # | ||
5 | # | ||
6 | |||
7 | use strict; | ||
8 | use Test::More tests => 42; | ||
9 | use NPTest; | ||
10 | |||
11 | my $result; | ||
12 | |||
13 | $result = NPTest->testCmd( | ||
14 | "./check_uptime" | ||
15 | ); | ||
16 | cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); | ||
17 | like ( $result->output, '/^Usage: check_uptime -w/', "Output for missing parameters correct" ); | ||
18 | |||
19 | $result = NPTest->testCmd( | ||
20 | "./check_uptime --help" | ||
21 | ); | ||
22 | cmp_ok( $result->return_code, '==', 3, "Help output requested" ); | ||
23 | like ( $result->output, '/ABSOLUTELY NO WARRANTY/', "Output for help correct" ); | ||
24 | |||
25 | $result = NPTest->testCmd( | ||
26 | "./check_uptime -w 5 -c 2" | ||
27 | ); | ||
28 | cmp_ok( $result->return_code, '==', 3, "Warning greater than critical" ); | ||
29 | like ( $result->output, '/^Upper Warning .*cannot be greater than Critical/', "Output for warning greater than critical correct" ); | ||
30 | |||
31 | $result = NPTest->testCmd( | ||
32 | "./check_uptime -c 1000 -W 100 2>&1" | ||
33 | ); | ||
34 | like ( $result->output, '/^Unknown option: W/', "Output with wrong parameter is correct" ); | ||
35 | |||
36 | $result = NPTest->testCmd( | ||
37 | "./check_uptime -f -w 1 -c 2" | ||
38 | ); | ||
39 | cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); | ||
40 | like ( $result->output, '/Running for \d+/', "Output for the f parameter correct" ); | ||
41 | |||
42 | $result = NPTest->testCmd( | ||
43 | "./check_uptime -s -w 1 -c 2" | ||
44 | ); | ||
45 | cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); | ||
46 | like ( $result->output, '/Running since \d+/', "Output for the s parameter correct" ); | ||
47 | |||
48 | $result = NPTest->testCmd( | ||
49 | "./check_uptime -d -w 1 -c 2" | ||
50 | ); | ||
51 | cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); | ||
52 | like ( $result->output, '/CRITICAL: Uptime is \d+ days/', "Output for the d parameter correct" ); | ||
53 | |||
54 | $result = NPTest->testCmd( | ||
55 | "./check_uptime -w 1 -c 2" | ||
56 | ); | ||
57 | cmp_ok( $result->return_code, '==', 2, "Uptime higher than 2 seconds" ); | ||
58 | like ( $result->output, '/^CRITICAL: Uptime is \d+ seconds/', "Output for uptime higher than 2 seconds correct" ); | ||
59 | |||
60 | $result = NPTest->testCmd( | ||
61 | "./check_uptime -w 1 -c 9999w" | ||
62 | ); | ||
63 | cmp_ok( $result->return_code, '==', 1, "Uptime lower than 9999 weeks" ); | ||
64 | like ( $result->output, '/^WARNING: Uptime is \d+ seconds/', "Output for uptime lower than 9999 weeks correct" ); | ||
65 | |||
66 | $result = NPTest->testCmd( | ||
67 | "./check_uptime -w 9998w -c 9999w" | ||
68 | ); | ||
69 | cmp_ok( $result->return_code, '==', 0, "Uptime lower than 9998 weeks" ); | ||
70 | like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 9998 weeks correct" ); | ||
71 | like ( $result->output, '/\|uptime=[0-9]+s;6046790400;6047395200;/', "Checking for performance output" ); | ||
72 | |||
73 | $result = NPTest->testCmd( | ||
74 | "./check_uptime -w 111222d -c 222333d" | ||
75 | ); | ||
76 | cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days" ); | ||
77 | like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 111222 days correct" ); | ||
78 | like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); | ||
79 | |||
80 | # Same as before, hopefully uptime is higher than 2 seconds so no warning | ||
81 | $result = NPTest->testCmd( | ||
82 | "./check_uptime -w 2:111222d -c 1:222333d" | ||
83 | ); | ||
84 | cmp_ok( $result->return_code, '==', 0, "Uptime lower than 111222 days, and higher 2 seconds" ); | ||
85 | like ( $result->output, '/^OK: Uptime is \d+ seconds/', "Output for uptime lower than 111222 days, and higher 2 seconds correct" ); | ||
86 | like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); | ||
87 | |||
88 | # Same as before, now the low warning should trigger | ||
89 | $result = NPTest->testCmd( | ||
90 | "./check_uptime -w 111221d:111222d -c 1:222333d" | ||
91 | ); | ||
92 | cmp_ok( $result->return_code, '==', 1, "Uptime lower than 111221 days raises warning" ); | ||
93 | like ( $result->output, '/^WARNING: Uptime is \d+ seconds/', "Output for uptime lower than 111221 days correct" ); | ||
94 | like ( $result->output, '/Exceeds lower warn threshold/', "Exceeds text correct" ); | ||
95 | like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); | ||
96 | |||
97 | # Same as before, now the low critical should trigger | ||
98 | $result = NPTest->testCmd( | ||
99 | "./check_uptime -w 111221d:111222d -c 111220d:222333d" | ||
100 | ); | ||
101 | cmp_ok( $result->return_code, '==', 2, "Uptime lower than 111220 days raises critical" ); | ||
102 | like ( $result->output, '/^CRITICAL: Uptime is \d+ seconds/', "Output for uptime lower than 111220 days correct" ); | ||
103 | like ( $result->output, '/Exceeds lower crit threshold/', "Exceeds text correct" ); | ||
104 | like ( $result->output, '/\|uptime=[0-9]+s;9609580800;19209571200;/', "Checking for performance output" ); | ||
105 | |||
106 | |||
107 | # | ||
108 | # Range values using ":" without two parts ("a:b") is invalid | ||
109 | # Strings without two parts are always considered as upper threshold | ||
110 | # | ||
111 | |||
112 | $result = NPTest->testCmd( | ||
113 | "./check_uptime -w 2: -c 1:4" | ||
114 | ); | ||
115 | cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" ); | ||
116 | like ( $result->output, '/^Upper warning .* is not numeric/', "Output for wrong parameter format correct" ); | ||
117 | |||
118 | $result = NPTest->testCmd( | ||
119 | "./check_uptime -w 2:3 -c 1:" | ||
120 | ); | ||
121 | cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" ); | ||
122 | like ( $result->output, '/^Upper critical .* is not numeric/', "Output for wrong parameter format correct" ); | ||
123 | |||
124 | $result = NPTest->testCmd( | ||
125 | "./check_uptime -w :3 -c 1:4" | ||
126 | ); | ||
127 | cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" ); | ||
128 | like ( $result->output, '/^Upper warning .* is not numeric/', "Output for wrong parameter format correct" ); | ||
129 | |||
130 | $result = NPTest->testCmd( | ||
131 | "./check_uptime -w 2:3 -c :4" | ||
132 | ); | ||
133 | cmp_ok( $result->return_code, '==', 3, "Wrong parameter format raises unknown" ); | ||
134 | like ( $result->output, '/^Upper critical .* is not numeric/', "Output for wrong parameter format correct" ); | ||
135 | |||
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in index 386831e..c84769f 100644 --- a/plugins-scripts/utils.pm.in +++ b/plugins-scripts/utils.pm.in | |||
@@ -23,6 +23,7 @@ $PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ; | |||
23 | $PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ; | 23 | $PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ; |
24 | $PATH_TO_MAILQ = "@PATH_TO_MAILQ@"; | 24 | $PATH_TO_MAILQ = "@PATH_TO_MAILQ@"; |
25 | $PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@"; | 25 | $PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@"; |
26 | $PATH_TO_SNMPGET = "@PATH_TO_SNMPGET@"; | ||
26 | 27 | ||
27 | ## common variables | 28 | ## common variables |
28 | $TIMEOUT = 15; | 29 | $TIMEOUT = 15; |