summaryrefslogtreecommitdiffstats
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 58db060..4ea262a 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 \
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
diff --git a/plugins-scripts/check_breeze.pl b/plugins-scripts/check_breeze.pl
index 037060c..917a1c6 100755
--- a/plugins-scripts/check_breeze.pl
+++ b/plugins-scripts/check_breeze.pl
@@ -4,7 +4,8 @@
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";
diff --git a/plugins-scripts/check_disk_smb.pl b/plugins-scripts/check_disk_smb.pl
index 01c560e..36259d5 100755
--- a/plugins-scripts/check_disk_smb.pl
+++ b/plugins-scripts/check_disk_smb.pl
@@ -3,7 +3,7 @@
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 ();
@@ -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 37bbe86..e028038 100755
--- a/plugins-scripts/check_file_age.pl
+++ b/plugins-scripts/check_file_age.pl
@@ -17,9 +17,8 @@
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;
@@ -32,7 +31,7 @@ use utils qw (%ERRORS &print_revision &support);
32sub print_help (); 31sub print_help ();
33sub print_usage (); 32sub print_usage ();
34 33
35my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V); 34my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V, $opt_i);
36my ($result, $message, $age, $size, $st); 35my ($result, $message, $age, $size, $st);
37 36
38$PROGNAME="check_file_age"; 37$PROGNAME="check_file_age";
@@ -51,6 +50,7 @@ Getopt::Long::Configure('bundling');
51GetOptions( 50GetOptions(
52 "V" => \$opt_V, "version" => \$opt_V, 51 "V" => \$opt_V, "version" => \$opt_V,
53 "h" => \$opt_h, "help" => \$opt_h, 52 "h" => \$opt_h, "help" => \$opt_h,
53 "i" => \$opt_i, "ignore-missing" => \$opt_i,
54 "f=s" => \$opt_f, "file" => \$opt_f, 54 "f=s" => \$opt_f, "file" => \$opt_f,
55 "w=f" => \$opt_w, "warning-age=f" => \$opt_w, 55 "w=f" => \$opt_w, "warning-age=f" => \$opt_w,
56 "W=f" => \$opt_W, "warning-size=f" => \$opt_W, 56 "W=f" => \$opt_W, "warning-size=f" => \$opt_W,
@@ -76,8 +76,15 @@ if (! $opt_f) {
76 76
77# Check that file exists (can be directory or link) 77# Check that file exists (can be directory or link)
78unless (-e $opt_f) { 78unless (-e $opt_f) {
79 print "FILE_AGE CRITICAL: File not found - $opt_f\n"; 79 if ($opt_i) {
80 exit $ERRORS{'CRITICAL'}; 80 $result = 'OK';
81 print "FILE_AGE $result: $opt_f doesn't exist, but ignore-missing was set\n";
82 exit $ERRORS{$result};
83
84 } else {
85 print "FILE_AGE CRITICAL: File not found - $opt_f\n";
86 exit $ERRORS{'CRITICAL'};
87 }
81} 88}
82 89
83$st = File::stat::stat($opt_f); 90$st = File::stat::stat($opt_f);
@@ -99,7 +106,7 @@ exit $ERRORS{$result};
99 106
100sub print_usage () { 107sub print_usage () {
101 print "Usage:\n"; 108 print "Usage:\n";
102 print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] -f <file>\n"; 109 print " $PROGNAME [-w <secs>] [-c <secs>] [-W <size>] [-C <size>] [-i] -f <file>\n";
103 print " $PROGNAME [-h | --help]\n"; 110 print " $PROGNAME [-h | --help]\n";
104 print " $PROGNAME [-V | --version]\n"; 111 print " $PROGNAME [-V | --version]\n";
105} 112}
@@ -109,6 +116,7 @@ sub print_help () {
109 print "Copyright (c) 2003 Steven Grimm\n\n"; 116 print "Copyright (c) 2003 Steven Grimm\n\n";
110 print_usage(); 117 print_usage();
111 print "\n"; 118 print "\n";
119 print " -i | --ignore-missing : return OK if the file does not exist\n";
112 print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; 120 print " <secs> File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n";
113 print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n"; 121 print " <size> File must be at least this many bytes long (default: crit 0 bytes)\n";
114 print "\n"; 122 print "\n";
diff --git a/plugins-scripts/check_flexlm.pl b/plugins-scripts/check_flexlm.pl
index 0597377..de63d3a 100755
--- a/plugins-scripts/check_flexlm.pl
+++ b/plugins-scripts/check_flexlm.pl
@@ -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";
@@ -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 452911b..159eb62 100755
--- a/plugins-scripts/check_ifoperstatus.pl
+++ b/plugins-scripts/check_ifoperstatus.pl
@@ -1,9 +1,9 @@
1#!/usr/local/bin/perl -w 1#!/usr/local/bin/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;
@@ -101,7 +103,7 @@ my %session_opts;
101$status = process_arguments(); 103$status = process_arguments();
102 104
103 105
104# Just in case of problems, let's not hang Nagios 106# Just in case of problems, let's not hang the monitoring system
105$SIG{'ALRM'} = sub { 107$SIG{'ALRM'} = sub {
106 print ("ERROR: No snmp response from $hostname (alarm)\n"); 108 print ("ERROR: No snmp response from $hostname (alarm)\n");
107 exit $ERRORS{"UNKNOWN"}; 109 exit $ERRORS{"UNKNOWN"};
@@ -292,7 +294,7 @@ sub print_usage() {
292sub print_help() { 294sub print_help() {
293 print_revision($PROGNAME, '@NP_VERSION@'); 295 print_revision($PROGNAME, '@NP_VERSION@');
294 print_usage(); 296 print_usage();
295 printf "check_ifoperstatus plugin for Nagios monitors operational \n"; 297 printf "check_ifoperstatus plugin for monitoring operational \n";
296 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";
297 printf "\nUsage:\n"; 299 printf "\nUsage:\n";
298 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 421580a..4760a28 100755
--- a/plugins-scripts/check_ifstatus.pl
+++ b/plugins-scripts/check_ifstatus.pl
@@ -1,10 +1,10 @@
1#!/usr/local/bin/perl -w 1#!/usr/local/bin/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;
@@ -102,7 +103,7 @@ my %session_opts;
102 103
103 104
104 105
105# Just in case of problems, let's not hang Nagios 106# Just in case of problems, let's not hang the monitoring system
106$SIG{'ALRM'} = sub { 107$SIG{'ALRM'} = sub {
107 print ("ERROR: No snmp response from $hostname (alarm timeout)\n"); 108 print ("ERROR: No snmp response from $hostname (alarm timeout)\n");
108 exit $ERRORS{"UNKNOWN"}; 109 exit $ERRORS{"UNKNOWN"};
@@ -242,7 +243,7 @@ sub print_usage() {
242sub print_help() { 243sub print_help() {
243 print_revision($PROGNAME, '@NP_VERSION@'); 244 print_revision($PROGNAME, '@NP_VERSION@');
244 print_usage(); 245 print_usage();
245 printf "check_ifstatus plugin for Nagios monitors operational \n"; 246 printf "check_ifstatus plugin for monitoring operational \n";
246 printf "status of each network interface on the target host\n"; 247 printf "status of each network interface on the target host\n";
247 printf "\nUsage:\n"; 248 printf "\nUsage:\n";
248 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 f80c5c6..dab6595 100755
--- a/plugins-scripts/check_ircd.pl
+++ b/plugins-scripts/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 ]--
@@ -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 a9ff06a..be4c7be 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
@@ -58,7 +58,6 @@
58# Paths to commands used in this script. These 58# Paths to commands used in this script. These
59# may have to be modified to match your system setup. 59# may have to be modified to match your system setup.
60 60
61ECHO="/bin/echo"
62GREP="/bin/egrep" 61GREP="/bin/egrep"
63DIFF="/bin/diff" 62DIFF="/bin/diff"
64TAIL="/bin/tail" 63TAIL="/bin/tail"
@@ -85,7 +84,7 @@ print_help() {
85 echo "" 84 echo ""
86 print_usage 85 print_usage
87 echo "" 86 echo ""
88 echo "Log file pattern detector plugin for Nagios" 87 echo "Log file pattern detector plugin for monitoring"
89 echo "" 88 echo ""
90 support 89 support
91} 90}
@@ -166,10 +165,10 @@ done
166# If the source log file doesn't exist, exit 165# If the source log file doesn't exist, exit
167 166
168if [ ! -e $logfile ]; then 167if [ ! -e $logfile ]; then
169 $ECHO "Log check error: Log file $logfile does not exist!\n" 168 echo "Log check error: Log file $logfile does not exist!"
170 exit $STATE_UNKNOWN 169 exit $STATE_UNKNOWN
171elif [ ! -r $logfile ] ; then 170elif [ ! -r $logfile ] ; then
172 $ECHO "Log check error: Log file $logfile is not readable!\n" 171 echo "Log check error: Log file $logfile is not readable!"
173 exit $STATE_UNKNOWN 172 exit $STATE_UNKNOWN
174fi 173fi
175 174
@@ -179,7 +178,7 @@ fi
179 178
180if [ ! -e $oldlog ]; then 179if [ ! -e $oldlog ]; then
181 $CAT $logfile > $oldlog 180 $CAT $logfile > $oldlog
182 $ECHO "Log check data initialized...\n" 181 echo "Log check data initialized..."
183 exit $STATE_OK 182 exit $STATE_OK
184fi 183fi
185 184
@@ -208,10 +207,10 @@ $RM -f $tempdiff
208$CAT $logfile > $oldlog 207$CAT $logfile > $oldlog
209 208
210if [ "$count" = "0" ]; then # no matches, exit with no error 209if [ "$count" = "0" ]; then # no matches, exit with no error
211 $ECHO "Log check ok - 0 pattern matches found\n" 210 echo "Log check ok - 0 pattern matches found"
212 exitstatus=$STATE_OK 211 exitstatus=$STATE_OK
213else # Print total matche count and the last entry we found 212else # Print total matche count and the last entry we found
214 $ECHO "($count) $lastentry" 213 echo "($count) $lastentry"
215 exitstatus=$STATE_CRITICAL 214 exitstatus=$STATE_CRITICAL
216fi 215fi
217 216
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl
index 1d0a3ad..488cf2f 100755
--- a/plugins-scripts/check_mailq.pl
+++ b/plugins-scripts/check_mailq.pl
@@ -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
@@ -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 4486149..cf23ae8 100755
--- a/plugins-scripts/check_mssql.pl
+++ b/plugins-scripts/check_mssql.pl
@@ -21,7 +21,7 @@
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
@@ -48,7 +48,7 @@ my $exitcode = $ERRORS{'OK'};
48 48
49process_arguments(); 49process_arguments();
50 50
51# Just in case of problems, let's not hang Nagios 51# Just in case of problems, let's not hang the monitoring system
52$SIG{'ALRM'} = sub { 52$SIG{'ALRM'} = sub {
53 print ("SQL UNKNOWN: ERROR connection $server (alarm timeout)\n"); 53 print ("SQL UNKNOWN: ERROR connection $server (alarm timeout)\n");
54 exit $ERRORS{"UNKNOWN"}; 54 exit $ERRORS{"UNKNOWN"};
diff --git a/plugins-scripts/check_netdns.pl b/plugins-scripts/check_netdns.pl
index 9871a9a..6e0d02d 100755
--- a/plugins-scripts/check_netdns.pl
+++ b/plugins-scripts/check_netdns.pl
@@ -27,7 +27,8 @@
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";
diff --git a/plugins-scripts/check_oracle.sh b/plugins-scripts/check_oracle.sh
index f5302e3..efa1df1 100755
--- a/plugins-scripts/check_oracle.sh
+++ b/plugins-scripts/check_oracle.sh
@@ -3,7 +3,7 @@
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`
@@ -164,7 +164,7 @@ case "$cmd" in
164 }' 164 }'
165 ;; 165 ;;
166--db) 166--db)
167 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}$"`
168 if [ ${pmonchk} -ge 1 ] ; then 168 if [ ${pmonchk} -ge 1 ] ; then
169 echo "${2} OK - ${pmonchk} PMON process(es) running" 169 echo "${2} OK - ${pmonchk} PMON process(es) running"
170 exit $STATE_OK 170 exit $STATE_OK
diff --git a/plugins-scripts/check_rpc.pl b/plugins-scripts/check_rpc.pl
index e09754d..f7fe032 100755
--- a/plugins-scripts/check_rpc.pl
+++ b/plugins-scripts/check_rpc.pl
@@ -1,6 +1,6 @@
1#!/usr/local/bin/perl -w 1#!/usr/local/bin/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);
@@ -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_wave.pl b/plugins-scripts/check_wave.pl
index 8f9a4da..5192753 100755
--- a/plugins-scripts/check_wave.pl
+++ b/plugins-scripts/check_wave.pl
@@ -3,7 +3,8 @@
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;
diff --git a/plugins-scripts/subst.in b/plugins-scripts/subst.in
index 49a95ca..c730b77 100644
--- a/plugins-scripts/subst.in
+++ b/plugins-scripts/subst.in
@@ -19,19 +19,6 @@ function which(c,path) {
19 return c; 19 return c;
20} 20}
21 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 { 22BEGIN {
36 split(ENVIRON["PATH"] ":/sbin:/usr/sbin",path,/:/); 23 split(ENVIRON["PATH"] ":/sbin:/usr/sbin",path,/:/);
37 24
@@ -58,9 +45,6 @@ BEGIN {
58 sub(c,which(c,path)); 45 sub(c,which(c,path));
59} 46}
60 47
61# add to libexecdir to INC for perl utils.pm
62/^use/ { if (/lib/) { if (/utils.pm|"."/ ) {sub(/utils.pm|"."/,led() )} } }
63
64# Trusted path mechanism 48# Trusted path mechanism
65/@trusted_path@/ {sub(/@trusted_path@/,"@with_trusted_path@");} 49/@trusted_path@/ {sub(/@trusted_path@/,"@with_trusted_path@");}
66 50
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
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 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
6package utils; 6package 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
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#