summaryrefslogtreecommitdiffstats
path: root/contrib/check_qmailq.pl
diff options
context:
space:
mode:
authorEthan Galstad <egalstad@users.sourceforge.net>2002-02-28 06:42:51 (GMT)
committerEthan Galstad <egalstad@users.sourceforge.net>2002-02-28 06:42:51 (GMT)
commit44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (patch)
treea1a4d9f7b92412a17ab08f34f04eec45433048b7 /contrib/check_qmailq.pl
parent54fd5d7022ff2d6a59bc52b8869182f3fc77a058 (diff)
downloadmonitoring-plugins-44a321cb8a42d6c0ea2d96a1086a17f2134c89cc.tar.gz
Initial revision
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/check_qmailq.pl')
-rwxr-xr-xcontrib/check_qmailq.pl121
1 files changed, 121 insertions, 0 deletions
diff --git a/contrib/check_qmailq.pl b/contrib/check_qmailq.pl
new file mode 100755
index 0000000..4c3f68f
--- /dev/null
+++ b/contrib/check_qmailq.pl
@@ -0,0 +1,121 @@
1#!/usr/bin/perl
2#
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)
6#
7# Copyright 2000 Benjamin Schmid
8#
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.
13#
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.
18#
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.
22#
23#
24# Emergency E-Mail :) blueshift@gmx.net
25#
26
27### CONFIGURATION SECTION ####################
28
29my $statcommand = "/var/qmail/bin/qmail-qstat";
30my $queuewarn = 5; # Warning, if more than x mail in Queue
31my $queuecrit = 10; # Critical if "--"
32my $prewarn = 1; # Warning, if more than x unhandled mails
33 # (not in Queue
34my $precrit = 5; # Critical, if "--"
35
36### CONFIURATION SECTION END ################
37
38use strict;
39use Carp;
40
41#use Getopt::Long;
42#&Getopt::Long::config('auto_abbrev');
43
44
45
46my $TIMEOUT = 15;
47
48my %ERRORS = ('UNKNOWN' , '-1',
49 'OK' , '0',
50 'WARNING', '1',
51 'CRITICAL', '2');
52
53my $state = "UNKNOWN";
54my $answer = "";
55
56#sub usage {
57# printf "\nMissing arguments!\n";
58# printf "\n";
59# printf "Printer Server Queue Nagios Plugin\n";
60# printf "monitors jobs in lpr queues\n";
61# printf "usage: \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";
67# printf "\n\n";
68# exit $ERRORS{"UNKNOWN"};
69#}
70
71# Just in case of problems, let's not hang Nagios
72$SIG{'ALRM'} = sub {
73 print ("ERROR: check_lpq.pl Time-Out $TIMEOUT s \n");
74 exit $ERRORS{"UNKNOWN"};
75};
76alarm($TIMEOUT);
77
78
79#$status = GetOptions("community=s",\$community,
80# "port=i",\$port);
81#if ($status == 0)
82#{
83# &usage;
84#}
85
86# $hostname = shift || &usage;
87
88if (! open STAT, "$statcommand|") {
89 print ("$state: $statcommand returns no result!");
90 exit $ERRORS{$state};
91}
92my @lines = <STAT>;
93close STAT;
94
95# Mails in Queues
96if ($lines[0]=~/^messages in queue: (\d+)/) {
97 my $anzq = $1;
98 $answer = $answer . "$anzq";
99 $state='WARNING' if ($anzq >= $queuewarn);
100 $state='CRITICAL' if ($anzq >= $queuecrit);
101} else {
102 $state='CRITICAL';
103 $answer="Keine gueltigte Antwort (Zeile #1) von $statcommand\n";
104}
105
106# Unverarbeite Mails
107if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) {
108 my $anzp = $1;
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);
112} else {
113 $state='CRITICAL';
114 $answer=$answer . "Keine gueltigte Antwort (Zeile #2) von $statcommand\n";
115}
116
117$state = 'OK' if ($state eq 'UNKNOWN');
118
119print ("$state: $answer\n");
120exit $ERRORS{$state};
121