--- a/check_mailq.pl Wed Jan 20 10:55:43 2016 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-#! /usr/bin/perl -w
-# $Id$
-# $URL$
-
-use strict;
-use warnings;
-
-use File::Basename;
-use Getopt::Long;
-use POSIX qw(:sys_wait_h);
-use lib "/usr/lib/nagios/plugins";
-use utils qw (%ERRORS &print_revision &support);
-
-sub print_help();
-sub print_usage();
-
-my $ME = basename $0;
-my ( $opt_w, $opt_c, $opt_s, $opt_V, $opt_h, $opt_b );
-my ( $result, $mailq );
-
-$opt_s = "86400";
-$opt_w = "10";
-$opt_c = "20";
-$opt_b = "/usr/sbin/exipick";
-
-Getopt::Long::Configure('bundling');
-GetOptions(
- "V" => \$opt_V,
- "version" => \$opt_V,
- "h" => \$opt_h,
- "help" => \$opt_h,
- "b=s" => \$opt_b,
- "binary" => \$opt_b,
- "s=i" => \$opt_s,
- "seconds" => \$opt_s,
- "w=i" => \$opt_w,
- "warning=i" => \$opt_w,
- "c=i" => \$opt_c,
- "critical=i" => \$opt_c
-);
-
-if ($opt_V) {
- print_revision( $ME, "1.1" );
- exit $ERRORS{"OK"};
-}
-
-if ($opt_h) {
- print_help();
- exit $ERRORS{"OK"};
-}
-
-if ( $opt_w > $opt_c ) {
- print
- "MAILQ CRITICAL: Warning (-w) cannot be greater than Critical (-c)!\n";
- exit $ERRORS{"CRITICAL"};
-}
-
-# check exipick binary
-unless ( -x $opt_b ) {
- print "MAILQ CRITICAL: exipick not found or not executable - $opt_b\n";
- exit $ERRORS{"CRITICAL"};
-}
-
-$SIG{CHLD} = sub {
- while (waitpid(-1, WNOHANG) > 0) {};
-};
-
-# check the mailq
-die "Can't fork: $!" unless defined (my $pid = open(F, "-|"));
-if ($pid) {
- <F> =~ /^(\d+).*/;
- $mailq = $1;
- close F;
-} else {
- exec $opt_b, '-o', $opt_s, '-c', @ARGV
- or die "can't exec $opt_b: $!";
-}
-
-SWITCH: {
- $mailq < $opt_w and $result = "OK", last;
- $mailq >= $opt_c and $result = "CRITICAL", last;
- $mailq >= $opt_w and $result = "WARNING", last;
-}
-
-print
-"MAILQ $result: ($mailq) queued mails older than $opt_s sec.|unsent=$mailq;$opt_w;$opt_c;0;0\n";
-exit $ERRORS{$result};
-
-sub print_usage() {
- print "Usage:\n";
- print " $ME [-b <binary>] [-s <sec>] [-w <warn>] [-c <crit>] [<exipick criterion> [<exipick criterion> ... ]]\n";
- print " $ME [-h | --help]\n";
- print " $ME [-V | --version]\n";
-}
-
-sub print_help() {
- print_revision( $ME, "1.1" );
- print "Copyright (c) 2008 Christian Arnold\n";
- print "Copyright (c) 2015 Matthias Förste\n\n";
- print "This plugin checks the number of messages, which are longer than\n";
- print "an specified time holding in the mail queue.\n\n";
- print_usage();
- print "\n";
- print " -b, --binary <binary>\n";
- print " Path of exipick binary (default: /usr/sbin/exipick)\n";
- print " -s, --seconds <sec>\n";
- print " Age of messages in seconds in the mail queue (default: 86400) one day\n";
- print " -w, --warning <warn>\n";
- print " Min. number of messages in the mail queue to generate warning alert (default: 10)\n";
- print " -c, --critical <crit>\n";
- print " Min. number of messages in the mail queue to generate critical alert (default: 20)\n";
- print "\n";
- print "Note: This plugin only works with exim4.\n\n";
- support();
-}