diff options
Diffstat (limited to 'plugins-scripts')
-rw-r--r-- | plugins-scripts/Makefile.am | 11 | ||||
-rwxr-xr-x | plugins-scripts/check_breeze.pl | 7 | ||||
-rwxr-xr-x | plugins-scripts/check_disk_smb.pl | 13 | ||||
-rwxr-xr-x | plugins-scripts/check_file_age.pl | 31 | ||||
-rwxr-xr-x | plugins-scripts/check_flexlm.pl | 11 | ||||
-rwxr-xr-x | plugins-scripts/check_ifoperstatus.pl | 22 | ||||
-rwxr-xr-x | plugins-scripts/check_ifstatus.pl | 20 | ||||
-rwxr-xr-x | plugins-scripts/check_ircd.pl | 17 | ||||
-rwxr-xr-x | plugins-scripts/check_log.sh | 58 | ||||
-rwxr-xr-x | plugins-scripts/check_mailq.pl | 109 | ||||
-rwxr-xr-x | plugins-scripts/check_mssql.pl | 15 | ||||
-rwxr-xr-x | plugins-scripts/check_netdns.pl | 9 | ||||
-rwxr-xr-x | plugins-scripts/check_ntp.pl | 4 | ||||
-rwxr-xr-x | plugins-scripts/check_oracle.sh | 5 | ||||
-rwxr-xr-x | plugins-scripts/check_rpc.pl | 13 | ||||
-rwxr-xr-x | plugins-scripts/check_sensors.sh | 6 | ||||
-rwxr-xr-x | plugins-scripts/check_wave.pl | 7 | ||||
-rw-r--r-- | plugins-scripts/subst.in | 78 | ||||
-rw-r--r-- | plugins-scripts/t/check_file_age.t | 7 | ||||
-rw-r--r-- | plugins-scripts/utils.pm.in | 4 | ||||
-rw-r--r-- | plugins-scripts/utils.sh.in | 10 |
21 files changed, 238 insertions, 219 deletions
diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am index 58db060..78a950c 100644 --- a/plugins-scripts/Makefile.am +++ b/plugins-scripts/Makefile.am | |||
@@ -19,10 +19,15 @@ libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \ | |||
19 | utils.sh utils.pm | 19 | utils.sh utils.pm |
20 | 20 | ||
21 | EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \ | 21 | EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \ |
22 | check_log.sh check_ntp.pl check_oracle.sh check_rpc.pl check_sensors.sh \ | 22 | 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 \ | 23 | check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \ |
24 | utils.sh.in utils.pm.in t | 24 | utils.sh.in utils.pm.in t |
25 | 25 | ||
26 | EDIT = sed \ | ||
27 | -e 's|[@]NP_VERSION[@]|$(NP_VERSION)|g' \ | ||
28 | -e 's|[@]TRUSTED_PATH[@]|$(with_trusted_path)|g' \ | ||
29 | -e 's|[@]PERL[@]|$(PERL)|g' | ||
30 | |||
26 | TESTS_ENVIRONMENT=perl -I $(top_builddir) -I $(top_srcdir) | 31 | TESTS_ENVIRONMENT=perl -I $(top_builddir) -I $(top_srcdir) |
27 | 32 | ||
28 | TESTS = @SCRIPT_TEST@ | 33 | TESTS = @SCRIPT_TEST@ |
@@ -38,11 +43,11 @@ test-debug: | |||
38 | CLEANFILES=$(libexec_SCRIPTS) | 43 | CLEANFILES=$(libexec_SCRIPTS) |
39 | 44 | ||
40 | .pl : | 45 | .pl : |
41 | NP_VERSION=$(NP_VERSION) $(AWK) -f ./subst $< > $@ | 46 | $(EDIT) $< > $@ |
42 | chmod +x $@ | 47 | chmod +x $@ |
43 | 48 | ||
44 | .sh : | 49 | .sh : |
45 | NP_VERSION=$(NP_VERSION) $(AWK) -f ./subst $< > $@ | 50 | $(EDIT) $< > $@ |
46 | chmod +x $@ | 51 | chmod +x $@ |
47 | 52 | ||
48 | clean-local: | 53 | clean-local: |
diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl index a4e8542..12a60ee 100755 --- a/plugins-scripts/check_breeze.pl +++ b/plugins-scripts/check_breeze.pl | |||
@@ -1,10 +1,11 @@ | |||
1 | #!/usr/bin/perl -wT | 1 | #!@PERL@ -w |
2 | 2 | ||
3 | 3 | ||
4 | use strict; | 4 | use strict; |
5 | use Getopt::Long; | 5 | 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 lib utils.pm ; | 7 | use FindBin; |
8 | use lib "$FindBin::Bin"; | ||
8 | use utils qw(%ERRORS &print_revision &support &usage); | 9 | use utils qw(%ERRORS &print_revision &support &usage); |
9 | 10 | ||
10 | $PROGNAME = "check_breeze"; | 11 | $PROGNAME = "check_breeze"; |
@@ -12,7 +13,7 @@ $PROGNAME = "check_breeze"; | |||
12 | sub print_help (); | 13 | sub print_help (); |
13 | sub print_usage (); | 14 | sub print_usage (); |
14 | 15 | ||
15 | $ENV{'PATH'}=''; | 16 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
16 | $ENV{'BASH_ENV'}=''; | 17 | $ENV{'BASH_ENV'}=''; |
17 | $ENV{'ENV'}=''; | 18 | $ENV{'ENV'}=''; |
18 | 19 | ||
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl index 0c89db5..99948a4 100755 --- a/plugins-scripts/check_disk_smb.pl +++ b/plugins-scripts/check_disk_smb.pl | |||
@@ -1,9 +1,9 @@ | |||
1 | #!/usr/bin/perl -w | 1 | #!@PERL@ -w |
2 | # | 2 | # |
3 | # | 3 | # |
4 | # check_disk.pl <host> <share> <user> <pass> [warn] [critical] [port] | 4 | # check_disk.pl <host> <share> <user> <pass> [warn] [critical] [port] |
5 | # | 5 | # |
6 | # Nagios host script to get the disk usage from a SMB share | 6 | # Monitoring host script to get the disk usage from a SMB share |
7 | # | 7 | # |
8 | # Changes and Modifications | 8 | # Changes and Modifications |
9 | # ========================= | 9 | # ========================= |
@@ -24,7 +24,8 @@ 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 $verbose); |
26 | use vars qw($PROGNAME); | 26 | use vars qw($PROGNAME); |
27 | use lib utils.pm ; | 27 | use FindBin; |
28 | use lib "$FindBin::Bin"; | ||
28 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | 29 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); |
29 | 30 | ||
30 | sub print_help (); | 31 | sub print_help (); |
@@ -32,7 +33,7 @@ sub print_usage (); | |||
32 | 33 | ||
33 | $PROGNAME = "check_disk_smb"; | 34 | $PROGNAME = "check_disk_smb"; |
34 | 35 | ||
35 | $ENV{'PATH'}=''; | 36 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
36 | $ENV{'BASH_ENV'}=''; | 37 | $ENV{'BASH_ENV'}=''; |
37 | $ENV{'ENV'}=''; | 38 | $ENV{'ENV'}=''; |
38 | 39 | ||
@@ -171,7 +172,7 @@ my $res = undef; | |||
171 | my $perfdata = ""; | 172 | my $perfdata = ""; |
172 | my @lines = undef; | 173 | my @lines = undef; |
173 | 174 | ||
174 | # Just in case of problems, let's not hang Nagios | 175 | # Just in case of problems, let's not hang the monitoring system |
175 | $SIG{'ALRM'} = sub { | 176 | $SIG{'ALRM'} = sub { |
176 | print "No Answer from Client\n"; | 177 | print "No Answer from Client\n"; |
177 | exit $ERRORS{"UNKNOWN"}; | 178 | exit $ERRORS{"UNKNOWN"}; |
@@ -293,7 +294,7 @@ sub print_help () { | |||
293 | print_revision($PROGNAME,'@NP_VERSION@'); | 294 | print_revision($PROGNAME,'@NP_VERSION@'); |
294 | print "Copyright (c) 2000 Michael Anthon/Karl DeBisschop | 295 | print "Copyright (c) 2000 Michael Anthon/Karl DeBisschop |
295 | 296 | ||
296 | Perl Check SMB Disk plugin for Nagios | 297 | Perl Check SMB Disk plugin for monitoring |
297 | 298 | ||
298 | "; | 299 | "; |
299 | print_usage(); | 300 | print_usage(); |
diff --git a/plugins-scripts/check_file_age.pl b/plugins-scripts/check_file_age.pl index dcd5efa..ae25201 100755 --- a/plugins-scripts/check_file_age.pl +++ b/plugins-scripts/check_file_age.pl | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/bin/perl -w | 1 | #!@PERL@ -w |
2 | 2 | ||
3 | # check_file_age.pl Copyright (C) 2003 Steven Grimm <koreth-nagios@midwinter.com> | 3 | # check_file_age.pl Copyright (C) 2003 Steven Grimm <koreth-nagios@midwinter.com> |
4 | # | 4 | # |
@@ -17,26 +17,30 @@ | |||
17 | # GNU General Public License for more details. | 17 | # GNU General Public License for more details. |
18 | # | 18 | # |
19 | # you should have received a copy of the GNU General Public License | 19 | # you should have received a copy of the GNU General Public License |
20 | # along with this program (or with Nagios); if not, write to the | 20 | # along with this program if not, write to the Free Software Foundation, |
21 | # Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
22 | # Boston, MA 02111-1307, USA | ||
23 | 22 | ||
24 | use strict; | 23 | use strict; |
25 | use English; | 24 | use English; |
26 | use Getopt::Long; | 25 | use Getopt::Long; |
27 | use File::stat; | 26 | use File::stat; |
28 | use vars qw($PROGNAME); | 27 | use vars qw($PROGNAME); |
29 | use lib "."; | 28 | use FindBin; |
29 | use lib "$FindBin::Bin"; | ||
30 | use utils qw (%ERRORS &print_revision &support); | 30 | use utils qw (%ERRORS &print_revision &support); |
31 | 31 | ||
32 | sub print_help (); | 32 | sub print_help (); |
33 | sub print_usage (); | 33 | sub print_usage (); |
34 | 34 | ||
35 | my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V); | 35 | my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i); |
36 | my ($result, $message, $age, $size, $st); | 36 | my ($result, $message, $age, $size, $st); |
37 | 37 | ||
38 | $PROGNAME="check_file_age"; | 38 | $PROGNAME="check_file_age"; |
39 | 39 | ||
40 | $ENV{'PATH'}='@TRUSTED_PATH@'; | ||
41 | $ENV{'BASH_ENV'}=''; | ||
42 | $ENV{'ENV'}=''; | ||
43 | |||
40 | $opt_w = 240; | 44 | $opt_w = 240; |
41 | $opt_c = 600; | 45 | $opt_c = 600; |
42 | $opt_W = 0; | 46 | $opt_W = 0; |
@@ -47,6 +51,7 @@ Getopt::Long::Configure('bundling'); | |||
47 | GetOptions( | 51 | GetOptions( |
48 | "V" => \$opt_V, "version" => \$opt_V, | 52 | "V" => \$opt_V, "version" => \$opt_V, |
49 | "h" => \$opt_h, "help" => \$opt_h, | 53 | "h" => \$opt_h, "help" => \$opt_h, |
54 | "i" => \$opt_i, "ignore-missing" => \$opt_i, | ||
50 | "f=s" => \$opt_f, "file" => \$opt_f, | 55 | "f=s" => \$opt_f, "file" => \$opt_f, |
51 | "w=f" => \$opt_w, "warning-age=f" => \$opt_w, | 56 | "w=f" => \$opt_w, "warning-age=f" => \$opt_w, |
52 | "W=f" => \$opt_W, "warning-size=f" => \$opt_W, | 57 | "W=f" => \$opt_W, "warning-size=f" => \$opt_W, |
@@ -72,8 +77,15 @@ if (! $opt_f) { | |||
72 | 77 | ||
73 | # Check that file exists (can be directory or link) | 78 | # Check that file exists (can be directory or link) |
74 | unless (-e $opt_f) { | 79 | unless (-e $opt_f) { |
75 | print "FILE_AGE CRITICAL: File not found - $opt_f\n"; | 80 | if ($opt_i) { |
76 | exit $ERRORS{'CRITICAL'}; | 81 | $result = 'OK'; |
82 | print "FILE_AGE $result: $opt_f doesn't exist, but ignore-missing was set\n"; | ||
83 | exit $ERRORS{$result}; | ||
84 | |||
85 | } else { | ||
86 | print "FILE_AGE CRITICAL: File not found - $opt_f\n"; | ||
87 | exit $ERRORS{'CRITICAL'}; | ||
88 | } | ||
77 | } | 89 | } |
78 | 90 | ||
79 | $st = File::stat::stat($opt_f); | 91 | $st = File::stat::stat($opt_f); |
@@ -95,7 +107,7 @@ exit $ERRORS{$result}; | |||
95 | 107 | ||
96 | sub print_usage () { | 108 | sub print_usage () { |
97 | print "Usage:\n"; | 109 | print "Usage:\n"; |
98 | print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] -f <file>\n"; | 110 | print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] [-i] -f <file>\n"; |
99 | print " $PROGNAME [-h | --help]\n"; | 111 | print " $PROGNAME [-h | --help]\n"; |
100 | print " $PROGNAME [-V | --version]\n"; | 112 | print " $PROGNAME [-V | --version]\n"; |
101 | } | 113 | } |
@@ -105,6 +117,7 @@ sub print_help () { | |||
105 | print "Copyright (c) 2003 Steven Grimm\n\n"; | 117 | print "Copyright (c) 2003 Steven Grimm\n\n"; |
106 | print_usage(); | 118 | print_usage(); |
107 | print "\n"; | 119 | print "\n"; |
120 | print " -i | --ignore-missing : return OK if the file does not exist\n"; | ||
108 | print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; | 121 | print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; |
109 | print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n"; | 122 | print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n"; |
110 | print "\n"; | 123 | print "\n"; |
diff --git a/plugins-scripts/check_flexlm.pl b/plugins-scripts/check_flexlm.pl index 54d933c..49d674d 100755 --- a/plugins-scripts/check_flexlm.pl +++ b/plugins-scripts/check_flexlm.pl | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/usr/bin/perl -w | 1 | #!@PERL@ -w |
2 | # | 2 | # |
3 | # usage: | 3 | # usage: |
4 | # check_flexlm.pl license_file | 4 | # check_flexlm.pl license_file |
@@ -9,7 +9,7 @@ | |||
9 | # Check and interpret the output of lmstat | 9 | # Check and interpret the output of lmstat |
10 | # and create returncodes and output. | 10 | # and create returncodes and output. |
11 | # | 11 | # |
12 | # Contrary to the nagios concept, this script takes | 12 | # Contrary to most other plugins, this script takes |
13 | # a file, not a hostname as an argument and returns | 13 | # a file, not a hostname as an argument and returns |
14 | # the status of hosts and services described in that | 14 | # the status of hosts and services described in that |
15 | # file. Use these hosts.cfg entries as an example | 15 | # file. Use these hosts.cfg entries as an example |
@@ -35,7 +35,8 @@ | |||
35 | use strict; | 35 | use strict; |
36 | use Getopt::Long; | 36 | 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 lib utils.pm; | 38 | use FindBin; |
39 | use lib "$FindBin::Bin"; | ||
39 | use utils qw(%ERRORS &print_revision &support &usage); | 40 | use utils qw(%ERRORS &print_revision &support &usage); |
40 | 41 | ||
41 | $PROGNAME="check_flexlm"; | 42 | $PROGNAME="check_flexlm"; |
@@ -43,7 +44,7 @@ $PROGNAME="check_flexlm"; | |||
43 | sub print_help (); | 44 | sub print_help (); |
44 | sub print_usage (); | 45 | sub print_usage (); |
45 | 46 | ||
46 | $ENV{'PATH'}=''; | 47 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
47 | $ENV{'BASH_ENV'}=''; | 48 | $ENV{'BASH_ENV'}=''; |
48 | $ENV{'ENV'}=''; | 49 | $ENV{'ENV'}=''; |
49 | 50 | ||
@@ -72,7 +73,7 @@ unless (defined $opt_F) { | |||
72 | print_usage(); | 73 | print_usage(); |
73 | exit $ERRORS{'UNKNOWN'}; | 74 | exit $ERRORS{'UNKNOWN'}; |
74 | } | 75 | } |
75 | # Just in case of problems, let's not hang Nagios | 76 | # Just in case of problems, let's not hang the monitoring system |
76 | $SIG{'ALRM'} = sub { | 77 | $SIG{'ALRM'} = sub { |
77 | print "Timeout: No Answer from Client\n"; | 78 | print "Timeout: No Answer from Client\n"; |
78 | exit $ERRORS{'UNKNOWN'}; | 79 | exit $ERRORS{'UNKNOWN'}; |
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl index 588993b..1a7fbba 100755 --- a/plugins-scripts/check_ifoperstatus.pl +++ b/plugins-scripts/check_ifoperstatus.pl | |||
@@ -1,9 +1,9 @@ | |||
1 | #!/usr/local/bin/perl -w | 1 | #!@PERL@ -w |
2 | # | 2 | # |
3 | # check_ifoperstatus.pl - nagios plugin | 3 | # check_ifoperstatus.pl - monitoring plugin |
4 | # | 4 | # |
5 | # Copyright (C) 2000 Christoph Kron, | 5 | # Copyright (C) 2000 Christoph Kron, |
6 | # Modified 5/2002 to conform to updated Nagios Plugin Guidelines | 6 | # Modified 5/2002 to conform to updated Monitoring Plugins Guidelines |
7 | # Added support for named interfaces per Valdimir Ivaschenko (S. Ghosh) | 7 | # Added support for named interfaces per Valdimir Ivaschenko (S. Ghosh) |
8 | # Added SNMPv3 support (10/2003) | 8 | # Added SNMPv3 support (10/2003) |
9 | # | 9 | # |
@@ -19,10 +19,11 @@ | |||
19 | # | 19 | # |
20 | # You should have received a copy of the GNU General Public License | 20 | # You should have received a copy of the GNU General Public License |
21 | # along with this program; if not, write to the Free Software | 21 | # along with this program; if not, write to the Free Software |
22 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 22 | # Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
23 | # USA | ||
23 | # | 24 | # |
24 | # | 25 | # |
25 | # Report bugs to: nagiosplug-help@lists.sourceforge.net | 26 | # Report bugs to: help@monitoring-plugins.org |
26 | # | 27 | # |
27 | # 11.01.2000 Version 1.0 | 28 | # 11.01.2000 Version 1.0 |
28 | # | 29 | # |
@@ -34,7 +35,8 @@ | |||
34 | 35 | ||
35 | use POSIX; | 36 | use POSIX; |
36 | use strict; | 37 | use strict; |
37 | use lib utils.pm ; | 38 | use FindBin; |
39 | use lib "$FindBin::Bin"; | ||
38 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 40 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
39 | 41 | ||
40 | use Net::SNMP; | 42 | use Net::SNMP; |
@@ -47,6 +49,10 @@ sub usage ($); | |||
47 | sub print_usage (); | 49 | sub print_usage (); |
48 | sub process_arguments (); | 50 | sub process_arguments (); |
49 | 51 | ||
52 | $ENV{'PATH'}='@TRUSTED_PATH@'; | ||
53 | $ENV{'BASH_ENV'}=''; | ||
54 | $ENV{'ENV'}=''; | ||
55 | |||
50 | my $timeout; | 56 | my $timeout; |
51 | my $status; | 57 | my $status; |
52 | my %ifOperStatus = ('1','up', | 58 | my %ifOperStatus = ('1','up', |
@@ -97,7 +103,7 @@ my %session_opts; | |||
97 | $status = process_arguments(); | 103 | $status = process_arguments(); |
98 | 104 | ||
99 | 105 | ||
100 | # Just in case of problems, let's not hang Nagios | 106 | # Just in case of problems, let's not hang the monitoring system |
101 | $SIG{'ALRM'} = sub { | 107 | $SIG{'ALRM'} = sub { |
102 | print ("ERROR: No snmp response from $hostname (alarm)\n"); | 108 | print ("ERROR: No snmp response from $hostname (alarm)\n"); |
103 | exit $ERRORS{"UNKNOWN"}; | 109 | exit $ERRORS{"UNKNOWN"}; |
@@ -288,7 +294,7 @@ sub print_usage() { | |||
288 | sub print_help() { | 294 | sub print_help() { |
289 | print_revision($PROGNAME, '@NP_VERSION@'); | 295 | print_revision($PROGNAME, '@NP_VERSION@'); |
290 | print_usage(); | 296 | print_usage(); |
291 | printf "check_ifoperstatus plugin for Nagios monitors operational \n"; | 297 | printf "check_ifoperstatus plugin for monitoring operational \n"; |
292 | printf "status of a particular network interface on the target host\n"; | 298 | printf "status of a particular network interface on the target host\n"; |
293 | printf "\nUsage:\n"; | 299 | printf "\nUsage:\n"; |
294 | printf " -H (--hostname) Hostname to query - (required)\n"; | 300 | printf " -H (--hostname) Hostname to query - (required)\n"; |
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl index 63c71ff..e9e6214 100755 --- a/plugins-scripts/check_ifstatus.pl +++ b/plugins-scripts/check_ifstatus.pl | |||
@@ -1,10 +1,10 @@ | |||
1 | #!/usr/local/bin/perl -w | 1 | #!@PERL@ -w |
2 | # | 2 | # |
3 | # check_ifstatus.pl - nagios plugin | 3 | # check_ifstatus.pl - monitoring plugin |
4 | # | 4 | # |
5 | # | 5 | # |
6 | # Copyright (C) 2000 Christoph Kron | 6 | # Copyright (C) 2000 Christoph Kron |
7 | # Modified 5/2002 to conform to updated Nagios Plugin Guidelines (S. Ghosh) | 7 | # Modified 5/2002 to conform to updated Monitoring Plugins Guidelines (S. Ghosh) |
8 | # Added -x option (4/2003) | 8 | # Added -x option (4/2003) |
9 | # Added -u option (4/2003) | 9 | # Added -u option (4/2003) |
10 | # Added -M option (10/2003) | 10 | # Added -M option (10/2003) |
@@ -22,17 +22,18 @@ | |||
22 | # | 22 | # |
23 | # You should have received a copy of the GNU General Public License | 23 | # You should have received a copy of the GNU General Public License |
24 | # along with this program; if not, write to the Free Software | 24 | # along with this program; if not, write to the Free Software |
25 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 25 | # Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
26 | # | 26 | # |
27 | # | 27 | # |
28 | # Report bugs to: ck@zet.net, nagiosplug-help@lists.sf.net | 28 | # Report bugs to: ck@zet.net, help@monitoring-plugins.org |
29 | # | 29 | # |
30 | # 11.01.2000 Version 1.0 | 30 | # 11.01.2000 Version 1.0 |
31 | # | 31 | # |
32 | 32 | ||
33 | use POSIX; | 33 | use POSIX; |
34 | use strict; | 34 | use strict; |
35 | use lib utils.pm ; | 35 | use FindBin; |
36 | use lib "$FindBin::Bin"; | ||
36 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 37 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
37 | 38 | ||
38 | use Net::SNMP; | 39 | use Net::SNMP; |
@@ -46,6 +47,9 @@ sub usage ($); | |||
46 | sub print_usage (); | 47 | sub print_usage (); |
47 | sub process_arguments (); | 48 | sub process_arguments (); |
48 | 49 | ||
50 | $ENV{'PATH'}='@TRUSTED_PATH@'; | ||
51 | $ENV{'BASH_ENV'}=''; | ||
52 | $ENV{'ENV'}=''; | ||
49 | 53 | ||
50 | my $status; | 54 | my $status; |
51 | my %ifOperStatus = ('1','up', | 55 | my %ifOperStatus = ('1','up', |
@@ -99,7 +103,7 @@ my %session_opts; | |||
99 | 103 | ||
100 | 104 | ||
101 | 105 | ||
102 | # Just in case of problems, let's not hang Nagios | 106 | # Just in case of problems, let's not hang the monitoring system |
103 | $SIG{'ALRM'} = sub { | 107 | $SIG{'ALRM'} = sub { |
104 | print ("ERROR: No snmp response from $hostname (alarm timeout)\n"); | 108 | print ("ERROR: No snmp response from $hostname (alarm timeout)\n"); |
105 | exit $ERRORS{"UNKNOWN"}; | 109 | exit $ERRORS{"UNKNOWN"}; |
@@ -239,7 +243,7 @@ sub print_usage() { | |||
239 | sub print_help() { | 243 | sub print_help() { |
240 | print_revision($PROGNAME, '@NP_VERSION@'); | 244 | print_revision($PROGNAME, '@NP_VERSION@'); |
241 | print_usage(); | 245 | print_usage(); |
242 | printf "check_ifstatus plugin for Nagios monitors operational \n"; | 246 | printf "check_ifstatus plugin for monitoring operational \n"; |
243 | printf "status of each network interface on the target host\n"; | 247 | printf "status of each network interface on the target host\n"; |
244 | printf "\nUsage:\n"; | 248 | printf "\nUsage:\n"; |
245 | printf " -H (--hostname) Hostname to query - (required)\n"; | 249 | printf " -H (--hostname) Hostname to query - (required)\n"; |
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl index 42a9bca..afedfb9 100755 --- a/plugins-scripts/check_ircd.pl +++ b/plugins-scripts/check_ircd.pl | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/usr/bin/perl -wT | 1 | #!@PERL@ -w |
2 | 2 | ||
3 | # ----------------------------------------------------------------------------- | 3 | # ----------------------------------------------------------------------------- |
4 | # File Name: check_ircd.pl | 4 | # File Name: check_ircd.pl |
@@ -16,8 +16,6 @@ | |||
16 | # ----------------------------------------------------------------------------- | 16 | # ----------------------------------------------------------------------------- |
17 | # Copyright 1999 (c) Richard Mayhew | 17 | # Copyright 1999 (c) Richard Mayhew |
18 | # | 18 | # |
19 | # Credits go to Ethan Galstad for coding Nagios | ||
20 | # | ||
21 | # If any changes are made to this script, please mail me a copy of the | 19 | # If any changes are made to this script, please mail me a copy of the |
22 | # changes :) | 20 | # changes :) |
23 | # | 21 | # |
@@ -51,7 +49,8 @@ use strict; | |||
51 | use Getopt::Long; | 49 | use Getopt::Long; |
52 | use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose); | 50 | use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose); |
53 | use vars qw($PROGNAME); | 51 | use vars qw($PROGNAME); |
54 | use lib utils.pm; | 52 | use FindBin; |
53 | use lib "$FindBin::Bin"; | ||
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 ]-- |
@@ -63,9 +62,9 @@ sub bindRemote ($$); | |||
63 | 62 | ||
64 | # -------------------------------------------------------------[ Enviroment ]-- | 63 | # -------------------------------------------------------------[ Enviroment ]-- |
65 | 64 | ||
66 | $ENV{PATH} = ""; | 65 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
67 | $ENV{ENV} = ""; | 66 | $ENV{'BASH_ENV'}=''; |
68 | $ENV{BASH_ENV} = ""; | 67 | $ENV{'ENV'}=''; |
69 | 68 | ||
70 | # -----------------------------------------------------------------[ Global ]-- | 69 | # -----------------------------------------------------------------[ Global ]-- |
71 | 70 | ||
@@ -121,7 +120,7 @@ sub print_help () | |||
121 | print_revision($PROGNAME,'@NP_VERSION@'); | 120 | print_revision($PROGNAME,'@NP_VERSION@'); |
122 | print "Copyright (c) 2000 Richard Mayhew/Karl DeBisschop | 121 | print "Copyright (c) 2000 Richard Mayhew/Karl DeBisschop |
123 | 122 | ||
124 | Perl Check IRCD plugin for Nagios | 123 | Perl Check IRCD plugin for monitoring |
125 | 124 | ||
126 | "; | 125 | "; |
127 | print_usage(); | 126 | print_usage(); |
@@ -205,7 +204,7 @@ MAIN: | |||
205 | 204 | ||
206 | if ($opt_t && $opt_t =~ /^([0-9]+)$/) { $TIMEOUT = $1; } | 205 | if ($opt_t && $opt_t =~ /^([0-9]+)$/) { $TIMEOUT = $1; } |
207 | 206 | ||
208 | # Just in case of problems, let's not hang Nagios | 207 | # Just in case of problems, let's not hang the monitoring system |
209 | $SIG{'ALRM'} = sub { | 208 | $SIG{'ALRM'} = sub { |
210 | print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n"; | 209 | print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n"; |
211 | exit $ERRORS{"UNKNOWN"}; | 210 | exit $ERRORS{"UNKNOWN"}; |
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh index a1bfb48..8653a5e 100755 --- a/plugins-scripts/check_log.sh +++ b/plugins-scripts/check_log.sh | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # | 2 | # |
3 | # Log file pattern detector plugin for Nagios | 3 | # Log file pattern detector plugin for monitoring |
4 | # Written by Ethan Galstad (nagios@nagios.org) | 4 | # Written by Ethan Galstad (nagios@nagios.org) |
5 | # Last Modified: 07-31-1999 | 5 | # Last Modified: 07-31-1999 |
6 | # | 6 | # |
@@ -29,15 +29,15 @@ | |||
29 | # | 29 | # |
30 | # If you use this plugin make sure to keep the following in mind: | 30 | # If you use this plugin make sure to keep the following in mind: |
31 | # | 31 | # |
32 | # 1. The "max_attempts" value for the service should be 1, as this | 32 | # 1. The "max_attempts" value for the service should be 1, as this will |
33 | # will prevent Nagios from retrying the service check (the | 33 | # prevent the monitoring system from retrying the service check (the |
34 | # next time the check is run it will not produce the same results). | 34 | # next time the check is run it will not produce the same results). |
35 | # | 35 | # |
36 | # 2. The "notify_recovery" value for the service should be 0, so that | 36 | # 2. The "notify_recovery" value for the service should be 0, so that the |
37 | # Nagios does not notify you of "recoveries" for the check. Since | 37 | # monitoring system does not notify you of "recoveries" for the check. |
38 | # pattern matches in the log file will only be reported once and not | 38 | # Since pattern matches in the log file will only be reported once and |
39 | # the next time, there will always be "recoveries" for the service, even | 39 | # not the next time, there will always be "recoveries" for the service, |
40 | # though recoveries really don't apply to this type of check. | 40 | # even though recoveries really don't apply to this type of check. |
41 | # | 41 | # |
42 | # 3. You *must* supply a different <old_file_log> for each service that | 42 | # 3. You *must* supply a different <old_file_log> for each service that |
43 | # you define to use this plugin script - even if the different services | 43 | # you define to use this plugin script - even if the different services |
@@ -57,21 +57,13 @@ | |||
57 | 57 | ||
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 | # TV: removed PATH restriction. Need to think more about what this means overall | ||
61 | #PATH="" | ||
62 | |||
63 | ECHO="/bin/echo" | ||
64 | GREP="/bin/egrep" | ||
65 | DIFF="/bin/diff" | ||
66 | TAIL="/bin/tail" | ||
67 | CAT="/bin/cat" | ||
68 | RM="/bin/rm" | ||
69 | CHMOD="/bin/chmod" | ||
70 | TOUCH="/bin/touch" | ||
71 | 60 | ||
72 | PROGNAME=`/bin/basename $0` | 61 | PROGNAME=`/bin/basename $0` |
73 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 62 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` |
74 | REVISION="@NP_VERSION@" | 63 | REVISION="@NP_VERSION@" |
64 | PATH="@TRUSTED_PATH@" | ||
65 | |||
66 | export PATH | ||
75 | 67 | ||
76 | . $PROGPATH/utils.sh | 68 | . $PROGPATH/utils.sh |
77 | 69 | ||
@@ -86,7 +78,7 @@ print_help() { | |||
86 | echo "" | 78 | echo "" |
87 | print_usage | 79 | print_usage |
88 | echo "" | 80 | echo "" |
89 | echo "Log file pattern detector plugin for Nagios" | 81 | echo "Log file pattern detector plugin for monitoring" |
90 | echo "" | 82 | echo "" |
91 | support | 83 | support |
92 | } | 84 | } |
@@ -167,10 +159,10 @@ done | |||
167 | # If the source log file doesn't exist, exit | 159 | # If the source log file doesn't exist, exit |
168 | 160 | ||
169 | if [ ! -e $logfile ]; then | 161 | if [ ! -e $logfile ]; then |
170 | $ECHO "Log check error: Log file $logfile does not exist!\n" | 162 | echo "Log check error: Log file $logfile does not exist!" |
171 | exit $STATE_UNKNOWN | 163 | exit $STATE_UNKNOWN |
172 | elif [ ! -r $logfile ] ; then | 164 | elif [ ! -r $logfile ] ; then |
173 | $ECHO "Log check error: Log file $logfile is not readable!\n" | 165 | echo "Log check error: Log file $logfile is not readable!" |
174 | exit $STATE_UNKNOWN | 166 | exit $STATE_UNKNOWN |
175 | fi | 167 | fi |
176 | 168 | ||
@@ -179,8 +171,8 @@ fi | |||
179 | # the old diff file and exit | 171 | # the old diff file and exit |
180 | 172 | ||
181 | if [ ! -e $oldlog ]; then | 173 | if [ ! -e $oldlog ]; then |
182 | $CAT $logfile > $oldlog | 174 | cat $logfile > $oldlog |
183 | $ECHO "Log check data initialized...\n" | 175 | echo "Log check data initialized..." |
184 | exit $STATE_OK | 176 | exit $STATE_OK |
185 | fi | 177 | fi |
186 | 178 | ||
@@ -193,26 +185,26 @@ if [ -x /bin/mktemp ]; then | |||
193 | else | 185 | else |
194 | tempdiff=`/bin/date '+%H%M%S'` | 186 | tempdiff=`/bin/date '+%H%M%S'` |
195 | tempdiff="/tmp/check_log.${tempdiff}" | 187 | tempdiff="/tmp/check_log.${tempdiff}" |
196 | $TOUCH $tempdiff | 188 | touch $tempdiff |
197 | $CHMOD 600 $tempdiff | 189 | chmod 600 $tempdiff |
198 | fi | 190 | fi |
199 | 191 | ||
200 | $DIFF $logfile $oldlog | $GREP -v "^>" > $tempdiff | 192 | diff $logfile $oldlog | grep -v "^>" > $tempdiff |
201 | 193 | ||
202 | # Count the number of matching log entries we have | 194 | # Count the number of matching log entries we have |
203 | count=`$GREP -c "$query" $tempdiff` | 195 | count=`grep -c "$query" $tempdiff` |
204 | 196 | ||
205 | # Get the last matching entry in the diff file | 197 | # Get the last matching entry in the diff file |
206 | lastentry=`$GREP "$query" $tempdiff | $TAIL -1` | 198 | lastentry=`grep "$query" $tempdiff | tail -1` |
207 | 199 | ||
208 | $RM -f $tempdiff | 200 | rm -f $tempdiff |
209 | $CAT $logfile > $oldlog | 201 | cat $logfile > $oldlog |
210 | 202 | ||
211 | if [ "$count" = "0" ]; then # no matches, exit with no error | 203 | if [ "$count" = "0" ]; then # no matches, exit with no error |
212 | $ECHO "Log check ok - 0 pattern matches found\n" | 204 | echo "Log check ok - 0 pattern matches found" |
213 | exitstatus=$STATE_OK | 205 | exitstatus=$STATE_OK |
214 | else # Print total matche count and the last entry we found | 206 | else # Print total matche count and the last entry we found |
215 | $ECHO "($count) $lastentry" | 207 | echo "($count) $lastentry" |
216 | exitstatus=$STATE_CRITICAL | 208 | exitstatus=$STATE_CRITICAL |
217 | fi | 209 | fi |
218 | 210 | ||
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl index 31eb46a..df1385d 100755 --- a/plugins-scripts/check_mailq.pl +++ b/plugins-scripts/check_mailq.pl | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/usr/local/bin/perl -w | 1 | #!@PERL@ -w |
2 | 2 | ||
3 | # check_mailq - check to see how many messages are in the smtp queue awating | 3 | # check_mailq - check to see how many messages are in the smtp queue awating |
4 | # transmittal. | 4 | # transmittal. |
@@ -20,8 +20,8 @@ | |||
20 | # | 20 | # |
21 | # You should have received a copy of the GNU General Public License | 21 | # You should have received a copy of the GNU General Public License |
22 | # along with this program; if not, write to the Free Software | 22 | # along with this program; if not, write to the Free Software |
23 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | # Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
24 | # | 24 | # USA |
25 | # | 25 | # |
26 | ############################################################################ | 26 | ############################################################################ |
27 | 27 | ||
@@ -31,7 +31,8 @@ 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 |
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 lib utils.pm; | 34 | use FindBin; |
35 | use lib "$FindBin::Bin"; | ||
35 | use utils qw(%ERRORS &print_revision &support &usage ); | 36 | use utils qw(%ERRORS &print_revision &support &usage ); |
36 | 37 | ||
37 | 38 | ||
@@ -39,7 +40,7 @@ sub print_help (); | |||
39 | sub print_usage (); | 40 | sub print_usage (); |
40 | sub process_arguments (); | 41 | sub process_arguments (); |
41 | 42 | ||
42 | $ENV{'PATH'}=''; | 43 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
43 | $ENV{'BASH_ENV'}=''; | 44 | $ENV{'BASH_ENV'}=''; |
44 | $ENV{'ENV'}=''; | 45 | $ENV{'ENV'}=''; |
45 | $PROGNAME = "check_mailq"; | 46 | $PROGNAME = "check_mailq"; |
@@ -199,20 +200,20 @@ if ($mailq eq "sendmail") { | |||
199 | ## now check the queue length(s) | 200 | ## now check the queue length(s) |
200 | 201 | ||
201 | if ($msg_q == 0) { | 202 | if ($msg_q == 0) { |
202 | $msg = "OK: mailq is empty"; | 203 | $msg = "OK: $mailq mailq is empty"; |
203 | $state = $ERRORS{'OK'}; | 204 | $state = $ERRORS{'OK'}; |
204 | } else { | 205 | } else { |
205 | print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose; | 206 | print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose; |
206 | 207 | ||
207 | # overall queue length | 208 | # overall queue length |
208 | if ($msg_q < $opt_w) { | 209 | if ($msg_q < $opt_w) { |
209 | $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; | 210 | $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; |
210 | $state = $ERRORS{'OK'}; | 211 | $state = $ERRORS{'OK'}; |
211 | }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { | 212 | }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { |
212 | $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)"; | 213 | $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)"; |
213 | $state = $ERRORS{'WARNING'}; | 214 | $state = $ERRORS{'WARNING'}; |
214 | }else { | 215 | }else { |
215 | $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)"; | 216 | $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)"; |
216 | $state = $ERRORS{'CRITICAL'}; | 217 | $state = $ERRORS{'CRITICAL'}; |
217 | } | 218 | } |
218 | 219 | ||
@@ -344,20 +345,20 @@ elsif ( $mailq eq "postfix" ) { | |||
344 | 345 | ||
345 | # check queue length(s) | 346 | # check queue length(s) |
346 | if ($msg_q == 0){ | 347 | if ($msg_q == 0){ |
347 | $msg = "OK: mailq reports queue is empty"; | 348 | $msg = "OK: $mailq mailq reports queue is empty"; |
348 | $state = $ERRORS{'OK'}; | 349 | $state = $ERRORS{'OK'}; |
349 | } else { | 350 | } else { |
350 | print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose; | 351 | print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose; |
351 | 352 | ||
352 | # overall queue length | 353 | # overall queue length |
353 | if ($msg_q < $opt_w) { | 354 | if ($msg_q < $opt_w) { |
354 | $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; | 355 | $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; |
355 | $state = $ERRORS{'OK'}; | 356 | $state = $ERRORS{'OK'}; |
356 | }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { | 357 | }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { |
357 | $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)"; | 358 | $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)"; |
358 | $state = $ERRORS{'WARNING'}; | 359 | $state = $ERRORS{'WARNING'}; |
359 | }else { | 360 | }else { |
360 | $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)"; | 361 | $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)"; |
361 | $state = $ERRORS{'CRITICAL'}; | 362 | $state = $ERRORS{'CRITICAL'}; |
362 | } | 363 | } |
363 | 364 | ||
@@ -373,7 +374,7 @@ elsif ( $mailq eq "postfix" ) { | |||
373 | # } | 374 | # } |
374 | #} | 375 | #} |
375 | } | 376 | } |
376 | } # end of ($mailq eq "postfixl") | 377 | } # end of ($mailq eq "postfix") |
377 | elsif ( $mailq eq "qmail" ) { | 378 | elsif ( $mailq eq "qmail" ) { |
378 | 379 | ||
379 | # open qmail-qstat | 380 | # open qmail-qstat |
@@ -431,13 +432,13 @@ elsif ( $mailq eq "qmail" ) { | |||
431 | 432 | ||
432 | # overall queue length | 433 | # overall queue length |
433 | if ($msg_q < $opt_w) { | 434 | if ($msg_q < $opt_w) { |
434 | $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; | 435 | $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; |
435 | $state = $ERRORS{'OK'}; | 436 | $state = $ERRORS{'OK'}; |
436 | }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { | 437 | }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { |
437 | $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)"; | 438 | $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)"; |
438 | $state = $ERRORS{'WARNING'}; | 439 | $state = $ERRORS{'WARNING'}; |
439 | }else { | 440 | }else { |
440 | $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)"; | 441 | $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)"; |
441 | $state = $ERRORS{'CRITICAL'}; | 442 | $state = $ERRORS{'CRITICAL'}; |
442 | } | 443 | } |
443 | 444 | ||
@@ -489,17 +490,54 @@ elsif ( $mailq eq "exim" ) { | |||
489 | exit $ERRORS{CRITICAL}; | 490 | exit $ERRORS{CRITICAL}; |
490 | } | 491 | } |
491 | if ($msg_q < $opt_w) { | 492 | if ($msg_q < $opt_w) { |
492 | $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; | 493 | $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; |
493 | $state = $ERRORS{'OK'}; | 494 | $state = $ERRORS{'OK'}; |
494 | }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { | 495 | }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { |
495 | $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)"; | 496 | $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)"; |
496 | $state = $ERRORS{'WARNING'}; | 497 | $state = $ERRORS{'WARNING'}; |
497 | }else { | 498 | }else { |
498 | $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)"; | 499 | $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)"; |
499 | $state = $ERRORS{'CRITICAL'}; | 500 | $state = $ERRORS{'CRITICAL'}; |
500 | } | 501 | } |
501 | } # end of ($mailq eq "exim") | 502 | } # end of ($mailq eq "exim") |
502 | 503 | ||
504 | elsif ( $mailq eq "nullmailer" ) { | ||
505 | ## open mailq | ||
506 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | ||
507 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | ||
508 | print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | ||
509 | exit $ERRORS{'UNKNOWN'}; | ||
510 | } | ||
511 | }elsif( defined $utils::PATH_TO_MAILQ){ | ||
512 | unless (-x $utils::PATH_TO_MAILQ) { | ||
513 | print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
514 | exit $ERRORS{'UNKNOWN'}; | ||
515 | } | ||
516 | } else { | ||
517 | print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; | ||
518 | exit $ERRORS{'UNKNOWN'}; | ||
519 | } | ||
520 | |||
521 | while (<MAILQ>) { | ||
522 | #2006-06-22 16:00:00 282 bytes | ||
523 | |||
524 | 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$/) { | ||
525 | $msg_q++ ; | ||
526 | } | ||
527 | } | ||
528 | close(MAILQ) ; | ||
529 | if ($msg_q < $opt_w) { | ||
530 | $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; | ||
531 | $state = $ERRORS{'OK'}; | ||
532 | }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { | ||
533 | $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)"; | ||
534 | $state = $ERRORS{'WARNING'}; | ||
535 | }else { | ||
536 | $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)"; | ||
537 | $state = $ERRORS{'CRITICAL'}; | ||
538 | } | ||
539 | } # end of ($mailq eq "nullmailer") | ||
540 | |||
503 | # Perfdata support | 541 | # Perfdata support |
504 | print "$msg|unsent=$msg_q;$opt_w;$opt_c;0\n"; | 542 | print "$msg|unsent=$msg_q;$opt_w;$opt_c;0\n"; |
505 | exit $state; | 543 | exit $state; |
@@ -559,7 +597,7 @@ sub process_arguments(){ | |||
559 | } | 597 | } |
560 | 598 | ||
561 | if (defined $opt_M) { | 599 | if (defined $opt_M) { |
562 | if ($opt_M =~ /^(sendmail|qmail|postfix|exim)$/) { | 600 | if ($opt_M =~ /^(sendmail|qmail|postfix|exim|nullmailer)$/) { |
563 | $mailq = $opt_M ; | 601 | $mailq = $opt_M ; |
564 | }elsif( $opt_M eq ''){ | 602 | }elsif( $opt_M eq ''){ |
565 | $mailq = 'sendmail'; | 603 | $mailq = 'sendmail'; |
@@ -568,7 +606,30 @@ sub process_arguments(){ | |||
568 | exit $ERRORS{'UNKNOWN'}; | 606 | exit $ERRORS{'UNKNOWN'}; |
569 | } | 607 | } |
570 | }else{ | 608 | }else{ |
571 | $mailq = 'sendmail' ; | 609 | if (defined $utils::PATH_TO_QMAIL_QSTAT |
610 | && -x $utils::PATH_TO_QMAIL_QSTAT) | ||
611 | { | ||
612 | $mailq = 'qmail'; | ||
613 | } | ||
614 | elsif (-d '/var/lib/postfix' || -d '/var/local/lib/postfix' | ||
615 | || -e '/usr/sbin/postfix' || -e '/usr/local/sbin/postfix') | ||
616 | { | ||
617 | $mailq = 'postfix'; | ||
618 | } | ||
619 | elsif (-d '/usr/lib/exim4' || -d '/usr/local/lib/exim4' | ||
620 | || -e '/usr/sbin/exim' || -e '/usr/local/sbin/exim') | ||
621 | { | ||
622 | $mailq = 'exim'; | ||
623 | } | ||
624 | elsif (-d '/usr/lib/nullmailer' || -d '/usr/local/lib/nullmailer' | ||
625 | || -e '/usr/sbin/nullmailer-send' | ||
626 | || -e '/usr/local/sbin/nullmailer-send') | ||
627 | { | ||
628 | $mailq = 'nullmailer'; | ||
629 | } | ||
630 | else { | ||
631 | $mailq = 'sendmail'; | ||
632 | } | ||
572 | } | 633 | } |
573 | 634 | ||
574 | return $ERRORS{'OK'}; | 635 | return $ERRORS{'OK'}; |
@@ -591,7 +652,7 @@ sub print_help () { | |||
591 | print "-W (--Warning) = Min. number of messages for same domain in queue to generate warning\n"; | 652 | print "-W (--Warning) = Min. number of messages for same domain in queue to generate warning\n"; |
592 | print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; | 653 | print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; |
593 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; | 654 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; |
594 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim ] (default = sendmail)\n"; | 655 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; |
595 | print "-h (--help)\n"; | 656 | print "-h (--help)\n"; |
596 | print "-V (--version)\n"; | 657 | print "-V (--version)\n"; |
597 | print "-v (--verbose) = debugging output\n"; | 658 | print "-v (--verbose) = debugging output\n"; |
@@ -599,6 +660,8 @@ sub print_help () { | |||
599 | print "Note: -w and -c are required arguments. -W and -C are optional.\n"; | 660 | print "Note: -w and -c are required arguments. -W and -C are optional.\n"; |
600 | print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n"; | 661 | print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n"; |
601 | print " -W and -C are applied message not yet preproccessed. (qmail)\n"; | 662 | print " -W and -C are applied message not yet preproccessed. (qmail)\n"; |
663 | print " This plugin tries to autodetect which mailserver you are running,\n"; | ||
664 | print " you can override the autodetection with -M.\n"; | ||
602 | print " This plugin uses the system mailq command (sendmail) or qmail-stat (qmail)\n"; | 665 | print " This plugin uses the system mailq command (sendmail) or qmail-stat (qmail)\n"; |
603 | print " to look at the queues. Mailq can usually only be accessed by root or \n"; | 666 | print " to look at the queues. Mailq can usually only be accessed by root or \n"; |
604 | print " a TrustedUser. You will have to set appropriate permissions for the plugin to work.\n"; | 667 | print " a TrustedUser. You will have to set appropriate permissions for the plugin to work.\n"; |
diff --git a/plugins-scripts/check_mssql.pl b/plugins-scripts/check_mssql.pl index 9a8fc51..a436a8f 100755 --- a/plugins-scripts/check_mssql.pl +++ b/plugins-scripts/check_mssql.pl | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/usr/bin/perl -w | 1 | #!@PERL@ -w |
2 | 2 | ||
3 | # | 3 | # |
4 | # Copyright 2003 Roy Sigurd Karlsbakk | 4 | # Copyright 2003 Roy Sigurd Karlsbakk |
@@ -19,9 +19,9 @@ | |||
19 | # | 19 | # |
20 | # You should have received a copy of the GNU General Public License | 20 | # You should have received a copy of the GNU General Public License |
21 | # along with this program; if not, write to the Free Software | 21 | # along with this program; if not, write to the Free Software |
22 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA. |
23 | # | 23 | # |
24 | # Report bugs to: nagiosplug-help@lists.sourceforge.net | 24 | # Report bugs to: help@monitoring-plugins.org |
25 | # | 25 | # |
26 | # | 26 | # |
27 | 27 | ||
@@ -29,12 +29,17 @@ | |||
29 | use DBI; | 29 | use DBI; |
30 | use DBD::Sybase; | 30 | use DBD::Sybase; |
31 | use Getopt::Long; | 31 | use Getopt::Long; |
32 | use lib "."; | 32 | use FindBin; |
33 | use lib "$FindBin::Bin"; | ||
33 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 34 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
34 | use strict; | 35 | use strict; |
35 | 36 | ||
36 | my $PROGNAME = "check_mssql"; | 37 | my $PROGNAME = "check_mssql"; |
37 | 38 | ||
39 | $ENV{'PATH'}='@TRUSTED_PATH@'; | ||
40 | $ENV{'BASH_ENV'}=''; | ||
41 | $ENV{'ENV'}=''; | ||
42 | |||
38 | my ( | 43 | my ( |
39 | $server,$database,$username,$password,$query,$help,$verbose,$timeout, | 44 | $server,$database,$username,$password,$query,$help,$verbose,$timeout, |
40 | $dbh,$sth,$row, | 45 | $dbh,$sth,$row, |
@@ -44,7 +49,7 @@ my $exitcode = $ERRORS{'OK'}; | |||
44 | 49 | ||
45 | process_arguments(); | 50 | process_arguments(); |
46 | 51 | ||
47 | # Just in case of problems, let's not hang Nagios | 52 | # Just in case of problems, let's not hang the monitoring system |
48 | $SIG{'ALRM'} = sub { | 53 | $SIG{'ALRM'} = sub { |
49 | print ("SQL UNKNOWN: ERROR connection $server (alarm timeout)\n"); | 54 | print ("SQL UNKNOWN: ERROR connection $server (alarm timeout)\n"); |
50 | exit $ERRORS{"UNKNOWN"}; | 55 | exit $ERRORS{"UNKNOWN"}; |
diff --git a/plugins-scripts/check_netdns.pl b/plugins-scripts/check_netdns.pl index ecdbdb1..82939bf 100755 --- a/plugins-scripts/check_netdns.pl +++ b/plugins-scripts/check_netdns.pl | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/usr/bin/perl -w | 1 | #!@PERL@ -w |
2 | 2 | ||
3 | # Perl version of check_dns plugin which calls DNS directly instead of | 3 | # Perl version of check_dns plugin which calls DNS directly instead of |
4 | # relying on nslookup (which has bugs) | 4 | # relying on nslookup (which has bugs) |
@@ -27,11 +27,16 @@ | |||
27 | 27 | ||
28 | use Getopt::Long; | 28 | use Getopt::Long; |
29 | use Net::DNS; | 29 | use Net::DNS; |
30 | use lib utils.pm; | 30 | use FindBin; |
31 | use lib "$FindBin::Bin"; | ||
31 | use utils ; | 32 | use utils ; |
32 | 33 | ||
33 | my $PROGNAME = "check_netdns"; | 34 | my $PROGNAME = "check_netdns"; |
34 | 35 | ||
36 | $ENV{'PATH'}='@TRUSTED_PATH@'; | ||
37 | $ENV{'BASH_ENV'}=''; | ||
38 | $ENV{'ENV'}=''; | ||
39 | |||
35 | Getopt::Long::Configure(`bundling`); | 40 | Getopt::Long::Configure(`bundling`); |
36 | GetOptions("V" => $opt_V, "version" => $opt_V, | 41 | GetOptions("V" => $opt_V, "version" => $opt_V, |
37 | "h" => $opt_h, "help" => $opt_h, | 42 | "h" => $opt_h, "help" => $opt_h, |
diff --git a/plugins-scripts/check_ntp.pl b/plugins-scripts/check_ntp.pl index 5c87e0a..13da939 100755 --- a/plugins-scripts/check_ntp.pl +++ b/plugins-scripts/check_ntp.pl | |||
@@ -1,4 +1,4 @@ | |||
1 | #!/usr/bin/perl -w | 1 | #!@PERL@ -w |
2 | # | 2 | # |
3 | # (c)1999 Ian Cass, Knowledge Matters Ltd. | 3 | # (c)1999 Ian Cass, Knowledge Matters Ltd. |
4 | # Read the GNU copyright stuff for all the legalese | 4 | # Read the GNU copyright stuff for all the legalese |
@@ -69,7 +69,7 @@ $PROGNAME="check_ntp"; | |||
69 | sub print_help (); | 69 | sub print_help (); |
70 | sub print_usage (); | 70 | sub print_usage (); |
71 | 71 | ||
72 | $ENV{'PATH'}=''; | 72 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
73 | $ENV{'BASH_ENV'}=''; | 73 | $ENV{'BASH_ENV'}=''; |
74 | $ENV{'ENV'}=''; | 74 | $ENV{'ENV'}=''; |
75 | 75 | ||
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh index 2a8ab21..ceac95d 100755 --- a/plugins-scripts/check_oracle.sh +++ b/plugins-scripts/check_oracle.sh | |||
@@ -3,12 +3,13 @@ | |||
3 | # latigid010@yahoo.com | 3 | # latigid010@yahoo.com |
4 | # 01/06/2000 | 4 | # 01/06/2000 |
5 | # | 5 | # |
6 | # This Nagios plugin was created to check Oracle status | 6 | # This Monitoring plugin was created to check Oracle status |
7 | # | 7 | # |
8 | 8 | ||
9 | PROGNAME=`basename $0` | 9 | PROGNAME=`basename $0` |
10 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 10 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` |
11 | REVISION="@NP_VERSION@" | 11 | REVISION="@NP_VERSION@" |
12 | PATH="@TRUSTED_PATH@" | ||
12 | 13 | ||
13 | . $PROGPATH/utils.sh | 14 | . $PROGPATH/utils.sh |
14 | 15 | ||
@@ -163,7 +164,7 @@ case "$cmd" in | |||
163 | }' | 164 | }' |
164 | ;; | 165 | ;; |
165 | --db) | 166 | --db) |
166 | pmonchk=`ps -ef | grep -v grep | grep -c "ora_pmon_${2}$"` | 167 | pmonchk=`ps -ef | grep -v grep | grep -E -c "(asm|ora)_pmon_${2}$"` |
167 | if [ ${pmonchk} -ge 1 ] ; then | 168 | if [ ${pmonchk} -ge 1 ] ; then |
168 | echo "${2} OK - ${pmonchk} PMON process(es) running" | 169 | echo "${2} OK - ${pmonchk} PMON process(es) running" |
169 | exit $STATE_OK | 170 | exit $STATE_OK |
diff --git a/plugins-scripts/check_rpc.pl b/plugins-scripts/check_rpc.pl index d2701e9..cbdeceb 100755 --- a/plugins-scripts/check_rpc.pl +++ b/plugins-scripts/check_rpc.pl | |||
@@ -1,6 +1,6 @@ | |||
1 | #!/usr/local/bin/perl -w | 1 | #!@PERL@ -w |
2 | # | 2 | # |
3 | # check_rpc plugin for nagios | 3 | # check_rpc plugin for monitoring |
4 | # | 4 | # |
5 | # usage: | 5 | # usage: |
6 | # check_rpc host service | 6 | # check_rpc host service |
@@ -20,7 +20,8 @@ | |||
20 | # | 20 | # |
21 | 21 | ||
22 | use strict; | 22 | use strict; |
23 | use lib utils.pm; | 23 | use FindBin; |
24 | use lib "$FindBin::Bin"; | ||
24 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 25 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
25 | use vars qw($PROGNAME); | 26 | use vars qw($PROGNAME); |
26 | my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state); | 27 | my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state); |
@@ -36,9 +37,9 @@ sub print_help (); | |||
36 | sub print_usage (); | 37 | sub print_usage (); |
37 | sub in ($$); | 38 | sub in ($$); |
38 | 39 | ||
39 | $ENV{'BASH_ENV'}=''; | 40 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
41 | $ENV{'BASH_ENV'}=''; | ||
40 | $ENV{'ENV'}=''; | 42 | $ENV{'ENV'}=''; |
41 | $ENV{'PATH'}=''; | ||
42 | $ENV{'LC_ALL'}='C'; | 43 | $ENV{'LC_ALL'}='C'; |
43 | 44 | ||
44 | #Initialise protocol for each progname number | 45 | #Initialise protocol for each progname number |
@@ -254,7 +255,7 @@ $proto = 't' if ($opt_t); | |||
254 | $proto = 'u' if ($opt_u); | 255 | $proto = 'u' if ($opt_u); |
255 | 256 | ||
256 | 257 | ||
257 | # Just in case of problems, let's not hang Nagios | 258 | # Just in case of problems, let's not hang the monitoring system |
258 | $SIG{'ALRM'} = sub { | 259 | $SIG{'ALRM'} = sub { |
259 | print ("ERROR: No response from RPC server (alarm)\n"); | 260 | print ("ERROR: No response from RPC server (alarm)\n"); |
260 | exit $ERRORS{"UNKNOWN"}; | 261 | exit $ERRORS{"UNKNOWN"}; |
diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh index 874e104..05c64c4 100755 --- a/plugins-scripts/check_sensors.sh +++ b/plugins-scripts/check_sensors.sh | |||
@@ -1,13 +1,13 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin | ||
4 | |||
5 | PROGNAME=`basename $0` | 3 | PROGNAME=`basename $0` |
6 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` | 4 | PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` |
7 | REVISION="@NP_VERSION@" | 5 | REVISION="@NP_VERSION@" |
6 | PATH="@TRUSTED_PATH@" | ||
8 | 7 | ||
9 | . $PROGPATH/utils.sh | 8 | export PATH |
10 | 9 | ||
10 | . $PROGPATH/utils.sh | ||
11 | 11 | ||
12 | print_usage() { | 12 | print_usage() { |
13 | echo "Usage: $PROGNAME" [--ignore-fault] | 13 | echo "Usage: $PROGNAME" [--ignore-fault] |
diff --git a/plugins-scripts/check_wave.pl b/plugins-scripts/check_wave.pl index 2671112..979416e 100755 --- a/plugins-scripts/check_wave.pl +++ b/plugins-scripts/check_wave.pl | |||
@@ -1,9 +1,10 @@ | |||
1 | #!/usr/bin/perl -wT | 1 | #!@PERL@ -w |
2 | # | 2 | # |
3 | 3 | ||
4 | 4 | ||
5 | use strict; | 5 | use strict; |
6 | use lib utils.pm; | 6 | use FindBin; |
7 | use lib "$FindBin::Bin"; | ||
7 | use utils qw($TIMEOUT %ERRORS &print_revision &support); | 8 | use utils qw($TIMEOUT %ERRORS &print_revision &support); |
8 | use vars qw($PROGNAME); | 9 | use vars qw($PROGNAME); |
9 | use Getopt::Long; | 10 | use Getopt::Long; |
@@ -15,7 +16,7 @@ $PROGNAME = "check_wave"; | |||
15 | sub print_help (); | 16 | sub print_help (); |
16 | sub print_usage (); | 17 | sub print_usage (); |
17 | 18 | ||
18 | $ENV{'PATH'}=''; | 19 | $ENV{'PATH'}='@TRUSTED_PATH@'; |
19 | $ENV{'BASH_ENV'}=''; | 20 | $ENV{'BASH_ENV'}=''; |
20 | $ENV{'ENV'}=''; | 21 | $ENV{'ENV'}=''; |
21 | 22 | ||
diff --git a/plugins-scripts/subst.in b/plugins-scripts/subst.in deleted file mode 100644 index a70ad88..0000000 --- a/plugins-scripts/subst.in +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | #!/usr/bin/awk | ||
2 | |||
3 | function which(c,path) { | ||
4 | cmd = "test -x " c; | ||
5 | |||
6 | if (system(cmd)==0) { | ||
7 | return c; | ||
8 | } | ||
9 | |||
10 | sub(/\/.*\//,"",c); | ||
11 | for (dir in path) { | ||
12 | cmd = "test -x " path[dir] "/" c; | ||
13 | if (system(cmd)==0) { | ||
14 | return path[dir] "/" c; | ||
15 | } | ||
16 | } | ||
17 | |||
18 | |||
19 | return c; | ||
20 | } | ||
21 | |||
22 | # used to replace "use lib utils.pm" with "use lib @libexecdir" | ||
23 | # | ||
24 | function led() { | ||
25 | led1 = "@libexecdir@"; | ||
26 | led2 = "@exec_prefix@"; | ||
27 | led3 = "@prefix@"; | ||
28 | if ( match(led1, /^\$\{exec_prefix\}/ ) != 0 ) { | ||
29 | return "\"" led3 "/libexec\" " ; | ||
30 | |||
31 | } | ||
32 | return "\"" led1 "\"" ; | ||
33 | } | ||
34 | |||
35 | BEGIN { | ||
36 | split(ENVIRON["PATH"] ":/sbin:/usr/sbin",path,/:/); | ||
37 | |||
38 | } | ||
39 | |||
40 | # Plugin revision | ||
41 | /@NP_VERSION@/ {sub(/@NP_VERSION@/,ENVIRON["NP_VERSION"]);} | ||
42 | |||
43 | # scripting language (first line) | ||
44 | |||
45 | /^#! ?\/.*\/python/ {sub(/^#! ?\/.*\/python/,"#! @PYTHON@");} | ||
46 | /^#! ?\/.*\/perl/ {sub(/^#! ?\/.*\/perl/,"#! @PERL@");} | ||
47 | /^#! ?\/.*\/[a-z]{0,2}awk/ {sub(/^#! ?\/.*\/[a-z]{0,2}awk/,"#! @AWK@");} | ||
48 | /^#! ?\/.*\/sh/ {sub(/^#! ?\/.*\/sh/,"#! @SHELL@");} | ||
49 | |||
50 | # If a script contains a reference to a fully qualified command, | ||
51 | # subst will replace the fully qualified command with whatever is | ||
52 | # returned from the which subroutine. run before changes to INC to add libexecdir | ||
53 | # FIXME: Prepend executables with a substitution keyword instead. | ||
54 | # | ||
55 | /^[^#]/ && /(\/.*)?\/(bin|sbin|lib|libexec)\// { | ||
56 | match($0,/(\/.*)?\/(bin|sbin|lib|libexec)\/[-_a-zA-Z0-9]+/); | ||
57 | c=substr($0,RSTART,RLENGTH); | ||
58 | sub(c,which(c,path)); | ||
59 | } | ||
60 | |||
61 | # add to libexecdir to INC for perl utils.pm | ||
62 | /^use/ { if (/lib/) { if (/utils.pm|"."/ ) {sub(/utils.pm|"."/,led() )} } } | ||
63 | |||
64 | |||
65 | # Trusted path mechanism (deprecated) | ||
66 | |||
67 | /^[ \t]*\$ENV[ \t]*\{[ \t'"]*PATH[ \t"']*\}[ \t]*=/ { | ||
68 | sub(/\=[ \t]*['"][^"']+["']/,"='@with_trusted_path@' # autoconf-derived"); | ||
69 | } | ||
70 | |||
71 | /^[\t ]*(export[\t ]*)?PATH[\t ]*=['"]+.+["']$/ { | ||
72 | sub(/\=.*$/,"='@with_trusted_path@' # autoconf-derived"); | ||
73 | } | ||
74 | |||
75 | { | ||
76 | print; | ||
77 | } | ||
78 | |||
diff --git a/plugins-scripts/t/check_file_age.t b/plugins-scripts/t/check_file_age.t index 384c276..a515649 100644 --- a/plugins-scripts/t/check_file_age.t +++ b/plugins-scripts/t/check_file_age.t | |||
@@ -5,7 +5,7 @@ | |||
5 | # | 5 | # |
6 | 6 | ||
7 | use strict; | 7 | use strict; |
8 | use Test::More tests => 15; | 8 | use Test::More tests => 16; |
9 | use NPTest; | 9 | use NPTest; |
10 | 10 | ||
11 | my $successOutput = '/^FILE_AGE OK: /'; | 11 | my $successOutput = '/^FILE_AGE OK: /'; |
@@ -58,6 +58,11 @@ $result = NPTest->testCmd( | |||
58 | cmp_ok( $result->return_code, '==', 0, "Checking file size" ); | 58 | cmp_ok( $result->return_code, '==', 0, "Checking file size" ); |
59 | 59 | ||
60 | $result = NPTest->testCmd( | 60 | $result = NPTest->testCmd( |
61 | "./check_file_age -f /non/existent --ignore-missing" | ||
62 | ); | ||
63 | cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); | ||
64 | |||
65 | $result = NPTest->testCmd( | ||
61 | "./check_file_age -f $temp_file -c 1000 -W 101" | 66 | "./check_file_age -f $temp_file -c 1000 -W 101" |
62 | ); | 67 | ); |
63 | cmp_ok( $result->return_code, '==', 1, "One byte too short" ); | 68 | cmp_ok( $result->return_code, '==', 1, "One byte too short" ); |
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in index 37cd62c..0f53243 100644 --- a/plugins-scripts/utils.pm.in +++ b/plugins-scripts/utils.pm.in | |||
@@ -1,6 +1,6 @@ | |||
1 | # Utility drawer for Nagios plugins. | 1 | # Utility drawer for Monitoring Plugins. |
2 | # | 2 | # |
3 | # This will be deprecated soon. Please use Nagios::Plugin from CPAN | 3 | # This will be deprecated soon. Please use Monitoring::Plugin from CPAN |
4 | # for new plugins | 4 | # for new plugins |
5 | 5 | ||
6 | package utils; | 6 | package utils; |
diff --git a/plugins-scripts/utils.sh.in b/plugins-scripts/utils.sh.in index 4a07df8..031c035 100644 --- a/plugins-scripts/utils.sh.in +++ b/plugins-scripts/utils.sh.in | |||
@@ -6,19 +6,13 @@ STATE_CRITICAL=2 | |||
6 | STATE_UNKNOWN=3 | 6 | STATE_UNKNOWN=3 |
7 | STATE_DEPENDENT=4 | 7 | STATE_DEPENDENT=4 |
8 | 8 | ||
9 | if test -x /usr/bin/printf; then | ||
10 | ECHO=/usr/bin/printf | ||
11 | else | ||
12 | ECHO=echo | ||
13 | fi | ||
14 | |||
15 | print_revision() { | 9 | print_revision() { |
16 | echo "$1 v$2 (@PACKAGE@ @VERSION@)" | 10 | echo "$1 v$2 (@PACKAGE@ @VERSION@)" |
17 | $ECHO "@WARRANTY@" | sed -e 's/\n/ /g' | 11 | printf '%b' "@WARRANTY@" |
18 | } | 12 | } |
19 | 13 | ||
20 | support() { | 14 | support() { |
21 | $ECHO "@SUPPORT@" | sed -e 's/\n/ /g' | 15 | printf '%b' "@SUPPORT@" |
22 | } | 16 | } |
23 | 17 | ||
24 | # | 18 | # |