root / plugins / mail / courier_log @ 31412baa
Historique | Voir | Annoter | Télécharger (1,71 ko)
| 1 | efb0772f | Lars Kruse | #!/bin/sh |
|---|---|---|---|
| 2 | # |
||
| 3 | # Plugin to count specific log categories for courier servers (pop3/imap) |
||
| 4 | # |
||
| 5 | # Magic markers - optional - used by installation scripts and |
||
| 6 | # munin-config: |
||
| 7 | # |
||
| 8 | #%# family=manual |
||
| 9 | #%# capabilities=suggest |
||
| 10 | |||
| 11 | CATEGORIES="peer_reset Reset_by_peer Connection reset by peer |
||
| 12 | conn_timeout Connection_timeout Connection timed out |
||
| 13 | disconnected Disconnected DISCONNECTED |
||
| 14 | timeout Timeout TIMEOUT |
||
| 15 | login Login LOGIN |
||
| 16 | logout Logout LOGOUT |
||
| 17 | mem_full FAM_needs_restart malloc: Input/output error |
||
| 18 | conn_full Connection_limit_reached malloc: Input/output error" |
||
| 19 | LOG_FILE=${LOG_FILE:-/var/log/mail.info}
|
||
| 20 | SUGGESTIONS="pop3d pop3d-ssl imapd imapd-ssl" |
||
| 21 | |||
| 22 | |||
| 23 | # "autoconf" and "suggest" only work reliably if the mail server already |
||
| 24 | # contains some log entries. |
||
| 25 | |||
| 26 | if [ "$1" = "autoconf" ]; then |
||
| 27 | [ ! -e "$LOG_FILE" ] && echo "no (no log file found: $LOG_FILE)" && exit 0 |
||
| 28 | for suggestion in $SUGGESTIONS; do |
||
| 29 | grep -q " $suggestion: " "$LOG_FILE" && echo "yes" && exit 0 |
||
| 30 | done |
||
| 31 | # no suitable line found in the log file |
||
| 32 | echo "no (no courier pop3d/imapd lines in $LOG_FILE found)" |
||
| 33 | exit 0 |
||
| 34 | fi |
||
| 35 | |||
| 36 | if [ "$1" = "suggest" ]; then |
||
| 37 | for suggestion in $SUGGESTIONS; do |
||
| 38 | grep -q " $suggestion: " "$LOG_FILE" && echo "$suggestion" |
||
| 39 | done |
||
| 40 | exit 0 |
||
| 41 | fi |
||
| 42 | |||
| 43 | |||
| 44 | type=$(basename "$0" | tr "_" "\n" | tail -1) |
||
| 45 | |||
| 46 | |||
| 47 | if [ "$1" = "config" ]; then |
||
| 48 | cat <<EOT |
||
| 49 | graph_title Courier log ($type) |
||
| 50 | graph_args --base 1000 -l 0 |
||
| 51 | graph_vlabel events per second |
||
| 52 | graph_category Mail |
||
| 53 | EOT |
||
| 54 | echo "$CATEGORIES" | while read field label match; do |
||
| 55 | echo "${field}.label $(echo "$label" | tr "_" " ")"
|
||
| 56 | echo "${field}.type DERIVE"
|
||
| 57 | echo "${field}.min 0"
|
||
| 58 | done |
||
| 59 | exit 0 |
||
| 60 | fi |
||
| 61 | |||
| 62 | echo "$CATEGORIES" | while read field label match; do |
||
| 63 | echo -n "${field}.value "
|
||
| 64 | grep " $type: " "$LOG_FILE" | grep "$match" | wc -l |
||
| 65 | done |
