File: exim_mailqueue_alt.in

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (82 lines) | stat: -rw-r--r-- 1,821 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!@@GOODSH@@
# -*- sh -*-

: << =cut

=head1 NAME

exim_mailqueue_alt - Plugin to monitor the exim mail queue

=head1 CONFIGURATION

The following environment variables are used by this plugin:

 exim      - exim binary location
 queuewarn - warning limit
 queuecrit - critical limit

The plugin needs to be run as the same user as exim, commonly "mail".

=head2 EXAMPLE CONFIGURATION

 [exim_mailqueue_alt]
  user mail
  env.queuewarn  2000
  env.queuecrit 10000

For a Debian based system, a minimal example configuration would be:

 [exim_mailqueue_alt]
  user Debian-exim

=head1 AUTHOR

Unknown author

=head1 LICENSE

GPLv2

=head1 MAGIC MARKERS

 #%# family=contrib
 #%# capabilities=

=cut

PATH='/bin:/sbin:/usr/bin:/usr/sbin'

QUEUECRIT=200
EXIM=${exim:-$(command -v exim || command -v exim4)}
QUEUEWARN=${queuewarn:-100}
QUEUECRIT=${queuecrit:-200}

if [ "$1" = "config" ]; then
	echo 'graph_title Exim mailqueue'
	echo 'graph_args --base 1000 -l 0'
	echo 'graph_vlabel mails in queue'
	echo 'graph_order frozen active bounces total'
	echo 'graph_category exim'
	echo 'active.label active'
	echo 'active.draw STACK'
	echo 'bounces.label bounces'
	echo 'bounces.draw LINE2'
	echo 'frozen.label frozen'
	echo 'frozen.draw AREA'
	echo 'total.label total'
	echo 'total.draw LINE2'
	echo "total.warning $QUEUEWARN"
	echo "total.critical $QUEUECRIT"
	exit 0
fi

$EXIM -bpr | awk 'BEGIN { bounces = 0; frozen = 0; total = 0 }
                  $4 == "<>" { bounces++; }
                  $6 == "frozen" { frozen++ }
                  /<[^>]*>/ { total++ }
                  END {
                      print "frozen.value " frozen;
                      print "bounces.value " bounces;
                      print "total.value " total;
                      print "active.value " total - frozen;
                  }'