Projet

Général

Profil

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

root / plugins / postfix / policyd-spf-python @ 4b2fcbf8

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

1
#! /bin/bash
2
#
3
#   Munin plugin to monitor postfix-policyd-spf-python results
4
#   Contributed by Alexander Koch <lynix47@gmail.com> 
5
#
6
#   This plugin is published under the terms of the MIT License.
7
# 
8
# Parameters understood:
9
#	config		(required)
10
#	autoconf 	(optional - used by munin-config)
11
# 
12
# Config variables:
13
#       logfile      - Where to find the postfix log (mail.log)
14
#
15
# Add the following line to a file in /etc/munin/plugin-conf.d:
16
# 	env.logfile /var/log/your/mail.log
17
#
18
# Magic markers (optional - used by munin-config and installation scripts):
19
#
20
#%# family=auto
21
#%# capabilities=autoconf
22

    
23

    
24
#
25
# Configuration
26
#
27

    
28
STAT_FILE=${STAT_FILE:-$MUNIN_PLUGSTATE/plugin-plcyd-spf-python.state}
29
LOGFILE=${logfile:-/var/log/mail.log}
30

    
31
if [ "$1" = "autoconf" ]; then
32
	echo yes
33
	exit 0
34
fi
35

    
36
if [ "$1" = "config" ]; then
37
	echo 'graph_title SPF Check Results'
38
	echo 'graph_category mail'
39
	echo 'graph_args --base 1000 -l 0'
40
	echo 'graph_vlabel Count/s'
41

    
42
	echo 'count_pass.label Pass'
43
	echo 'count_pass.type DERIVE'
44
	echo 'count_pass.min 0'
45
	echo 'count_pass.colour 00cc00'
46
	echo 'count_fail.label Fail'
47
	echo 'count_fail.type DERIVE'
48
	echo 'count_fail.min 0'
49
	echo 'count_fail.colour cc0000'
50
	echo 'count_none.label None'
51
	echo 'count_none.type DERIVE'
52
	echo 'count_none.min 0'
53
	echo 'count_none.colour 0066b3'
54
	echo 'count_temperror.label Temperror'
55
	echo 'count_temperror.type DERIVE'
56
	echo 'count_temperror.min 0'
57
	echo 'count_temperror.colour ff8000'
58
	echo 'count_neutral.label Neutral'
59
	echo 'count_neutral.type DERIVE'
60
	echo 'count_neutral.min 0'
61
	echo 'count_neutral.colour ffcc00'
62

    
63
	exit 0
64
fi
65

    
66

    
67
#
68
# Log parsing
69
#
70

    
71
function get_log_count() {
72
	egrep "policyd-spf\[[0-9]+\]: $1;" "$LOGFILE" | grep "$(date '+%b %e')" | wc -l
73
}
74

    
75
PASS=$(get_log_count "Pass")
76
FAIL=$(get_log_count "Fail")
77
NONE=$(get_log_count "None")
78
TEMPERR=$(get_log_count "Temperror")
79
NEUTRAL=$(get_log_count "Neutral")
80

    
81
echo "count_pass.value $PASS"
82
echo "count_fail.value $FAIL"
83
echo "count_none.value $NONE"
84
echo "count_temperror.value $TEMPERR"
85
echo "count_neutral.value $NEUTRAL"
86

    
87

    
88
exit 0