Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / postfix / postfix-queue-size @ 17f78427

Historique | Voir | Annoter | Télécharger (2,92 ko)

1
#!/bin/sh
2
# -*- sh -*-
3

    
4
: << =cut
5

    
6
=head1 NAME
7

    
8
postfix_mailqueue - Plugin to monitor postfix mail spools
9

    
10
=head1 ABOUT
11

    
12
A guide to postfix mail queue manageent can be found at
13
L<http://www.postfix.org/QSHAPE_README.html#queues>
14

    
15
A summary:
16

    
17
=over 4
18

    
19
=item maildrop
20

    
21
Messages that have been submitted via the Postfix sendmail(1) command,
22
but not yet brought into the main Postfix queue by the pickup(8)
23
service.
24

    
25
=item hold
26

    
27
Messages placed in the "hold" queue stay there until the administrator
28
intervenes
29

    
30
=item incoming
31

    
32
Inbound mail from the network, or mail picked up by the local
33
pickup(8) daemon from the maildrop directory.
34

    
35
=item active
36

    
37
Messages that the queue manager has opened for delivery. Only a limited number
38
of messages is allowed to enter the active queue (leaky bucket strategy, for a
39
fixed delivery rate).
40

    
41
=item deferred
42

    
43
Mail that could not be delivered upon the first attempt. The queue manager
44
implements exponential backoff by doubling the time between delivery attempts.
45

    
46
=item corrupt
47

    
48
Unreadable or damaged queue files are moved here for inspection.
49

    
50
=back
51

    
52
=head1 CONFIGURATION
53

    
54
By default "postconf -h queue_directory" is used to determine the
55
spool directory.  Is postconf is not available in the $PATH then
56
/var/spool/postfix is assumed.  This can be overridden by the
57
"spooldir" environment variable like so:
58

    
59
 [postfix_mailqueue]
60
    env.spooldir /var/spool/postfix
61

    
62
=head1 AUTHOR
63

    
64
Unknown.
65

    
66
=head1 LICENSE
67

    
68
Unknown.
69

    
70
=head1 MAGIC MARKERS
71

    
72
=begin comment
73

    
74
These magic markers are used by munin-node-configure when installing
75
munin-node.
76

    
77
=end comment
78

    
79
 #%# family=auto
80
 #%# capabilities=autoconf
81

    
82
=cut
83

    
84
# atempt to get spooldir via postconf, but environment overrides.
85

    
86
# Remember that postconf is not available unless postfix is.
87
POSTCONFSPOOL="$(postconf -h queue_directory 2>/dev/null || echo /var/spool/postfix)"
88
SPOOLDIR=${spooldir:-$POSTCONFSPOOL}
89

    
90
. $MUNIN_LIBDIR/plugins/plugin.sh
91

    
92
case $1 in
93
    autoconf|detect)
94

    
95
	if [ -d $SPOOLDIR ] ; then
96
	    echo yes
97
	    exit 0
98
        else
99
	    echo "no (spooldir not found)"
100
	    exit 0
101
        fi;;
102
    config)
103
	cat <<'EOF'
104
graph_title Postfix Queue Size
105
graph_vlabel KB in Queue
106
graph_category mail
107
graph_total Total
108
active.label active
109
deferred.label deferred
110
maildrop.label maildrop
111
incoming.label incoming
112
corrupt.label corrupt
113
hold.label held
114
EOF
115
	for field in active deferred maildrop incoming corrupt hold; do
116
		print_warning $field
117
		print_critical $field
118
	done
119
	exit 0;;
120
esac
121

    
122
cd $SPOOLDIR >/dev/null 2>/dev/null || {
123
     echo "# Cannot cd to $SPOOLDIR"
124
     exit 1
125
}
126

    
127
cat <<EOF
128
deferred.value `du -sb $SPOOLDIR/* | grep deferred | awk '{print $1}'`
129
active.value `du -sb $SPOOLDIR/* | grep active | awk '{print $1}'`
130
maildrop.value `du -sb $SPOOLDIR/* | grep maildrop | awk '{print $1}'`
131
incoming.value `du -sb $SPOOLDIR/* | grep incoming | awk '{print $1}'`
132
corrupt.value `du -sb $SPOOLDIR/* | grep corrupt | awk '{print $1}'`
133
hold.value `du -sb $SPOOLDIR/* | grep hold | awk '{print $1}'`
134
EOF