diff options
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-x | plugins-scripts/check_breeze.pl | 1 | ||||
-rwxr-xr-x | plugins-scripts/check_disk_smb.pl | 1 | ||||
-rwxr-xr-x | plugins-scripts/check_file_age.pl | 6 | ||||
-rwxr-xr-x | plugins-scripts/check_flexlm.pl | 1 | ||||
-rwxr-xr-x | plugins-scripts/check_ifoperstatus.pl | 1 | ||||
-rwxr-xr-x | plugins-scripts/check_ifstatus.pl | 58 | ||||
-rwxr-xr-x | plugins-scripts/check_ircd.pl | 1 | ||||
-rwxr-xr-x | plugins-scripts/check_log.sh | 7 | ||||
-rwxr-xr-x | plugins-scripts/check_mailq.pl | 35 | ||||
-rwxr-xr-x | plugins-scripts/check_mssql.pl | 1 | ||||
-rwxr-xr-x | plugins-scripts/check_netdns.pl | 3 | ||||
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 5 | ||||
-rwxr-xr-x | plugins-scripts/check_rpc.pl | 1 | ||||
-rwxr-xr-x | plugins-scripts/check_sensors.sh | 5 | ||||
-rwxr-xr-x | plugins-scripts/check_wave.pl | 1 | ||||
-rw-r--r-- | plugins-scripts/t/check_disk_smb.t | 2 | ||||
-rw-r--r-- | plugins-scripts/t/check_file_age.t | 8 | ||||
-rw-r--r-- | plugins-scripts/utils.pm.in | 1 |
18 files changed, 83 insertions, 55 deletions
diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl index 1a3aceb..12a60ee 100755 --- a/plugins-scripts/check_breeze.pl +++ b/plugins-scripts/check_breeze.pl | |||
@@ -6,7 +6,6 @@ use Getopt::Long; | |||
6 | use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME); | 6 | use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME); |
7 | use FindBin; | 7 | use FindBin; |
8 | use lib "$FindBin::Bin"; | 8 | use lib "$FindBin::Bin"; |
9 | use lib '@libexecdir@'; | ||
10 | use utils qw(%ERRORS &print_revision &support &usage); | 9 | use utils qw(%ERRORS &print_revision &support &usage); |
11 | 10 | ||
12 | $PROGNAME = "check_breeze"; | 11 | $PROGNAME = "check_breeze"; |
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl index 4805434..99948a4 100755 --- a/plugins-scripts/check_disk_smb.pl +++ b/plugins-scripts/check_disk_smb.pl | |||
@@ -26,7 +26,6 @@ use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_ | |||
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 lib '@libexecdir@'; | ||
30 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | 29 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); |
31 | 30 | ||
32 | sub print_help (); | 31 | sub print_help (); |
diff --git a/plugins-scripts/check_file_age.pl b/plugins-scripts/check_file_age.pl index 453e0f5..15330f7 100755 --- a/plugins-scripts/check_file_age.pl +++ b/plugins-scripts/check_file_age.pl | |||
@@ -27,14 +27,13 @@ use File::stat; | |||
27 | use vars qw($PROGNAME); | 27 | use vars qw($PROGNAME); |
28 | use FindBin; | 28 | use FindBin; |
29 | use lib "$FindBin::Bin"; | 29 | use lib "$FindBin::Bin"; |
30 | use lib '@libexecdir@'; | ||
31 | use utils qw (%ERRORS &print_revision &support); | 30 | use utils qw (%ERRORS &print_revision &support); |
32 | 31 | ||
33 | sub print_help (); | 32 | sub print_help (); |
34 | sub print_usage (); | 33 | sub print_usage (); |
35 | 34 | ||
36 | my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i); | 35 | my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i); |
37 | my ($result, $message, $age, $size, $st); | 36 | my ($result, $message, $age, $size, $st, $perfdata); |
38 | 37 | ||
39 | $PROGNAME="check_file_age"; | 38 | $PROGNAME="check_file_age"; |
40 | 39 | ||
@@ -92,6 +91,7 @@ unless (-e $opt_f) { | |||
92 | $st = File::stat::stat($opt_f); | 91 | $st = File::stat::stat($opt_f); |
93 | $age = time - $st->mtime; | 92 | $age = time - $st->mtime; |
94 | $size = $st->size; | 93 | $size = $st->size; |
94 | $perfdata = "age=${age}s;${opt_w};${opt_c} size=${size}B;${opt_W};${opt_C};0"; | ||
95 | 95 | ||
96 | 96 | ||
97 | $result = 'OK'; | 97 | $result = 'OK'; |
@@ -103,7 +103,7 @@ elsif (($opt_w and $age > $opt_w) or ($opt_W and $size < $opt_W)) { | |||
103 | $result = 'WARNING'; | 103 | $result = 'WARNING'; |
104 | } | 104 | } |
105 | 105 | ||
106 | print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes\n"; | 106 | print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes | $perfdata\n"; |
107 | exit $ERRORS{$result}; | 107 | exit $ERRORS{$result}; |
108 | 108 | ||
109 | sub print_usage () { | 109 | sub print_usage () { |
diff --git a/plugins-scripts/check_flexlm.pl b/plugins-scripts/check_flexlm.pl index 5f3ed59..49d674d 100755 --- a/plugins-scripts/check_flexlm.pl +++ b/plugins-scripts/check_flexlm.pl | |||
@@ -37,7 +37,6 @@ use Getopt::Long; | |||
37 | use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME); | 37 | use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME); |
38 | use FindBin; | 38 | use FindBin; |
39 | use lib "$FindBin::Bin"; | 39 | use lib "$FindBin::Bin"; |
40 | use lib '@libexecdir@'; | ||
41 | use utils qw(%ERRORS &print_revision &support &usage); | 40 | use utils qw(%ERRORS &print_revision &support &usage); |
42 | 41 | ||
43 | $PROGNAME="check_flexlm"; | 42 | $PROGNAME="check_flexlm"; |
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl index cf2c7b5..1a7fbba 100755 --- a/plugins-scripts/check_ifoperstatus.pl +++ b/plugins-scripts/check_ifoperstatus.pl | |||
@@ -37,7 +37,6 @@ use POSIX; | |||
37 | use strict; | 37 | use strict; |
38 | use FindBin; | 38 | use FindBin; |
39 | use lib "$FindBin::Bin"; | 39 | use lib "$FindBin::Bin"; |
40 | use lib '@libexecdir@'; | ||
41 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 40 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
42 | 41 | ||
43 | use Net::SNMP; | 42 | use Net::SNMP; |
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl index 709ad17..2c76d0c 100755 --- a/plugins-scripts/check_ifstatus.pl +++ b/plugins-scripts/check_ifstatus.pl | |||
@@ -9,6 +9,7 @@ | |||
9 | # Added -u option (4/2003) | 9 | # Added -u option (4/2003) |
10 | # Added -M option (10/2003) | 10 | # Added -M option (10/2003) |
11 | # Added SNMPv3 support (10/2003) | 11 | # Added SNMPv3 support (10/2003) |
12 | # Added -n option (07/2014) | ||
12 | # | 13 | # |
13 | # This program is free software; you can redistribute it and/or | 14 | # This program is free software; you can redistribute it and/or |
14 | # modify it under the terms of the GNU General Public License | 15 | # modify it under the terms of the GNU General Public License |
@@ -34,7 +35,6 @@ use POSIX; | |||
34 | use strict; | 35 | use strict; |
35 | use FindBin; | 36 | use FindBin; |
36 | use lib "$FindBin::Bin"; | 37 | use lib "$FindBin::Bin"; |
37 | use lib '@libexecdir@'; | ||
38 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 38 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
39 | 39 | ||
40 | use Net::SNMP; | 40 | use Net::SNMP; |
@@ -95,8 +95,10 @@ my $ifXTable; | |||
95 | my $opt_h ; | 95 | my $opt_h ; |
96 | my $opt_V ; | 96 | my $opt_V ; |
97 | my $opt_u; | 97 | my $opt_u; |
98 | my $opt_n; | ||
98 | my $opt_x ; | 99 | my $opt_x ; |
99 | my %excluded ; | 100 | my %excluded ; |
101 | my %unused_names ; | ||
100 | my @unused_ports ; | 102 | my @unused_ports ; |
101 | my %session_opts; | 103 | my %session_opts; |
102 | 104 | ||
@@ -171,27 +173,30 @@ alarm(0); | |||
171 | foreach $key (keys %ifStatus) { | 173 | foreach $key (keys %ifStatus) { |
172 | 174 | ||
173 | # skip unused interfaces | 175 | # skip unused interfaces |
174 | if (!defined($ifStatus{$key}{'notInUse'})) { | 176 | my $ifName = $ifStatus{$key}{$snmpIfDescr}; |
177 | |||
178 | if (!defined($ifStatus{$key}{'notInUse'}) && !grep(/^${ifName}/, @unused_ports )) { | ||
175 | # check only if interface is administratively up | 179 | # check only if interface is administratively up |
176 | if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) { | 180 | if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) { |
177 | 181 | #check only if interface is not excluded | |
178 | # check only if interface type is not listed in %excluded | 182 | if (!defined $unused_names{$ifStatus{$key}{$snmpIfDescr}} ) { |
179 | if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) { | 183 | # check only if interface type is not listed in %excluded |
180 | if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ;} | 184 | if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) { |
181 | if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) { | 185 | if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ; } |
182 | $ifdown++ ; | 186 | if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) { |
183 | if (defined $ifXTable) { | 187 | $ifdown++ ; |
184 | $ifmessage .= sprintf("%s: down -> %s<BR>", | 188 | if (defined $ifXTable) { |
185 | $ifStatus{$key}{$snmpIfName}, | 189 | $ifmessage .= sprintf("%s: down -> %s<BR>\n", $ifStatus{$key}{$snmpIfName}, $ifStatus{$key}{$snmpIfAlias}); |
186 | $ifStatus{$key}{$snmpIfAlias}); | 190 | }else{ |
187 | }else{ | 191 | $ifmessage .= sprintf("%s: down <BR>\n",$ifStatus{$key}{$snmpIfDescr}); |
188 | $ifmessage .= sprintf("%s: down <BR>", | 192 | } |
189 | $ifStatus{$key}{$snmpIfDescr}); | 193 | } |
190 | } | 194 | if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;} |
195 | } else { | ||
196 | $ifexclude++; | ||
191 | } | 197 | } |
192 | if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;} | 198 | } else { |
193 | }else{ | 199 | $ifunused++; |
194 | $ifexclude++; | ||
195 | } | 200 | } |
196 | 201 | ||
197 | } | 202 | } |
@@ -259,6 +264,8 @@ sub print_help() { | |||
259 | printf " the descriptive name. Do not use if you don't know what this is. \n"; | 264 | printf " the descriptive name. Do not use if you don't know what this is. \n"; |
260 | printf " -x (--exclude) A comma separated list of ifType values that should be excluded \n"; | 265 | printf " -x (--exclude) A comma separated list of ifType values that should be excluded \n"; |
261 | printf " from the report (default for an empty list is PPP(23).\n"; | 266 | printf " from the report (default for an empty list is PPP(23).\n"; |
267 | printf " -n (--unused_ports_by_name) A comma separated list of ifDescr values that should be excluded \n"; | ||
268 | printf " from the report (default is an empty exclusion list).\n"; | ||
262 | printf " -u (--unused_ports) A comma separated list of ifIndex values that should be excluded \n"; | 269 | printf " -u (--unused_ports) A comma separated list of ifIndex values that should be excluded \n"; |
263 | printf " from the report (default is an empty exclusion list).\n"; | 270 | printf " from the report (default is an empty exclusion list).\n"; |
264 | printf " See the IANAifType-MIB for a list of interface types.\n"; | 271 | printf " See the IANAifType-MIB for a list of interface types.\n"; |
@@ -299,6 +306,7 @@ sub process_arguments() { | |||
299 | "I" => \$ifXTable, "ifmib" => \$ifXTable, | 306 | "I" => \$ifXTable, "ifmib" => \$ifXTable, |
300 | "x:s" => \$opt_x, "exclude:s" => \$opt_x, | 307 | "x:s" => \$opt_x, "exclude:s" => \$opt_x, |
301 | "u=s" => \$opt_u, "unused_ports=s" => \$opt_u, | 308 | "u=s" => \$opt_u, "unused_ports=s" => \$opt_u, |
309 | "n=s" => \$opt_n, "unused_ports_by_name=s" => \$opt_n, | ||
302 | "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize, | 310 | "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize, |
303 | "t=i" => \$timeout, "timeout=i" => \$timeout, | 311 | "t=i" => \$timeout, "timeout=i" => \$timeout, |
304 | ); | 312 | ); |
@@ -406,6 +414,16 @@ sub process_arguments() { | |||
406 | } | 414 | } |
407 | } | 415 | } |
408 | 416 | ||
417 | # Excluded interface descriptors | ||
418 | if (defined $opt_n) { | ||
419 | my @unused = split(/,/,$opt_n); | ||
420 | if ( @unused ) { | ||
421 | foreach $key (@unused) { | ||
422 | $unused_names{$key} = 1; | ||
423 | } | ||
424 | } | ||
425 | } | ||
426 | |||
409 | # Excluded interface ports (ifIndex) - management reasons | 427 | # Excluded interface ports (ifIndex) - management reasons |
410 | if ($opt_u) { | 428 | if ($opt_u) { |
411 | @unused_ports = split(/,/,$opt_u); | 429 | @unused_ports = split(/,/,$opt_u); |
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl index 6d40cf5..afedfb9 100755 --- a/plugins-scripts/check_ircd.pl +++ b/plugins-scripts/check_ircd.pl | |||
@@ -51,7 +51,6 @@ use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose); | |||
51 | use vars qw($PROGNAME); | 51 | use vars qw($PROGNAME); |
52 | use FindBin; | 52 | use FindBin; |
53 | use lib "$FindBin::Bin"; | 53 | use lib "$FindBin::Bin"; |
54 | use lib '@libexecdir@'; | ||
55 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | 54 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); |
56 | 55 | ||
57 | # ----------------------------------------------------[ Function Prototypes ]-- | 56 | # ----------------------------------------------------[ Function Prototypes ]-- |
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh index 8653a5e..d28c8d0 100755 --- a/plugins-scripts/check_log.sh +++ b/plugins-scripts/check_log.sh | |||
@@ -58,12 +58,11 @@ | |||
58 | # Paths to commands used in this script. These | 58 | # Paths to commands used in this script. These |
59 | # may have to be modified to match your system setup. | 59 | # may have to be modified to match your system setup. |
60 | 60 | ||
61 | PROGNAME=`/bin/basename $0` | ||
62 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | ||
63 | REVISION="@NP_VERSION@" | ||
64 | PATH="@TRUSTED_PATH@" | 61 | PATH="@TRUSTED_PATH@" |
65 | |||
66 | export PATH | 62 | export PATH |
63 | PROGNAME=`basename $0` | ||
64 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | ||
65 | REVISION="@NP_VERSION@" | ||
67 | 66 | ||
68 | . $PROGPATH/utils.sh | 67 | . $PROGPATH/utils.sh |
69 | 68 | ||
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl index bd78981..3086e94 100755 --- a/plugins-scripts/check_mailq.pl +++ b/plugins-scripts/check_mailq.pl | |||
@@ -28,14 +28,14 @@ | |||
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 | 31 | use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s |
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 @lines |
33 | %srcdomains %dstdomains); | 33 | %srcdomains %dstdomains); |
34 | use FindBin; | 34 | use FindBin; |
35 | use lib "$FindBin::Bin"; | 35 | use lib "$FindBin::Bin"; |
36 | use lib '@libexecdir@'; | ||
37 | use utils qw(%ERRORS &print_revision &support &usage ); | 36 | use utils qw(%ERRORS &print_revision &support &usage ); |
38 | 37 | ||
38 | my ($sudo); | ||
39 | 39 | ||
40 | sub print_help (); | 40 | sub print_help (); |
41 | sub print_usage (); | 41 | sub print_usage (); |
@@ -57,6 +57,17 @@ if ($status){ | |||
57 | exit $ERRORS{"UNKNOWN"}; | 57 | exit $ERRORS{"UNKNOWN"}; |
58 | } | 58 | } |
59 | 59 | ||
60 | if ($opt_s) { | ||
61 | if (defined $utils::PATH_TO_SUDO && -x $utils::PATH_TO_SUDO) { | ||
62 | $sudo = $utils::PATH_TO_SUDO; | ||
63 | } else { | ||
64 | print "ERROR: Cannot execute sudo\n"; | ||
65 | exit $ERRORS{'UNKNOWN'}; | ||
66 | } | ||
67 | } else { | ||
68 | $sudo = ""; | ||
69 | } | ||
70 | |||
60 | $SIG{'ALRM'} = sub { | 71 | $SIG{'ALRM'} = sub { |
61 | print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n"); | 72 | print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n"); |
62 | exit $ERRORS{"WARNING"}; | 73 | exit $ERRORS{"WARNING"}; |
@@ -69,7 +80,7 @@ if ($mailq eq "sendmail") { | |||
69 | 80 | ||
70 | ## open mailq | 81 | ## open mailq |
71 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | 82 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { |
72 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | 83 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { |
73 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | 84 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; |
74 | exit $ERRORS{'UNKNOWN'}; | 85 | exit $ERRORS{'UNKNOWN'}; |
75 | } | 86 | } |
@@ -298,7 +309,7 @@ elsif ( $mailq eq "postfix" ) { | |||
298 | 309 | ||
299 | ## open mailq | 310 | ## open mailq |
300 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | 311 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { |
301 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | 312 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { |
302 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | 313 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; |
303 | exit $ERRORS{'UNKNOWN'}; | 314 | exit $ERRORS{'UNKNOWN'}; |
304 | } | 315 | } |
@@ -332,7 +343,7 @@ elsif ( $mailq eq "postfix" ) { | |||
332 | }elsif ($lines[0]=~/Mail queue is empty/) { | 343 | }elsif ($lines[0]=~/Mail queue is empty/) { |
333 | $msg_q = 0; | 344 | $msg_q = 0; |
334 | }else{ | 345 | }else{ |
335 | print "Couldn't match $utils::PATH_TO_QMAIL_QSTAT output\n"; | 346 | print "Couldn't match $utils::PATH_TO_MAILQ output\n"; |
336 | exit $ERRORS{'UNKNOWN'}; | 347 | exit $ERRORS{'UNKNOWN'}; |
337 | } | 348 | } |
338 | 349 | ||
@@ -340,7 +351,7 @@ elsif ( $mailq eq "postfix" ) { | |||
340 | #if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) { | 351 | #if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) { |
341 | # my $msg_p = $1; | 352 | # my $msg_p = $1; |
342 | #}else{ | 353 | #}else{ |
343 | # print "Couldn't match $utils::PATH_TO_QMAIL_QSTAT output\n"; | 354 | # print "Couldn't match $utils::PATH_TO_MAILQ output\n"; |
344 | # exit $ERRORS{'UNKNOWN'}; | 355 | # exit $ERRORS{'UNKNOWN'}; |
345 | #} | 356 | #} |
346 | 357 | ||
@@ -380,7 +391,7 @@ elsif ( $mailq eq "qmail" ) { | |||
380 | 391 | ||
381 | # open qmail-qstat | 392 | # open qmail-qstat |
382 | if ( defined $utils::PATH_TO_QMAIL_QSTAT && -x $utils::PATH_TO_QMAIL_QSTAT ) { | 393 | if ( defined $utils::PATH_TO_QMAIL_QSTAT && -x $utils::PATH_TO_QMAIL_QSTAT ) { |
383 | if (! open (MAILQ, "$utils::PATH_TO_QMAIL_QSTAT | " ) ) { | 394 | if (! open (MAILQ, "$sudo $utils::PATH_TO_QMAIL_QSTAT | " ) ) { |
384 | print "ERROR: could not open $utils::PATH_TO_QMAIL_QSTAT \n"; | 395 | print "ERROR: could not open $utils::PATH_TO_QMAIL_QSTAT \n"; |
385 | exit $ERRORS{'UNKNOWN'}; | 396 | exit $ERRORS{'UNKNOWN'}; |
386 | } | 397 | } |
@@ -462,7 +473,7 @@ elsif ( $mailq eq "qmail" ) { | |||
462 | elsif ( $mailq eq "exim" ) { | 473 | elsif ( $mailq eq "exim" ) { |
463 | ## open mailq | 474 | ## open mailq |
464 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | 475 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { |
465 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | 476 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { |
466 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | 477 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; |
467 | exit $ERRORS{'UNKNOWN'}; | 478 | exit $ERRORS{'UNKNOWN'}; |
468 | } | 479 | } |
@@ -505,7 +516,7 @@ elsif ( $mailq eq "exim" ) { | |||
505 | elsif ( $mailq eq "nullmailer" ) { | 516 | elsif ( $mailq eq "nullmailer" ) { |
506 | ## open mailq | 517 | ## open mailq |
507 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | 518 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { |
508 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | 519 | if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) { |
509 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | 520 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; |
510 | exit $ERRORS{'UNKNOWN'}; | 521 | exit $ERRORS{'UNKNOWN'}; |
511 | } | 522 | } |
@@ -556,7 +567,8 @@ sub process_arguments(){ | |||
556 | "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail) | 567 | "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail) |
557 | "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number | 568 | "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number |
558 | "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number | 569 | "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number |
559 | "t=i" => \$opt_t, "timeout=i" => \$opt_t | 570 | "t=i" => \$opt_t, "timeout=i" => \$opt_t, |
571 | "s" => \$opt_s, "sudo" => \$opt_s | ||
560 | ); | 572 | ); |
561 | 573 | ||
562 | if ($opt_V) { | 574 | if ($opt_V) { |
@@ -637,7 +649,7 @@ sub process_arguments(){ | |||
637 | } | 649 | } |
638 | 650 | ||
639 | sub print_usage () { | 651 | sub print_usage () { |
640 | print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-v verbose]\n"; | 652 | print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-v]\n"; |
641 | } | 653 | } |
642 | 654 | ||
643 | sub print_help () { | 655 | sub print_help () { |
@@ -654,6 +666,7 @@ sub print_help () { | |||
654 | print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; | 666 | print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; |
655 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; | 667 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; |
656 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; | 668 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; |
669 | print "-s (--sudo) = Use sudo to call the mailq command\n"; | ||
657 | print "-h (--help)\n"; | 670 | print "-h (--help)\n"; |
658 | print "-V (--version)\n"; | 671 | print "-V (--version)\n"; |
659 | print "-v (--verbose) = debugging output\n"; | 672 | print "-v (--verbose) = debugging output\n"; |
diff --git a/plugins-scripts/check_mssql.pl b/plugins-scripts/check_mssql.pl index 1f38788..a436a8f 100755 --- a/plugins-scripts/check_mssql.pl +++ b/plugins-scripts/check_mssql.pl | |||
@@ -31,7 +31,6 @@ use DBD::Sybase; | |||
31 | use Getopt::Long; | 31 | use Getopt::Long; |
32 | use FindBin; | 32 | use FindBin; |
33 | use lib "$FindBin::Bin"; | 33 | use lib "$FindBin::Bin"; |
34 | use lib '@libexecdir@'; | ||
35 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 34 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
36 | use strict; | 35 | use strict; |
37 | 36 | ||
diff --git a/plugins-scripts/check_netdns.pl b/plugins-scripts/check_netdns.pl index 59c81a9..af1456b 100755 --- a/plugins-scripts/check_netdns.pl +++ b/plugins-scripts/check_netdns.pl | |||
@@ -29,8 +29,7 @@ use Getopt::Long; | |||
29 | use Net::DNS; | 29 | use Net::DNS; |
30 | use FindBin; | 30 | use FindBin; |
31 | use lib "$FindBin::Bin"; | 31 | use lib "$FindBin::Bin"; |
32 | use lib '@libexecdir@'; | 32 | use utils; |
33 | use utils ; | ||
34 | 33 | ||
35 | my $PROGNAME = "check_netdns"; | 34 | my $PROGNAME = "check_netdns"; |
36 | 35 | ||
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index ceac95d..96078ac 100755 --- a/plugins-scripts/check_oracle.sh +++ b/plugins-scripts/check_oracle.sh | |||
@@ -6,10 +6,11 @@ | |||
6 | # This Monitoring plugin was created to check Oracle status | 6 | # This Monitoring plugin was created to check Oracle status |
7 | # | 7 | # |
8 | 8 | ||
9 | PATH="@TRUSTED_PATH@" | ||
10 | export PATH | ||
9 | PROGNAME=`basename $0` | 11 | PROGNAME=`basename $0` |
10 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 12 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` |
11 | REVISION="@NP_VERSION@" | 13 | REVISION="@NP_VERSION@" |
12 | PATH="@TRUSTED_PATH@" | ||
13 | 14 | ||
14 | . $PROGPATH/utils.sh | 15 | . $PROGPATH/utils.sh |
15 | 16 | ||
@@ -137,7 +138,7 @@ case "$cmd" in | |||
137 | tnschk=` tnsping $2` | 138 | tnschk=` tnsping $2` |
138 | tnschk2=` echo $tnschk | grep -c OK` | 139 | tnschk2=` echo $tnschk | grep -c OK` |
139 | if [ ${tnschk2} -eq 1 ] ; then | 140 | if [ ${tnschk2} -eq 1 ] ; then |
140 | tnschk3=` echo $tnschk | sed -e 's/.*(//' -e 's/).*//'` | 141 | tnschk3=${tnschk##*(}; tnschk3=${tnschk3%)*} |
141 | echo "OK - reply time ${tnschk3} from $2" | 142 | echo "OK - reply time ${tnschk3} from $2" |
142 | exit $STATE_OK | 143 | exit $STATE_OK |
143 | else | 144 | else |
diff --git a/plugins-scripts/check_rpc.pl b/plugins-scripts/check_rpc.pl index b1c6147..cbdeceb 100755 --- a/plugins-scripts/check_rpc.pl +++ b/plugins-scripts/check_rpc.pl | |||
@@ -22,7 +22,6 @@ | |||
22 | use strict; | 22 | use strict; |
23 | use FindBin; | 23 | use FindBin; |
24 | use lib "$FindBin::Bin"; | 24 | use lib "$FindBin::Bin"; |
25 | use lib '@libexecdir@'; | ||
26 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 25 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
27 | use vars qw($PROGNAME); | 26 | use vars qw($PROGNAME); |
28 | my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state); | 27 | my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state); |
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh index 05c64c4..f742830 100755 --- a/plugins-scripts/check_sensors.sh +++ b/plugins-scripts/check_sensors.sh | |||
@@ -1,11 +1,10 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | PATH="@TRUSTED_PATH@" | ||
4 | export PATH | ||
3 | PROGNAME=`basename $0` | 5 | PROGNAME=`basename $0` |
4 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 6 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` |
5 | REVISION="@NP_VERSION@" | 7 | REVISION="@NP_VERSION@" |
6 | PATH="@TRUSTED_PATH@" | ||
7 | |||
8 | export PATH | ||
9 | 8 | ||
10 | . $PROGPATH/utils.sh | 9 | . $PROGPATH/utils.sh |
11 | 10 | ||
diff --git a/plugins-scripts/check_wave.pl b/plugins-scripts/check_wave.pl index ee0fda4..979416e 100755 --- a/plugins-scripts/check_wave.pl +++ b/plugins-scripts/check_wave.pl | |||
@@ -5,7 +5,6 @@ | |||
5 | use strict; | 5 | use strict; |
6 | use FindBin; | 6 | use FindBin; |
7 | use lib "$FindBin::Bin"; | 7 | use lib "$FindBin::Bin"; |
8 | use lib '@libexecdir@'; | ||
9 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 8 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
10 | use vars qw($PROGNAME); | 9 | use vars qw($PROGNAME); |
11 | use Getopt::Long; | 10 | use Getopt::Long; |
diff --git a/plugins-scripts/t/check_disk_smb.t b/plugins-scripts/t/check_disk_smb.t index 831f388..c2e8bbb 100644 --- a/plugins-scripts/t/check_disk_smb.t +++ b/plugins-scripts/t/check_disk_smb.t | |||
@@ -90,7 +90,7 @@ SKIP: { | |||
90 | SKIP: { | 90 | SKIP: { |
91 | skip "no non responsive host defined", 1 if ( ! $host_nonresponsive ); | 91 | skip "no non responsive host defined", 1 if ( ! $host_nonresponsive ); |
92 | $res = NPTest->testCmd( "./$plugin -H $host_nonresponsive -s np_foobar "); | 92 | $res = NPTest->testCmd( "./$plugin -H $host_nonresponsive -s np_foobar "); |
93 | cmp_ok( $res->return_code, '==', 3, "Exit UNKNOWN with non responsive host" ); | 93 | cmp_ok( $res->return_code, '>=', 2, "Exit CRITICAL/UNKNOWN with non responsive host" ); |
94 | } | 94 | } |
95 | 95 | ||
96 | } | 96 | } |
diff --git a/plugins-scripts/t/check_file_age.t b/plugins-scripts/t/check_file_age.t index a515649..50a2e69 100644 --- a/plugins-scripts/t/check_file_age.t +++ b/plugins-scripts/t/check_file_age.t | |||
@@ -5,13 +5,14 @@ | |||
5 | # | 5 | # |
6 | 6 | ||
7 | use strict; | 7 | use strict; |
8 | use Test::More tests => 16; | 8 | use Test::More tests => 17; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | my $successOutput = '/^FILE_AGE OK: /'; | 11 | my $successOutput = '/^FILE_AGE OK: /'; |
12 | my $warningOutput = '/^FILE_AGE WARNING: /'; | 12 | my $warningOutput = '/^FILE_AGE WARNING: /'; |
13 | my $criticalOutput = '/^FILE_AGE CRITICAL: /'; | 13 | my $criticalOutput = '/^FILE_AGE CRITICAL: /'; |
14 | my $unknownOutput = '/^FILE_AGE UNKNOWN: /'; | 14 | my $unknownOutput = '/^FILE_AGE UNKNOWN: /'; |
15 | my $performanceOutput = '/ \| age=[0-9]+s;[0-9]+;[0-9]+ size=[0-9]+B;[0-9]+;[0-9]+;0$/'; | ||
15 | 16 | ||
16 | my $result; | 17 | my $result; |
17 | my $temp_file = "/tmp/check_file_age.tmp"; | 18 | my $temp_file = "/tmp/check_file_age.tmp"; |
@@ -58,6 +59,11 @@ $result = NPTest->testCmd( | |||
58 | cmp_ok( $result->return_code, '==', 0, "Checking file size" ); | 59 | cmp_ok( $result->return_code, '==', 0, "Checking file size" ); |
59 | 60 | ||
60 | $result = NPTest->testCmd( | 61 | $result = NPTest->testCmd( |
62 | "./check_file_age -f $temp_file -c 1000 -W 100" | ||
63 | ); | ||
64 | like( $result->output, $performanceOutput, "Checking for performance Output" ); | ||
65 | |||
66 | $result = NPTest->testCmd( | ||
61 | "./check_file_age -f /non/existent --ignore-missing" | 67 | "./check_file_age -f /non/existent --ignore-missing" |
62 | ); | 68 | ); |
63 | cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); | 69 | cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); |
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in index 0f53243..386831e 100644 --- a/plugins-scripts/utils.pm.in +++ b/plugins-scripts/utils.pm.in | |||
@@ -17,6 +17,7 @@ sub support(); | |||
17 | sub is_hostname; | 17 | sub is_hostname; |
18 | 18 | ||
19 | ## updated by autoconf | 19 | ## updated by autoconf |
20 | $PATH_TO_SUDO = "@PATH_TO_SUDO@"; | ||
20 | $PATH_TO_RPCINFO = "@PATH_TO_RPCINFO@" ; | 21 | $PATH_TO_RPCINFO = "@PATH_TO_RPCINFO@" ; |
21 | $PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ; | 22 | $PATH_TO_LMSTAT = "@PATH_TO_LMSTAT@" ; |
22 | $PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ; | 23 | $PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ; |