Projet

Général

Profil

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

root / plugins / mail / dkimproxy_mails @ e5ce7492

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

1
#!/bin/bash
2
#
3
# Plugin to monitor incoming DKIM mail.
4
#
5
# Florian Sager, sager@agitos.de, 2008-02-06
6
#
7
# Parameters understood:
8
#
9
#       config   (required)
10
#       autoconf (optional)
11
#
12
# Gives the result of the verification. The following values are possible:
13
# 
14
# pass
15
#     Returned if a valid DKIM-Signature header was found, and the signature contains a correct value for the message.
16
#
17
# fail
18
#     Returned if a valid DKIM-Signature header was found, but the signature does not contain a correct value for the message.
19
#
20
# invalid
21
#     Returned if no valid DKIM-Signature headers were found, but there is at least one invalid DKIM-Signature header. For a reason why a DKIM-Signature header found in the message was invalid, see $dkim->{signature_reject_reason}.
22
#
23
# none
24
#     Returned if no DKIM-Signature headers (valid or invalid) were found.
25
# 
26
# In case of multiple signatures, the "best" result will be returned. Best is defined as "pass", followed by "fail", "invalid", and "none".
27
# 
28

    
29
mktempfile () {
30
mktemp -t
31
}
32

    
33
MAIL_LOG=${logfile:-/var/log/mail.log}
34
LOGTAIL=${logtail:-`which logtail`}
35
STATEFILE=/var/lib/munin/plugin-state/dkimproxy_mails.offset
36

    
37
if [ "$1" = "autoconf" ]; then
38
        if [ -f "${MAIL_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
39
                echo yes
40
                exit 0
41
        else
42
                echo no
43
                exit 1
44
        fi
45
fi
46

    
47
if [ "$1" = "config" ]; then
48
        echo 'graph_title DKIM Proxy mails'
49
        echo 'graph_order dkimnone dkimpass dkiminvalid dkimfail'
50
        echo 'graph_category mail'
51
        echo 'graph_vlabel Count'
52
        echo 'graph_args --base 1000 -l 0'
53
#       echo 'graph_total total'
54

    
55
        echo 'dkimnone.label No DKIM-Sigs'
56
        echo 'dkimnone.min 0'
57
        echo 'dkimpass.label Valid DKIM-Sigs'
58
        echo 'dkimpass.min 0'
59
        echo 'dkiminvalid.label Invalid DKIM-Sigs'
60
        echo 'dkiminvalid.min 0'
61
        echo 'dkimfail.label Failed DKIM-Sigs'
62
        echo 'dkimfail.min 0'        
63
        exit 0
64
fi
65

    
66
dkimnone=U
67
dkimpass=U
68
dkiminvalid=U
69
dkiminfail=U
70

    
71
TEMP_FILE=`mktempfile munin-dkimproxy_mails.XXXXXX`
72

    
73
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
74
then
75
        $LOGTAIL ${MAIL_LOG} $STATEFILE | grep "DKIM verify - " > ${TEMP_FILE}
76

    
77
        dkimnone=`grep 'DKIM verify - none' ${TEMP_FILE} | wc -l`
78
        dkimpass=`grep 'DKIM verify - pass' ${TEMP_FILE} | wc -l`
79
        dkiminvalid=`grep 'DKIM verify - invalid' ${TEMP_FILE} | wc -l`
80
        dkimfail=`grep 'DKIM verify - fail' ${TEMP_FILE} | wc -l`
81

    
82
        /bin/rm -f $TEMP_FILE
83
fi
84

    
85
echo "dkimnone.value ${dkimnone}"
86
echo "dkimpass.value ${dkimpass}"
87
echo "dkiminvalid.value ${dkiminvalid}"
88
echo "dkimfail.value ${dkimfail}"