source: trunk/munin-plugins/courier_.in @ 323

Last change on this file since 323 was 19, checked in by sebas, 17 years ago

:q!

File size: 3.0 KB
RevLine 
[19]1#!@@GOODSH@@
2#
3# Plugin to graph number of courier login/logouts
4# Requires: logtail
5#
6# This plugin should be symlinked to have the service name that you
7# want to track. If you want to watch imaplogin entries you would do:
8# ln -s /usr/share/munin/plugins/courier_ /etc/munin/plugins/courier_imaplogin
9# if you wanted to track courierpop3login entries, then you would do:
10# ln -s /usr/share/munin/plugins/courier_ /etc/munin/plugins/courier_courierpop3login
11#
12# Coypright Micah Anderson <micah@riseup.net>
13# Jan 22, 2005
14#
15#
16#%# family=contrib
17#%# capabilities=autoconf
18
19# The different log lines we are interested in:
20#
21# imaplogin:
22# Jan 22 10:53:35 raven imaplogin: Connection, ip=[::ffff:192.168.0.1]
23# Jan 22 06:28:19 raven imaplogin: DISCONNECTED, user=someuser, ip=[::ffff:192.168.0.1], headers=0, body=0, time=22
24# Jan 22 10:53:35 raven imaplogin: LOGIN, user=someuser, ip=[::ffff:192.168.0.1], protocol=IMAP
25# Jan 22 06:28:16 raven imaplogin: LOGOUT, user=someuser, ip=[::ffff:192.168.0.1], headers=0, body=2811, time=0
26#
27# courierpop3login:
28# Jan 22 06:28:24 raven courierpop3login: Connection, ip=[::ffff:192.168.0.1]
29# Jan 22 06:48:22 raven courierpop3login: DISCONNECTED, user=someuser, ip=[::ffff:192.168.0.1], top=0, retr=0, time=21
30# Jan 22 06:28:24 raven courierpop3login: LOGIN, user=someuser, ip=[::ffff:192.168.0.1]
31# Jan 22 06:28:25 raven courierpop3login: LOGOUT, user=someuser, ip=[::ffff:192.168.0.1], top=0, retr=0, time=0
32
33
34# Set the location of the courier logs
35COURIER_LOG=${logfile:-/var/log/mail.log}
36SERVICE=${service:-`basename $0 | sed 's/^courier_//g'`}
37OFFSET_FILE=@@PLUGSTATE@@/courier_${SERVICE}.offset
38LOGTAIL=${logtail:-/usr/sbin/logtail}
39
40mktempfile () {
41@@MKTEMP@@
42}
43
44case $1 in
45    autoconf|detect)
46    if [ -f ${COURIER_LOG} -a -x ${LOGTAIL} ]
47    then
48        # Makes no sense for wildcard plugin to autoconf to yes
49        # unless you can provide suggestions.
50        echo no
51        exit 0
52    else
53        echo "no (either $COURIER_LOG was not found, or logtail was not in your path)"
54        exit 1
55    fi
56    ;;
57    config)
58    cat <<EOF
59graph_title Courier $SERVICE Connections
60graph_vlabel Number of Connections
61graph_total Total
62connection.label connections
63disconnected.label disconnections
64login.label logins
65logout.label logouts
66EOF
67    exit 0
68    ;;
69esac
70
71ARGS=0
72`$LOGTAIL /etc/hosts 2>/dev/null >/dev/null`
73if [ $? = 66 ]; then
74    if [ ! -n "$logtail" ]; then
75        ARGS=1
76    fi
77fi
78
79TEMP_FILE=`mktempfile munin-courier.XXXXXX`
80
81if [ -z "$TEMP_FILE" -o ! -f "$TEMP_FILE" ]; then
82    exit 3
83fi
84
85if [ $ARGS != 0 ]; then
86    ${LOGTAIL} -f ${COURIER_LOG} -o ${OFFSET_FILE} | grep "$SERVICE" > ${TEMP_FILE}
87else
88    ${LOGTAIL} ${COURIER_LOG} ${OFFSET_FILE} | grep "$SERVICE" > ${TEMP_FILE}
89fi
90connection=`grep Connection ${TEMP_FILE} | wc -l`
91disconnected=`grep DISCONNECTED ${TEMP_FILE} | wc -l`
92login=`grep LOGIN ${TEMP_FILE} | wc -l`
93logout=`grep LOGOUT ${TEMP_FILE} | wc -l`
94
95rm ${TEMP_FILE}
96
97echo "connection.value ${connection}"
98echo "disconnected.value ${disconnected}"
99echo "login.value ${login}"
100echo "logout.value ${logout}"
Note: See TracBrowser for help on using the repository browser.