forked from munin-monitoring/munin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourier_
executable file
·113 lines (87 loc) · 2.55 KB
/
courier_
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
: << =cut
=head1 NAME
courier_ - plugin to graph courier logins and logouts
=head1 APPLICABLE SYSTEMS
Any system with a courier imap/pop3 server and logtail installed
=head1 CONFIGURATION
The configuration variables are:
logtail - path to the logtail script
logfile - log file from courier
service - which courier service to graph
Service names for courier are "imaplogin" and "courierpop3login".
Good symlink names for this plugin is "courier_imaplogin" and
"courier_courierpop3login", which will set the "service" environment
variable to "imaplogin" and "courierpop3login", respectively.
The default configuration is:
[courier_*]
env.logtail /usr/sbin/logtail
env.logfile /var/log/mail.log
env.service <Whatever follows "courier_" in the file name>
env.mktemp_command /bin/mktemp
=head1 MAGIC MARKERS
#%# family=contrib
#%# capabilities=autoconf
=head1 BUGS
None known
=head1 AUTHOR
# Coypright Micah Anderson <[email protected]>
# Jan 22, 2005
=head1 LICENSE
Unknown
=cut
# Set the location of the courier logs
COURIER_LOG=${logfile:-/var/log/mail.log}
SERVICE=${service:-`basename $0 | sed 's/^courier_//g'`}
OFFSET_FILE=${MUNIN_PLUGSTATE}/courier_${SERVICE}.offset
LOGTAIL=${logtail:-/usr/sbin/logtail}
mktemp_command="${mktemp_command:-/bin/mktemp}"
case $1 in
autoconf|detect)
if [ -f ${COURIER_LOG} -a -x ${LOGTAIL} ]
then
# Makes no sense for wildcard plugin to autoconf to yes
# unless you can provide suggestions.
echo no
exit 0
else
echo "no (either $COURIER_LOG was not found, or logtail was not in your path)"
exit 0
fi
;;
config)
cat <<EOF
graph_title Courier $SERVICE Connections
graph_category mail
graph_vlabel Number of Connections
graph_total Total
connection.label connections
disconnected.label disconnections
login.label logins
logout.label logouts
EOF
exit 0
;;
esac
ARGS=0
`$LOGTAIL /etc/hosts 2>/dev/null >/dev/null`
if [ $? = 66 ]; then
if [ ! -n "$logtail" ]; then
ARGS=1
fi
fi
TEMP_FILE=$($mktemp_command) || exit 73
trap 'rm -f "$TEMP_FILE"' EXIT
if [ $ARGS != 0 ]; then
${LOGTAIL} -f ${COURIER_LOG} -o ${OFFSET_FILE} | grep "$SERVICE" > ${TEMP_FILE}
else
${LOGTAIL} ${COURIER_LOG} ${OFFSET_FILE} | grep "$SERVICE" > ${TEMP_FILE}
fi
connection=`grep Connection ${TEMP_FILE} | wc -l`
disconnected=`grep DISCONNECTED ${TEMP_FILE} | wc -l`
login=`grep LOGIN ${TEMP_FILE} | wc -l`
logout=`grep LOGOUT ${TEMP_FILE} | wc -l`
echo "connection.value ${connection}"
echo "disconnected.value ${disconnected}"
echo "login.value ${login}"
echo "logout.value ${logout}"