aboutsummaryrefslogtreecommitdiff
path: root/plugins-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts')
-rw-r--r--plugins-scripts/Makefile.am2
-rwxr-xr-xplugins-scripts/check_breeze.pl3
-rwxr-xr-xplugins-scripts/check_disk_smb.pl9
-rwxr-xr-xplugins-scripts/check_file_age.pl22
-rwxr-xr-xplugins-scripts/check_flexlm.pl7
-rwxr-xr-xplugins-scripts/check_ifoperstatus.pl16
-rwxr-xr-xplugins-scripts/check_ifstatus.pl15
-rwxr-xr-xplugins-scripts/check_ircd.pl9
-rwxr-xr-xplugins-scripts/check_log.sh29
-rwxr-xr-xplugins-scripts/check_mailq.pl105
-rwxr-xr-xplugins-scripts/check_mssql.pl4
-rwxr-xr-xplugins-scripts/check_netdns.pl3
-rwxr-xr-xplugins-scripts/check_oracle.sh4
-rwxr-xr-xplugins-scripts/check_rpc.pl7
-rwxr-xr-xplugins-scripts/check_wave.pl3
-rw-r--r--plugins-scripts/subst.in16
-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
19 files changed, 168 insertions, 107 deletions
diff --git a/plugins-scripts/Makefile.am b/plugins-scripts/Makefile.am
index 58db0604..4ea262af 100644
--- a/plugins-scripts/Makefile.am
+++ b/plugins-scripts/Makefile.am
@@ -19,7 +19,7 @@ libexec_SCRIPTS = check_breeze check_disk_smb check_flexlm check_ircd \
utils.sh utils.pm
EXTRA_DIST=check_breeze.pl check_disk_smb.pl check_flexlm.pl check_ircd.pl \
- check_log.sh check_ntp.pl check_oracle.sh check_rpc.pl check_sensors.sh \
+ check_log.sh check_oracle.sh check_rpc.pl check_sensors.sh \
check_ifstatus.pl check_ifoperstatus.pl check_wave.pl check_mailq.pl check_file_age.pl \
utils.sh.in utils.pm.in t
diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl
index 037060c8..917a1c6f 100755
--- a/plugins-scripts/check_breeze.pl
+++ b/plugins-scripts/check_breeze.pl
@@ -4,7 +4,8 @@
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME);
-use lib utils.pm ;
+use FindBin;
+use lib "$FindBin::Bin";
use utils qw(%ERRORS &print_revision &support &usage);
$PROGNAME = "check_breeze";
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl
index 01c560ef..36259d59 100755
--- a/plugins-scripts/check_disk_smb.pl
+++ b/plugins-scripts/check_disk_smb.pl
@@ -3,7 +3,7 @@
#
# check_disk.pl <host> <share> <user> <pass> [warn] [critical] [port]
#
-# Nagios host script to get the disk usage from a SMB share
+# Monitoring host script to get the disk usage from a SMB share
#
# Changes and Modifications
# =========================
@@ -24,7 +24,8 @@ use strict;
use Getopt::Long;
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);
use vars qw($PROGNAME);
-use lib utils.pm ;
+use FindBin;
+use lib "$FindBin::Bin";
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
sub print_help ();
@@ -171,7 +172,7 @@ my $res = undef;
my $perfdata = "";
my @lines = undef;
-# Just in case of problems, let's not hang Nagios
+# Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print "No Answer from Client\n";
exit $ERRORS{"UNKNOWN"};
@@ -293,7 +294,7 @@ sub print_help () {
print_revision($PROGNAME,'@NP_VERSION@');
print "Copyright (c) 2000 Michael Anthon/Karl DeBisschop
-Perl Check SMB Disk plugin for Nagios
+Perl Check SMB Disk plugin for monitoring
";
print_usage();
diff --git a/plugins-scripts/check_file_age.pl b/plugins-scripts/check_file_age.pl
index 37bbe86f..e0280381 100755
--- a/plugins-scripts/check_file_age.pl
+++ b/plugins-scripts/check_file_age.pl
@@ -17,9 +17,8 @@
# GNU General Public License for more details.
#
# you should have received a copy of the GNU General Public License
-# along with this program (or with Nagios); if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA
+# along with this program if not, write to the Free Software Foundation,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
use strict;
use English;
@@ -32,7 +31,7 @@ use utils qw (%ERRORS &print_revision &support);
sub print_help ();
sub print_usage ();
-my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V);
+my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i);
my ($result, $message, $age, $size, $st);
$PROGNAME="check_file_age";
@@ -51,6 +50,7 @@ Getopt::Long::Configure('bundling');
GetOptions(
"V" => \$opt_V, "version" => \$opt_V,
"h" => \$opt_h, "help" => \$opt_h,
+ "i" => \$opt_i, "ignore-missing" => \$opt_i,
"f=s" => \$opt_f, "file" => \$opt_f,
"w=f" => \$opt_w, "warning-age=f" => \$opt_w,
"W=f" => \$opt_W, "warning-size=f" => \$opt_W,
@@ -76,8 +76,15 @@ if (! $opt_f) {
# Check that file exists (can be directory or link)
unless (-e $opt_f) {
- print "FILE_AGE CRITICAL: File not found - $opt_f\n";
- exit $ERRORS{'CRITICAL'};
+ if ($opt_i) {
+ $result = 'OK';
+ print "FILE_AGE $result: $opt_f doesn't exist, but ignore-missing was set\n";
+ exit $ERRORS{$result};
+
+ } else {
+ print "FILE_AGE CRITICAL: File not found - $opt_f\n";
+ exit $ERRORS{'CRITICAL'};
+ }
}
$st = File::stat::stat($opt_f);
@@ -99,7 +106,7 @@ exit $ERRORS{$result};
sub print_usage () {
print "Usage:\n";
- print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] -f <file>\n";
+ print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] [-i] -f <file>\n";
print " $PROGNAME [-h | --help]\n";
print " $PROGNAME [-V | --version]\n";
}
@@ -109,6 +116,7 @@ sub print_help () {
print "Copyright (c) 2003 Steven Grimm\n\n";
print_usage();
print "\n";
+ print " -i | --ignore-missing : return OK if the file does not exist\n";
print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n";
print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n";
print "\n";
diff --git a/plugins-scripts/check_flexlm.pl b/plugins-scripts/check_flexlm.pl
index 05973777..de63d3ab 100755
--- a/plugins-scripts/check_flexlm.pl
+++ b/plugins-scripts/check_flexlm.pl
@@ -9,7 +9,7 @@
# Check and interpret the output of lmstat
# and create returncodes and output.
#
-# Contrary to the nagios concept, this script takes
+# Contrary to most other plugins, this script takes
# a file, not a hostname as an argument and returns
# the status of hosts and services described in that
# file. Use these hosts.cfg entries as an example
@@ -35,7 +35,8 @@
use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME);
-use lib utils.pm;
+use FindBin;
+use lib "$FindBin::Bin";
use utils qw(%ERRORS &print_revision &support &usage);
$PROGNAME="check_flexlm";
@@ -72,7 +73,7 @@ unless (defined $opt_F) {
print_usage();
exit $ERRORS{'UNKNOWN'};
}
-# Just in case of problems, let's not hang Nagios
+# Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print "Timeout: No Answer from Client\n";
exit $ERRORS{'UNKNOWN'};
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl
index 452911b7..159eb62e 100755
--- a/plugins-scripts/check_ifoperstatus.pl
+++ b/plugins-scripts/check_ifoperstatus.pl
@@ -1,9 +1,9 @@
#!/usr/local/bin/perl -w
#
-# check_ifoperstatus.pl - nagios plugin
+# check_ifoperstatus.pl - monitoring plugin
#
# Copyright (C) 2000 Christoph Kron,
-# Modified 5/2002 to conform to updated Nagios Plugin Guidelines
+# Modified 5/2002 to conform to updated Monitoring Plugins Guidelines
# Added support for named interfaces per Valdimir Ivaschenko (S. Ghosh)
# Added SNMPv3 support (10/2003)
#
@@ -19,10 +19,11 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA
#
#
-# Report bugs to: nagiosplug-help@lists.sourceforge.net
+# Report bugs to: help@monitoring-plugins.org
#
# 11.01.2000 Version 1.0
#
@@ -34,7 +35,8 @@
use POSIX;
use strict;
-use lib utils.pm ;
+use FindBin;
+use lib "$FindBin::Bin";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use Net::SNMP;
@@ -101,7 +103,7 @@ my %session_opts;
$status = process_arguments();
-# Just in case of problems, let's not hang Nagios
+# Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print ("ERROR: No snmp response from $hostname (alarm)\n");
exit $ERRORS{"UNKNOWN"};
@@ -292,7 +294,7 @@ sub print_usage() {
sub print_help() {
print_revision($PROGNAME, '@NP_VERSION@');
print_usage();
- printf "check_ifoperstatus plugin for Nagios monitors operational \n";
+ printf "check_ifoperstatus plugin for monitoring operational \n";
printf "status of a particular network interface on the target host\n";
printf "\nUsage:\n";
printf " -H (--hostname) Hostname to query - (required)\n";
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl
index 421580ad..4760a281 100755
--- a/plugins-scripts/check_ifstatus.pl
+++ b/plugins-scripts/check_ifstatus.pl
@@ -1,10 +1,10 @@
#!/usr/local/bin/perl -w
#
-# check_ifstatus.pl - nagios plugin
+# check_ifstatus.pl - monitoring plugin
#
#
# Copyright (C) 2000 Christoph Kron
-# Modified 5/2002 to conform to updated Nagios Plugin Guidelines (S. Ghosh)
+# Modified 5/2002 to conform to updated Monitoring Plugins Guidelines (S. Ghosh)
# Added -x option (4/2003)
# Added -u option (4/2003)
# Added -M option (10/2003)
@@ -22,17 +22,18 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
#
-# Report bugs to: ck@zet.net, nagiosplug-help@lists.sf.net
+# Report bugs to: ck@zet.net, help@monitoring-plugins.org
#
# 11.01.2000 Version 1.0
#
use POSIX;
use strict;
-use lib utils.pm ;
+use FindBin;
+use lib "$FindBin::Bin";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use Net::SNMP;
@@ -102,7 +103,7 @@ my %session_opts;
-# Just in case of problems, let's not hang Nagios
+# Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print ("ERROR: No snmp response from $hostname (alarm timeout)\n");
exit $ERRORS{"UNKNOWN"};
@@ -242,7 +243,7 @@ sub print_usage() {
sub print_help() {
print_revision($PROGNAME, '@NP_VERSION@');
print_usage();
- printf "check_ifstatus plugin for Nagios monitors operational \n";
+ printf "check_ifstatus plugin for monitoring operational \n";
printf "status of each network interface on the target host\n";
printf "\nUsage:\n";
printf " -H (--hostname) Hostname to query - (required)\n";
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl
index f80c5c65..dab65954 100755
--- a/plugins-scripts/check_ircd.pl
+++ b/plugins-scripts/check_ircd.pl
@@ -16,8 +16,6 @@
# -----------------------------------------------------------------------------
# Copyright 1999 (c) Richard Mayhew
#
-# Credits go to Ethan Galstad for coding Nagios
-#
# If any changes are made to this script, please mail me a copy of the
# changes :)
#
@@ -51,7 +49,8 @@ use strict;
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose);
use vars qw($PROGNAME);
-use lib utils.pm;
+use FindBin;
+use lib "$FindBin::Bin";
use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
# ----------------------------------------------------[ Function Prototypes ]--
@@ -121,7 +120,7 @@ sub print_help ()
print_revision($PROGNAME,'@NP_VERSION@');
print "Copyright (c) 2000 Richard Mayhew/Karl DeBisschop
-Perl Check IRCD plugin for Nagios
+Perl Check IRCD plugin for monitoring
";
print_usage();
@@ -205,7 +204,7 @@ MAIN:
if ($opt_t && $opt_t =~ /^([0-9]+)$/) { $TIMEOUT = $1; }
- # Just in case of problems, let's not hang Nagios
+ # Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n";
exit $ERRORS{"UNKNOWN"};
diff --git a/plugins-scripts/check_log.sh b/plugins-scripts/check_log.sh
index a9ff06ad..be4c7be1 100755
--- a/plugins-scripts/check_log.sh
+++ b/plugins-scripts/check_log.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Log file pattern detector plugin for Nagios
+# Log file pattern detector plugin for monitoring
# Written by Ethan Galstad (nagios@nagios.org)
# Last Modified: 07-31-1999
#
@@ -29,15 +29,15 @@
#
# If you use this plugin make sure to keep the following in mind:
#
-# 1. The "max_attempts" value for the service should be 1, as this
-# will prevent Nagios from retrying the service check (the
+# 1. The "max_attempts" value for the service should be 1, as this will
+# prevent the monitoring system from retrying the service check (the
# next time the check is run it will not produce the same results).
#
-# 2. The "notify_recovery" value for the service should be 0, so that
-# Nagios does not notify you of "recoveries" for the check. Since
-# pattern matches in the log file will only be reported once and not
-# the next time, there will always be "recoveries" for the service, even
-# though recoveries really don't apply to this type of check.
+# 2. The "notify_recovery" value for the service should be 0, so that the
+# monitoring system does not notify you of "recoveries" for the check.
+# Since pattern matches in the log file will only be reported once and
+# not the next time, there will always be "recoveries" for the service,
+# even though recoveries really don't apply to this type of check.
#
# 3. You *must* supply a different <old_file_log> for each service that
# you define to use this plugin script - even if the different services
@@ -58,7 +58,6 @@
# Paths to commands used in this script. These
# may have to be modified to match your system setup.
-ECHO="/bin/echo"
GREP="/bin/egrep"
DIFF="/bin/diff"
TAIL="/bin/tail"
@@ -85,7 +84,7 @@ print_help() {
echo ""
print_usage
echo ""
- echo "Log file pattern detector plugin for Nagios"
+ echo "Log file pattern detector plugin for monitoring"
echo ""
support
}
@@ -166,10 +165,10 @@ done
# If the source log file doesn't exist, exit
if [ ! -e $logfile ]; then
- $ECHO "Log check error: Log file $logfile does not exist!\n"
+ echo "Log check error: Log file $logfile does not exist!"
exit $STATE_UNKNOWN
elif [ ! -r $logfile ] ; then
- $ECHO "Log check error: Log file $logfile is not readable!\n"
+ echo "Log check error: Log file $logfile is not readable!"
exit $STATE_UNKNOWN
fi
@@ -179,7 +178,7 @@ fi
if [ ! -e $oldlog ]; then
$CAT $logfile > $oldlog
- $ECHO "Log check data initialized...\n"
+ echo "Log check data initialized..."
exit $STATE_OK
fi
@@ -208,10 +207,10 @@ $RM -f $tempdiff
$CAT $logfile > $oldlog
if [ "$count" = "0" ]; then # no matches, exit with no error
- $ECHO "Log check ok - 0 pattern matches found\n"
+ echo "Log check ok - 0 pattern matches found"
exitstatus=$STATE_OK
else # Print total matche count and the last entry we found
- $ECHO "($count) $lastentry"
+ echo "($count) $lastentry"
exitstatus=$STATE_CRITICAL
fi
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl
index 1d0a3ad7..488cf2f1 100755
--- a/plugins-scripts/check_mailq.pl
+++ b/plugins-scripts/check_mailq.pl
@@ -20,8 +20,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
+# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+# USA
#
############################################################################
@@ -31,7 +31,8 @@ use Getopt::Long;
use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t
$opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines
%srcdomains %dstdomains);
-use lib utils.pm;
+use FindBin;
+use lib "$FindBin::Bin";
use utils qw(%ERRORS &print_revision &support &usage );
@@ -199,20 +200,20 @@ if ($mailq eq "sendmail") {
## now check the queue length(s)
if ($msg_q == 0) {
- $msg = "OK: mailq is empty";
+ $msg = "OK: $mailq mailq is empty";
$state = $ERRORS{'OK'};
} else {
print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose;
# overall queue length
if ($msg_q < $opt_w) {
- $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+ $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
$state = $ERRORS{'OK'};
}elsif ($msg_q >= $opt_w && $msg_q < $opt_c) {
- $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
+ $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
$state = $ERRORS{'WARNING'};
}else {
- $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
+ $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
$state = $ERRORS{'CRITICAL'};
}
@@ -344,20 +345,20 @@ elsif ( $mailq eq "postfix" ) {
# check queue length(s)
if ($msg_q == 0){
- $msg = "OK: mailq reports queue is empty";
+ $msg = "OK: $mailq mailq reports queue is empty";
$state = $ERRORS{'OK'};
} else {
print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose;
# overall queue length
if ($msg_q < $opt_w) {
- $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+ $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
$state = $ERRORS{'OK'};
}elsif ($msg_q >= $opt_w && $msg_q < $opt_c) {
- $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
+ $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
$state = $ERRORS{'WARNING'};
}else {
- $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
+ $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
$state = $ERRORS{'CRITICAL'};
}
@@ -373,7 +374,7 @@ elsif ( $mailq eq "postfix" ) {
# }
#}
}
-} # end of ($mailq eq "postfixl")
+} # end of ($mailq eq "postfix")
elsif ( $mailq eq "qmail" ) {
# open qmail-qstat
@@ -431,13 +432,13 @@ elsif ( $mailq eq "qmail" ) {
# overall queue length
if ($msg_q < $opt_w) {
- $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+ $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
$state = $ERRORS{'OK'};
}elsif ($msg_q >= $opt_w && $msg_q < $opt_c) {
- $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
+ $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
$state = $ERRORS{'WARNING'};
}else {
- $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
+ $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
$state = $ERRORS{'CRITICAL'};
}
@@ -489,17 +490,54 @@ elsif ( $mailq eq "exim" ) {
exit $ERRORS{CRITICAL};
}
if ($msg_q < $opt_w) {
- $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+ $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
$state = $ERRORS{'OK'};
}elsif ($msg_q >= $opt_w && $msg_q < $opt_c) {
- $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
+ $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
$state = $ERRORS{'WARNING'};
}else {
- $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
+ $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
$state = $ERRORS{'CRITICAL'};
}
} # end of ($mailq eq "exim")
+elsif ( $mailq eq "nullmailer" ) {
+ ## open mailq
+ if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
+ if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
+ print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
+ exit $ERRORS{'UNKNOWN'};
+ }
+ }elsif( defined $utils::PATH_TO_MAILQ){
+ unless (-x $utils::PATH_TO_MAILQ) {
+ print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n";
+ exit $ERRORS{'UNKNOWN'};
+ }
+ } else {
+ print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n";
+ exit $ERRORS{'UNKNOWN'};
+ }
+
+ while (<MAILQ>) {
+ #2006-06-22 16:00:00 282 bytes
+
+ 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$/) {
+ $msg_q++ ;
+ }
+ }
+ close(MAILQ) ;
+ if ($msg_q < $opt_w) {
+ $msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+ $state = $ERRORS{'OK'};
+ }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) {
+ $msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
+ $state = $ERRORS{'WARNING'};
+ }else {
+ $msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
+ $state = $ERRORS{'CRITICAL'};
+ }
+} # end of ($mailq eq "nullmailer")
+
# Perfdata support
print "$msg|unsent=$msg_q;$opt_w;$opt_c;0\n";
exit $state;
@@ -559,7 +597,7 @@ sub process_arguments(){
}
if (defined $opt_M) {
- if ($opt_M =~ /^(sendmail|qmail|postfix|exim)$/) {
+ if ($opt_M =~ /^(sendmail|qmail|postfix|exim|nullmailer)$/) {
$mailq = $opt_M ;
}elsif( $opt_M eq ''){
$mailq = 'sendmail';
@@ -568,7 +606,30 @@ sub process_arguments(){
exit $ERRORS{'UNKNOWN'};
}
}else{
- $mailq = 'sendmail' ;
+ if (defined $utils::PATH_TO_QMAIL_QSTAT
+ && -x $utils::PATH_TO_QMAIL_QSTAT)
+ {
+ $mailq = 'qmail';
+ }
+ elsif (-d '/var/lib/postfix' || -d '/var/local/lib/postfix'
+ || -e '/usr/sbin/postfix' || -e '/usr/local/sbin/postfix')
+ {
+ $mailq = 'postfix';
+ }
+ elsif (-d '/usr/lib/exim4' || -d '/usr/local/lib/exim4'
+ || -e '/usr/sbin/exim' || -e '/usr/local/sbin/exim')
+ {
+ $mailq = 'exim';
+ }
+ elsif (-d '/usr/lib/nullmailer' || -d '/usr/local/lib/nullmailer'
+ || -e '/usr/sbin/nullmailer-send'
+ || -e '/usr/local/sbin/nullmailer-send')
+ {
+ $mailq = 'nullmailer';
+ }
+ else {
+ $mailq = 'sendmail';
+ }
}
return $ERRORS{'OK'};
@@ -591,7 +652,7 @@ sub print_help () {
print "-W (--Warning) = Min. number of messages for same domain in queue to generate warning\n";
print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
- print "-M (--mailserver) = [ sendmail | qmail | postfix | exim ] (default = sendmail)\n";
+ print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n";
print "-h (--help)\n";
print "-V (--version)\n";
print "-v (--verbose) = debugging output\n";
@@ -599,6 +660,8 @@ sub print_help () {
print "Note: -w and -c are required arguments. -W and -C are optional.\n";
print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n";
print " -W and -C are applied message not yet preproccessed. (qmail)\n";
+ print " This plugin tries to autodetect which mailserver you are running,\n";
+ print " you can override the autodetection with -M.\n";
print " This plugin uses the system mailq command (sendmail) or qmail-stat (qmail)\n";
print " to look at the queues. Mailq can usually only be accessed by root or \n";
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 4486149d..cf23ae82 100755
--- a/plugins-scripts/check_mssql.pl
+++ b/plugins-scripts/check_mssql.pl
@@ -21,7 +21,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-# Report bugs to: nagiosplug-help@lists.sourceforge.net
+# Report bugs to: help@monitoring-plugins.org
#
#
@@ -48,7 +48,7 @@ my $exitcode = $ERRORS{'OK'};
process_arguments();
-# Just in case of problems, let's not hang Nagios
+# Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print ("SQL UNKNOWN: ERROR connection $server (alarm timeout)\n");
exit $ERRORS{"UNKNOWN"};
diff --git a/plugins-scripts/check_netdns.pl b/plugins-scripts/check_netdns.pl
index 9871a9a5..6e0d02d1 100755
--- a/plugins-scripts/check_netdns.pl
+++ b/plugins-scripts/check_netdns.pl
@@ -27,7 +27,8 @@
use Getopt::Long;
use Net::DNS;
-use lib utils.pm;
+use FindBin;
+use lib "$FindBin::Bin";
use utils ;
my $PROGNAME = "check_netdns";
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh
index f5302e3b..efa1df19 100755
--- a/plugins-scripts/check_oracle.sh
+++ b/plugins-scripts/check_oracle.sh
@@ -3,7 +3,7 @@
# latigid010@yahoo.com
# 01/06/2000
#
-# This Nagios plugin was created to check Oracle status
+# This Monitoring plugin was created to check Oracle status
#
PROGNAME=`basename $0`
@@ -164,7 +164,7 @@ case "$cmd" in
}'
;;
--db)
- pmonchk=`ps -ef | grep -v grep | grep -c "ora_pmon_${2}$"`
+ pmonchk=`ps -ef | grep -v grep | grep -E -c "(asm|ora)_pmon_${2}$"`
if [ ${pmonchk} -ge 1 ] ; then
echo "${2} OK - ${pmonchk} PMON process(es) running"
exit $STATE_OK
diff --git a/plugins-scripts/check_rpc.pl b/plugins-scripts/check_rpc.pl
index e09754dd..f7fe0321 100755
--- a/plugins-scripts/check_rpc.pl
+++ b/plugins-scripts/check_rpc.pl
@@ -1,6 +1,6 @@
#!/usr/local/bin/perl -w
#
-# check_rpc plugin for nagios
+# check_rpc plugin for monitoring
#
# usage:
# check_rpc host service
@@ -20,7 +20,8 @@
#
use strict;
-use lib utils.pm;
+use FindBin;
+use lib "$FindBin::Bin";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME);
my ($verbose,@proto,%prognum,$host,$response,$prognum,$port,$cmd,$progver,$state);
@@ -254,7 +255,7 @@ $proto = 't' if ($opt_t);
$proto = 'u' if ($opt_u);
-# Just in case of problems, let's not hang Nagios
+# Just in case of problems, let's not hang the monitoring system
$SIG{'ALRM'} = sub {
print ("ERROR: No response from RPC server (alarm)\n");
exit $ERRORS{"UNKNOWN"};
diff --git a/plugins-scripts/check_wave.pl b/plugins-scripts/check_wave.pl
index 8f9a4da3..51927534 100755
--- a/plugins-scripts/check_wave.pl
+++ b/plugins-scripts/check_wave.pl
@@ -3,7 +3,8 @@
use strict;
-use lib utils.pm;
+use FindBin;
+use lib "$FindBin::Bin";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
use vars qw($PROGNAME);
use Getopt::Long;
diff --git a/plugins-scripts/subst.in b/plugins-scripts/subst.in
index 49a95ca1..c730b770 100644
--- a/plugins-scripts/subst.in
+++ b/plugins-scripts/subst.in
@@ -19,19 +19,6 @@ function which(c,path) {
return c;
}
-# used to replace "use lib utils.pm" with "use lib @libexecdir"
-#
-function led() {
- led1 = "@libexecdir@";
- led2 = "@exec_prefix@";
- led3 = "@prefix@";
- if ( match(led1, /^\$\{exec_prefix\}/ ) != 0 ) {
- return "\"" led3 "/libexec\" " ;
-
- }
- return "\"" led1 "\"" ;
-}
-
BEGIN {
split(ENVIRON["PATH"] ":/sbin:/usr/sbin",path,/:/);
@@ -58,9 +45,6 @@ BEGIN {
sub(c,which(c,path));
}
-# add to libexecdir to INC for perl utils.pm
-/^use/ { if (/lib/) { if (/utils.pm|"."/ ) {sub(/utils.pm|"."/,led() )} } }
-
# Trusted path mechanism
/@trusted_path@/ {sub(/@trusted_path@/,"@with_trusted_path@");}
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 @@
#
use strict;
-use Test::More tests => 15;
+use Test::More tests => 16;
use NPTest;
my $successOutput = '/^FILE_AGE OK: /';
@@ -58,6 +58,11 @@ $result = NPTest->testCmd(
cmp_ok( $result->return_code, '==', 0, "Checking file size" );
$result = NPTest->testCmd(
+ "./check_file_age -f /non/existent --ignore-missing"
+ );
+cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" );
+
+$result = NPTest->testCmd(
"./check_file_age -f $temp_file -c 1000 -W 101"
);
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 37cd62c3..0f53243c 100644
--- a/plugins-scripts/utils.pm.in
+++ b/plugins-scripts/utils.pm.in
@@ -1,6 +1,6 @@
-# Utility drawer for Nagios plugins.
+# Utility drawer for Monitoring Plugins.
#
-# This will be deprecated soon. Please use Nagios::Plugin from CPAN
+# This will be deprecated soon. Please use Monitoring::Plugin from CPAN
# for new plugins
package 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
STATE_UNKNOWN=3
STATE_DEPENDENT=4
-if test -x /usr/bin/printf; then
- ECHO=/usr/bin/printf
-else
- ECHO=echo
-fi
-
print_revision() {
echo "$1 v$2 (@PACKAGE@ @VERSION@)"
- $ECHO "@WARRANTY@" | sed -e 's/\n/ /g'
+ printf '%b' "@WARRANTY@"
}
support() {
- $ECHO "@SUPPORT@" | sed -e 's/\n/ /g'
+ printf '%b' "@SUPPORT@"
}
#