summaryrefslogtreecommitdiffstats
path: root/plugins-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts')
-rw-r--r--plugins-scripts/Makefile.am11
-rwxr-xr-xplugins-scripts/check_breeze.pl7
-rwxr-xr-xplugins-scripts/check_disk_smb.pl13
-rwxr-xr-xplugins-scripts/check_file_age.pl31
-rwxr-xr-xplugins-scripts/check_flexlm.pl11
-rwxr-xr-xplugins-scripts/check_ifoperstatus.pl22
-rwxr-xr-xplugins-scripts/check_ifstatus.pl20
-rwxr-xr-xplugins-scripts/check_ircd.pl17
-rwxr-xr-xplugins-scripts/check_log.sh58
-rwxr-xr-xplugins-scripts/check_mailq.pl109
-rwxr-xr-xplugins-scripts/check_mssql.pl15
-rwxr-xr-xplugins-scripts/check_netdns.pl9
-rwxr-xr-xplugins-scripts/check_ntp.pl4
-rwxr-xr-xplugins-scripts/check_oracle.sh5
-rwxr-xr-xplugins-scripts/check_rpc.pl13
-rwxr-xr-xplugins-scripts/check_sensors.sh6
-rwxr-xr-xplugins-scripts/check_wave.pl7
-rw-r--r--plugins-scripts/subst.in78
-rw-r--r--plugins-scripts/t/check_file_age.t7
-rw-r--r--plugins-scripts/utils.pm.in4
-rw-r--r--plugins-scripts/utils.sh.in10
21 files changed, 238 insertions, 219 deletions
diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am
index 58db0604..78a950c2 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
21EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \ 21EXTRA_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
26EDIT = 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
26TESTS_ENVIRONMENT=perl -I $(top_builddir) -I $(top_srcdir) 31TESTS_ENVIRONMENT=perl -I $(top_builddir) -I $(top_srcdir)
27 32
28TESTS = @SCRIPT_TEST@ 33TESTS = @SCRIPT_TEST@
@@ -38,11 +43,11 @@ test-debug:
38CLEANFILES=$(libexec_SCRIPTS) 43CLEANFILES=$(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
48clean-local: 53clean-local:
diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl
index a4e8542c..12a60ee6 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
4use strict; 4use strict;
5use Getopt::Long; 5use Getopt::Long;
6use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME); 6use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME);
7use lib utils.pm ; 7use FindBin;
8use lib "$FindBin::Bin";
8use utils qw(%ERRORS &print_revision &support &usage); 9use utils qw(%ERRORS &print_revision &support &usage);
9 10
10$PROGNAME = "check_breeze"; 11$PROGNAME = "check_breeze";
@@ -12,7 +13,7 @@ $PROGNAME = "check_breeze";
12sub print_help (); 13sub print_help ();
13sub print_usage (); 14sub 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 0c89db57..99948a41 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;
24use Getopt::Long; 24use Getopt::Long;
25use 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); 25use 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);
26use vars qw($PROGNAME); 26use vars qw($PROGNAME);
27use lib utils.pm ; 27use FindBin;
28use lib "$FindBin::Bin";
28use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); 29use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
29 30
30sub print_help (); 31sub 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;
171my $perfdata = ""; 172my $perfdata = "";
172my @lines = undef; 173my @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
296Perl Check SMB Disk plugin for Nagios 297Perl 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 dcd5efab..ae25201e 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
24use strict; 23use strict;
25use English; 24use English;
26use Getopt::Long; 25use Getopt::Long;
27use File::stat; 26use File::stat;
28use vars qw($PROGNAME); 27use vars qw($PROGNAME);
29use lib "."; 28use FindBin;
29use lib "$FindBin::Bin";
30use utils qw (%ERRORS &print_revision &support); 30use utils qw (%ERRORS &print_revision &support);
31 31
32sub print_help (); 32sub print_help ();
33sub print_usage (); 33sub print_usage ();
34 34
35my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V); 35my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i);
36my ($result, $message, $age, $size, $st); 36my ($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');
47GetOptions( 51GetOptions(
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)
74unless (-e $opt_f) { 79unless (-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
96sub print_usage () { 108sub 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 54d933c7..49d674d4 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 @@
35use strict; 35use strict;
36use Getopt::Long; 36use Getopt::Long;
37use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME); 37use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME);
38use lib utils.pm; 38use FindBin;
39use lib "$FindBin::Bin";
39use utils qw(%ERRORS &print_revision &support &usage); 40use utils qw(%ERRORS &print_revision &support &usage);
40 41
41$PROGNAME="check_flexlm"; 42$PROGNAME="check_flexlm";
@@ -43,7 +44,7 @@ $PROGNAME="check_flexlm";
43sub print_help (); 44sub print_help ();
44sub print_usage (); 45sub 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 588993be..1a7fbba4 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
35use POSIX; 36use POSIX;
36use strict; 37use strict;
37use lib utils.pm ; 38use FindBin;
39use lib "$FindBin::Bin";
38use utils qw($TIMEOUT %ERRORS &print_revision &support); 40use utils qw($TIMEOUT %ERRORS &print_revision &support);
39 41
40use Net::SNMP; 42use Net::SNMP;
@@ -47,6 +49,10 @@ sub usage ($);
47sub print_usage (); 49sub print_usage ();
48sub process_arguments (); 50sub process_arguments ();
49 51
52$ENV{'PATH'}='@TRUSTED_PATH@';
53$ENV{'BASH_ENV'}='';
54$ENV{'ENV'}='';
55
50my $timeout; 56my $timeout;
51my $status; 57my $status;
52my %ifOperStatus = ('1','up', 58my %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() {
288sub print_help() { 294sub 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 63c71ffa..e9e62149 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
33use POSIX; 33use POSIX;
34use strict; 34use strict;
35use lib utils.pm ; 35use FindBin;
36use lib "$FindBin::Bin";
36use utils qw($TIMEOUT %ERRORS &print_revision &support); 37use utils qw($TIMEOUT %ERRORS &print_revision &support);
37 38
38use Net::SNMP; 39use Net::SNMP;
@@ -46,6 +47,9 @@ sub usage ($);
46sub print_usage (); 47sub print_usage ();
47sub process_arguments (); 48sub process_arguments ();
48 49
50$ENV{'PATH'}='@TRUSTED_PATH@';
51$ENV{'BASH_ENV'}='';
52$ENV{'ENV'}='';
49 53
50my $status; 54my $status;
51my %ifOperStatus = ('1','up', 55my %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() {
239sub print_help() { 243sub 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 42a9bca9..afedfb95 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;
51use Getopt::Long; 49use Getopt::Long;
52use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose); 50use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose);
53use vars qw($PROGNAME); 51use vars qw($PROGNAME);
54use lib utils.pm; 52use FindBin;
53use lib "$FindBin::Bin";
55use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); 54use 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
124Perl Check IRCD plugin for Nagios 123Perl 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 a1bfb486..8653a5e1 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
63ECHO="/bin/echo"
64GREP="/bin/egrep"
65DIFF="/bin/diff"
66TAIL="/bin/tail"
67CAT="/bin/cat"
68RM="/bin/rm"
69CHMOD="/bin/chmod"
70TOUCH="/bin/touch"
71 60
72PROGNAME=`/bin/basename $0` 61PROGNAME=`/bin/basename $0`
73PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 62PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
74REVISION="@NP_VERSION@" 63REVISION="@NP_VERSION@"
64PATH="@TRUSTED_PATH@"
65
66export 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
169if [ ! -e $logfile ]; then 161if [ ! -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
172elif [ ! -r $logfile ] ; then 164elif [ ! -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
175fi 167fi
176 168
@@ -179,8 +171,8 @@ fi
179# the old diff file and exit 171# the old diff file and exit
180 172
181if [ ! -e $oldlog ]; then 173if [ ! -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
185fi 177fi
186 178
@@ -193,26 +185,26 @@ if [ -x /bin/mktemp ]; then
193else 185else
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
198fi 190fi
199 191
200$DIFF $logfile $oldlog | $GREP -v "^>" > $tempdiff 192diff $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
203count=`$GREP -c "$query" $tempdiff` 195count=`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
206lastentry=`$GREP "$query" $tempdiff | $TAIL -1` 198lastentry=`grep "$query" $tempdiff | tail -1`
207 199
208$RM -f $tempdiff 200rm -f $tempdiff
209$CAT $logfile > $oldlog 201cat $logfile > $oldlog
210 202
211if [ "$count" = "0" ]; then # no matches, exit with no error 203if [ "$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
214else # Print total matche count and the last entry we found 206else # 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
217fi 209fi
218 210
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl
index 31eb46a4..df1385d2 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;
31use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t 31use 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);
34use lib utils.pm; 34use FindBin;
35use lib "$FindBin::Bin";
35use utils qw(%ERRORS &print_revision &support &usage ); 36use utils qw(%ERRORS &print_revision &support &usage );
36 37
37 38
@@ -39,7 +40,7 @@ sub print_help ();
39sub print_usage (); 40sub print_usage ();
40sub process_arguments (); 41sub 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")
377elsif ( $mailq eq "qmail" ) { 378elsif ( $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
504elsif ( $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
504print "$msg|unsent=$msg_q;$opt_w;$opt_c;0\n"; 542print "$msg|unsent=$msg_q;$opt_w;$opt_c;0\n";
505exit $state; 543exit $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 9a8fc511..a436a8ff 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 @@
29use DBI; 29use DBI;
30use DBD::Sybase; 30use DBD::Sybase;
31use Getopt::Long; 31use Getopt::Long;
32use lib "."; 32use FindBin;
33use lib "$FindBin::Bin";
33use utils qw($TIMEOUT %ERRORS &print_revision &support); 34use utils qw($TIMEOUT %ERRORS &print_revision &support);
34use strict; 35use strict;
35 36
36my $PROGNAME = "check_mssql"; 37my $PROGNAME = "check_mssql";
37 38
39$ENV{'PATH'}='@TRUSTED_PATH@';
40$ENV{'BASH_ENV'}='';
41$ENV{'ENV'}='';
42
38my ( 43my (
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
45process_arguments(); 50process_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 ecdbdb1a..82939bff 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
28use Getopt::Long; 28use Getopt::Long;
29use Net::DNS; 29use Net::DNS;
30use lib utils.pm; 30use FindBin;
31use lib "$FindBin::Bin";
31use utils ; 32use utils ;
32 33
33my $PROGNAME = "check_netdns"; 34my $PROGNAME = "check_netdns";
34 35
36$ENV{'PATH'}='@TRUSTED_PATH@';
37$ENV{'BASH_ENV'}='';
38$ENV{'ENV'}='';
39
35Getopt::Long::Configure(`bundling`); 40Getopt::Long::Configure(`bundling`);
36GetOptions("V" => $opt_V, "version" => $opt_V, 41GetOptions("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 5c87e0a6..13da939c 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";
69sub print_help (); 69sub print_help ();
70sub print_usage (); 70sub 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 2a8ab21d..ceac95dc 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
9PROGNAME=`basename $0` 9PROGNAME=`basename $0`
10PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 10PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
11REVISION="@NP_VERSION@" 11REVISION="@NP_VERSION@"
12PATH="@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 d2701e95..cbdeceb4 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
22use strict; 22use strict;
23use lib utils.pm; 23use FindBin;
24use lib "$FindBin::Bin";
24use utils qw($TIMEOUT %ERRORS &print_revision &support); 25use utils qw($TIMEOUT %ERRORS &print_revision &support);
25use vars qw($PROGNAME); 26use vars qw($PROGNAME);
26my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state); 27my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state);
@@ -36,9 +37,9 @@ sub print_help ();
36sub print_usage (); 37sub print_usage ();
37sub in ($$); 38sub 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 874e1049..05c64c48 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
3PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
4
5PROGNAME=`basename $0` 3PROGNAME=`basename $0`
6PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` 4PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
7REVISION="@NP_VERSION@" 5REVISION="@NP_VERSION@"
6PATH="@TRUSTED_PATH@"
8 7
9. $PROGPATH/utils.sh 8export PATH
10 9
10. $PROGPATH/utils.sh
11 11
12print_usage() { 12print_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 2671112a..979416e0 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
5use strict; 5use strict;
6use lib utils.pm; 6use FindBin;
7use lib "$FindBin::Bin";
7use utils qw($TIMEOUT %ERRORS &print_revision &support); 8use utils qw($TIMEOUT %ERRORS &print_revision &support);
8use vars qw($PROGNAME); 9use vars qw($PROGNAME);
9use Getopt::Long; 10use Getopt::Long;
@@ -15,7 +16,7 @@ $PROGNAME = "check_wave";
15sub print_help (); 16sub print_help ();
16sub print_usage (); 17sub 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 a70ad884..00000000
--- a/plugins-scripts/subst.in
+++ /dev/null
@@ -1,78 +0,0 @@
1#!/usr/bin/awk
2
3function 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#
24function 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
35BEGIN {
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 384c276b..a5156491 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
7use strict; 7use strict;
8use Test::More tests => 15; 8use Test::More tests => 16;
9use NPTest; 9use NPTest;
10 10
11my $successOutput = '/^FILE_AGE OK: /'; 11my $successOutput = '/^FILE_AGE OK: /';
@@ -58,6 +58,11 @@ $result = NPTest->testCmd(
58cmp_ok( $result->return_code, '==', 0, "Checking file size" ); 58cmp_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 );
63cmp_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 );
63cmp_ok( $result->return_code, '==', 1, "One byte too short" ); 68cmp_ok( $result->return_code, '==', 1, "One byte too short" );
diff --git a/plugins-scripts/utils.pm.in b/plugins-scripts/utils.pm.in
index 37cd62c3..0f53243c 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
6package utils; 6package utils;
diff --git a/plugins-scripts/utils.sh.in b/plugins-scripts/utils.sh.in
index 4a07df89..031c0357 100644
--- a/plugins-scripts/utils.sh.in
+++ b/plugins-scripts/utils.sh.in
@@ -6,19 +6,13 @@ STATE_CRITICAL=2
6STATE_UNKNOWN=3 6STATE_UNKNOWN=3
7STATE_DEPENDENT=4 7STATE_DEPENDENT=4
8 8
9if test -x /usr/bin/printf; then
10 ECHO=/usr/bin/printf
11else
12 ECHO=echo
13fi
14
15print_revision() { 9print_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
20support() { 14support() {
21 $ECHO "@SUPPORT@" | sed -e 's/\n/ /g' 15 printf '%b' "@SUPPORT@"
22} 16}
23 17
24# 18#