3
# check_qmailq.pl - nagios plugin
4
# This plugin allows you to check the number of Mails in a qmail-
5
# queue. PLUGIN NEEDS CONFIGURATION ! (see below)
7
# Copyright 2000 Benjamin Schmid
9
# This program is free software; you can redistribute it and/or
10
# modify it under the terms of the GNU General Public License
11
# as published by the Free Software Foundation; either version 2
12
# of the License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License
20
# along with this program; if not, write to the Free Software
21
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
# Emergency E-Mail :) blueshift@gmx.net
27
### CONFIGURATION SECTION ####################
29
my $statcommand = "/var/qmail/bin/qmail-qstat";
30
my $queuewarn = 5; # Warning, if more than x mail in Queue
31
my $queuecrit = 10; # Critical if "--"
32
my $prewarn = 1; # Warning, if more than x unhandled mails
34
my $precrit = 5; # Critical, if "--"
36
### CONFIURATION SECTION END ################
42
#&Getopt::Long::config('auto_abbrev');
48
my %ERRORS = ('UNKNOWN' , '-1',
53
my $state = "UNKNOWN";
57
# printf "\nMissing arguments!\n";
59
# printf "Printer Server Queue Nagios Plugin\n";
60
# printf "monitors jobs in lpr queues\n";
62
# printf "check_lpq.pl \n";
63
# printf "Copyright (C) 2000 Benjamin Schmid\n";
64
# printf "check_lpq.pl comes with ABSOLUTELY NO WARRANTY\n";
65
# printf "This programm is licensed under the terms of the ";
66
# printf "GNU General Public License\n(check source code for details)\n";
68
# exit $ERRORS{"UNKNOWN"};
71
# Just in case of problems, let's not hang Nagios
73
print ("ERROR: check_lpq.pl Time-Out $TIMEOUT s \n");
74
exit $ERRORS{"UNKNOWN"};
79
#$status = GetOptions("community=s",\$community,
86
# $hostname = shift || &usage;
88
if (! open STAT, "$statcommand|") {
89
print ("$state: $statcommand returns no result!");
96
if ($lines[0]=~/^messages in queue: (\d+)/) {
98
$answer = $answer . "$anzq";
99
$state='WARNING' if ($anzq >= $queuewarn);
100
$state='CRITICAL' if ($anzq >= $queuecrit);
103
$answer="Keine gueltigte Antwort (Zeile #1) von $statcommand\n";
107
if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) {
109
$answer = $answer . " E-Mail(s) nicht ausgeliefert, $anzp unverarbeitet.";
110
$state='WARNING' if ($anzp >= $prewarn && $state eq 'UNKNOWN');
111
$state='CRITICAL' if ($anzp >= $precrit);
114
$answer=$answer . "Keine gueltigte Antwort (Zeile #2) von $statcommand\n";
117
$state = 'OK' if ($state eq 'UNKNOWN');
119
print ("$state: $answer\n");
120
exit $ERRORS{$state};