root / plugins / postfix / postfix_mailqueue_ @ e5ce7492
Historique | Voir | Annoter | Télécharger (3,08 ko)
| 1 | a2c35ad7 | Clemens Schwaighofer | #!/bin/sh |
|---|---|---|---|
| 2 | # -*- sh -*- |
||
| 3 | |||
| 4 | : << =cut |
||
| 5 | |||
| 6 | =head1 NAME |
||
| 7 | |||
| 8 | postfix_mailqueue_ - Plugin to monitor postfix mail spools per running postfix |
||
| 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 | Uses the last part of the symlink name to get the postfix queue directory for the config file. |
||
| 55 | It then extract the queue path from the configuration file and uses it as a spooldir. |
||
| 56 | A environment spooldir can be set as a fallback. |
||
| 57 | |||
| 58 | [postfix_mailqueue] |
||
| 59 | env.spooldir /var/spool/postfix |
||
| 60 | |||
| 61 | =head1 AUTHOR |
||
| 62 | |||
| 63 | Unknown. |
||
| 64 | |||
| 65 | Extended to multiple queue use by Clemens Schwaighofer (gullevek@gullevek.org) in 2010. |
||
| 66 | |||
| 67 | =head1 LICENSE |
||
| 68 | |||
| 69 | Unknown. |
||
| 70 | |||
| 71 | =head1 MAGIC MARKERS |
||
| 72 | |||
| 73 | =begin comment |
||
| 74 | |||
| 75 | These magic markers are used by munin-node-configure when installing |
||
| 76 | munin-node. |
||
| 77 | |||
| 78 | =end comment |
||
| 79 | |||
| 80 | #%# family=auto |
||
| 81 | #%# capabilities=autoconf |
||
| 82 | |||
| 83 | =cut |
||
| 84 | |||
| 85 | # atempt to get spooldir via postconf, but environment overrides. |
||
| 86 | |||
| 87 | # Remember that postconf is not available unless postfix is. |
||
| 88 | CONFIG=${0##*postfix_mailqueue_}
|
||
| 89 | CONFIG="/etc/"$CONFIG"/" |
||
| 90 | POSTCONFSPOOL="$(postconf -c $CONFIG -h queue_directory 2>/dev/null || echo /var/spool/postfix)" |
||
| 91 | SPOOLDIR=${spooldir:-$POSTCONFSPOOL}
|
||
| 92 | |||
| 93 | . $MUNIN_LIBDIR/plugins/plugin.sh |
||
| 94 | |||
| 95 | case $1 in |
||
| 96 | autoconf|detect) |
||
| 97 | if [ -d $SPOOLDIR ] ; then |
||
| 98 | echo yes |
||
| 99 | exit 0 |
||
| 100 | else |
||
| 101 | echo "no (spooldir not found)" |
||
| 102 | exit 0 |
||
| 103 | fi |
||
| 104 | ;; |
||
| 105 | config) |
||
| 106 | echo "graph_title Postfix Mailqueue $CONFIG"; |
||
| 107 | cat <<'EOF' |
||
| 108 | graph_vlabel Mails in queue |
||
| 109 | graph_category postfix |
||
| 110 | graph_total Total |
||
| 111 | active.label active |
||
| 112 | deferred.label deferred |
||
| 113 | maildrop.label maildrop |
||
| 114 | incoming.label incoming |
||
| 115 | corrupt.label corrupt |
||
| 116 | hold.label held |
||
| 117 | EOF |
||
| 118 | for field in active deferred maildrop incoming corrupt hold; do |
||
| 119 | print_warning $field |
||
| 120 | print_critical $field |
||
| 121 | done |
||
| 122 | exit 0 |
||
| 123 | ;; |
||
| 124 | esac |
||
| 125 | |||
| 126 | cd $SPOOLDIR >/dev/null 2>/dev/null || {
|
||
| 127 | echo "# Cannot cd to $SPOOLDIR" |
||
| 128 | exit 1 |
||
| 129 | } |
||
| 130 | |||
| 131 | cat <<EOF |
||
| 132 | deferred.value `(test -d deferred && find deferred -type f) | wc -l` |
||
| 133 | active.value `(test -d active && find active -type f) | wc -l` |
||
| 134 | maildrop.value `(test -d maildrop && find maildrop -type f) | wc -l` |
||
| 135 | incoming.value `(test -d incoming && find incoming -type f) | wc -l` |
||
| 136 | corrupt.value `(test -d corrupt && find corrupt -type f) | wc -l` |
||
| 137 | hold.value `( test -d hold && find hold -type f) | wc -l` |
||
| 138 | EOF |
