Initial check-in.
[monitoring/munin.git] / thh_exim_mailqueue
1 #!/bin/sh
2 #
3 # Plugin to monitor exim queue size
4 #
5 # Usage: Copy or link into /etc/munin/node.d/
6 #
7 # Parameters:
8 #
9 #       config   (required)
10 #       autoconf (optional - used by munin-config)
11 #
12 # Config variables:
13 #
14 #       spooldir     - Override what exim says
15 #       exim         - Where's exim?
16 #       queuewarn    - When to warn
17 #       queuecrit    - When to crit
18 #
19 # $Log$
20 # Revision 1.4  2004/11/10 15:47:10  jimmyo
21 # Made graph_title a parameter for generic/exim_mailqueue (patch by Torstein T. Svendsen, SF#1060834).
22 #
23 # Revision 1.3  2004/05/20 13:57:12  jimmyo
24 # Set categories to some of the plugins.
25 #
26 # Revision 1.2  2004/01/29 19:39:00  jimmyo
27 # Generic plugins now use printf instead of echo -n, as this is more portable (SF#885564)
28 #
29 # Revision 1.1  2004/01/02 18:50:00  jimmyo
30 # Renamed occurrances of lrrd -> munin
31 #
32 # Revision 1.1.1.1  2004/01/02 15:18:07  jimmyo
33 # Import of LRRD CVS tree after renaming to Munin
34 #
35 # Revision 1.5  2003/11/07 17:43:16  jimmyo
36 # Cleanups and log entries
37 #
38 #
39 #
40 # Magic markers (optional - used by installation scripts and
41 # munin-config):
42 #
43 #%# family=auto
44 #%# capabilities=autoconf
45
46 DIRNAME=`dirname $0`
47 SPOOLDIR='/var/spool/exim'
48 #EXIM=`which exim 2>/dev/null || which exim4 2>/dev/null`
49 EXIM='/usr/exim/bin/exim'
50 QUEUEWARN=100
51 QUEUECRIT=200
52 GRAPHTITLE='Exim Mailqueue'
53
54 if [ "$spooldir"  ]; then  SPOOLDIR=$spooldir ; fi
55 if [ "$exim"      ]; then      EXIM=$exim     ; fi
56 if [ "$queuewarn" ]; then QUEUEWARN=$queuewarn; fi
57 if [ "$queuecrit" ]; then QUEUECRIT=$queuecrit; fi
58 if [ "$graphtitle" ]; then GRAPHTITLE=$graphtitle; fi
59
60 if [ "$SPOOLDIR" = "unset" ]
61 then
62         SPOOLDIR=`($EXIM -bP spool_directory | awk '{ print $3 "/input" }') 2>/dev/null`
63 fi
64
65 if [ "$1" = "autoconf" ]; then
66         if ( $EXIM -bV 2>/dev/null >/dev/null ); then
67                 if ( /usr/bin/find $SPOOLDIR -iname "*-H" -print 2>/dev/null >/dev/null ); then
68                         echo yes
69                         exit 0
70                 else
71                         if [ $? -eq 1 ]; then
72                                 echo "no (permission denied on spooldir)"
73                                 exit 1
74                         else
75                                 echo "no"
76                                 exit 1
77                         fi
78                 fi
79         else
80                 if [ $? -eq 127 ]
81                 then
82                         echo "no (exim not found)"
83                         exit 1
84                 else
85                         echo no
86                         exit 1
87                 fi
88         fi
89 fi
90
91 if [ "$1" = "config" ]; then
92         if [ ! -z $SPOOLDIR ];then
93         echo "graph_title $GRAPHTITLE"
94         echo 'graph_args --base 1000 -l 0'
95         echo 'graph_vlabel mails in queue'
96         echo 'graph_category Mail'
97         echo 'mails.label mails'
98         echo 'mails.draw AREA'
99         echo "mails.warning $QUEUEWARN"
100         echo "mails.critical $QUEUECRIT"
101         fi;
102         exit 0
103 fi
104
105 printf "mails.value "
106 /usr/bin/find $SPOOLDIR -iname "*-H" -print 2>/dev/null |wc -l | sed 's/ *//'
This page took 0.012446 seconds and 3 git commands to generate.