2009-02-09 19:08:29 +01:00
|
|
|
#!/bin/sh
|
2011-07-15 11:15:20 +02:00
|
|
|
#
|
2012-03-07 11:59:04 +01:00
|
|
|
# Copyright (C) 2009 - 2012 Andreas Thienemann <andreas@bawue.net>
|
2009-02-09 19:08:29 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Library General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 only
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Library General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Library General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
#
|
|
|
|
|
2011-07-15 11:15:20 +02:00
|
|
|
: <<=cut
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
cyrus-imapd - Munin plugin to monitor the load on a cyrus imapd server
|
|
|
|
|
|
|
|
=head1 CONFIGURATION
|
|
|
|
|
|
|
|
The user running this plugin needs read and write access to the
|
|
|
|
cyrus-imapd proc directory. You will need to add the following to the
|
|
|
|
munin-node/plugin configuration:
|
|
|
|
|
|
|
|
[cyrus-imapd]
|
|
|
|
user root
|
|
|
|
|
|
|
|
=head1 INTERPRETATION
|
|
|
|
|
|
|
|
This plugin should be pretty self explanatory.
|
|
|
|
|
|
|
|
It displays the following three datapoints:
|
|
|
|
|
|
|
|
- Total number of open connections (both in authenticated and
|
|
|
|
non-authenticated state)
|
|
|
|
- Number of authenticated sessions
|
|
|
|
- Number of unique users
|
|
|
|
|
|
|
|
=head1 MAGIC MARKERS
|
|
|
|
|
|
|
|
#%# family=contrib
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
|
|
|
=head1 VERSION
|
|
|
|
|
2012-03-07 11:59:04 +01:00
|
|
|
0.0.20120307
|
2011-07-15 11:15:20 +02:00
|
|
|
|
|
|
|
=head1 BUGS
|
|
|
|
|
|
|
|
None known. If you find any, please put in a ticket at <https://trac.bawue.org/munin/newticket>.
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
Andreas Thienemann <andreas@bawue.net>
|
|
|
|
|
|
|
|
=head1 LICENSE
|
|
|
|
|
|
|
|
GPLv2
|
|
|
|
|
|
|
|
=cut
|
2009-02-09 19:08:29 +01:00
|
|
|
|
|
|
|
# IMAP Configuration Directory
|
2015-05-20 15:24:30 +02:00
|
|
|
PROCDIR=$(awk -F : '/^proc_path:/ { gsub(/ /, "", $2); print $2 }' /etc/imapd.conf 2> /dev/null)
|
|
|
|
if [ "x${PROCDIR}x" = "xx" ]; then
|
|
|
|
CONFIGDIR=$(awk -F : '/^configdirectory:/ { gsub(/ /, "", $2); print $2 }' /etc/imapd.conf 2> /dev/null)
|
|
|
|
PROCDIR="${CONFIGDIR}/proc"
|
|
|
|
fi
|
2009-02-09 19:08:29 +01:00
|
|
|
|
2014-10-04 22:03:52 +02:00
|
|
|
if [ "$1" = "autoconf" ]; then
|
2015-05-20 15:24:30 +02:00
|
|
|
if [ "x${PROCDIR}x" != "xx" ] && [ -d ${PROCDIR} ]; then
|
2009-02-09 19:08:29 +01:00
|
|
|
echo yes
|
|
|
|
else
|
2011-07-15 11:15:20 +02:00
|
|
|
echo "no (no cyrus-imapd procdir found)"
|
2009-02-09 19:08:29 +01:00
|
|
|
fi
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if we actually got some sensible data
|
2015-05-20 15:24:30 +02:00
|
|
|
if [ "x${PROCDIR}x" = "xx" ]; then
|
2009-02-09 19:08:29 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If run with the "config"-parameter, give out information on how the
|
|
|
|
# graphs should look.
|
|
|
|
|
2014-10-04 22:03:52 +02:00
|
|
|
if [ "$1" = "config" ]; then
|
2009-02-09 19:08:29 +01:00
|
|
|
echo 'graph_title Cyrus IMAPd Load'
|
|
|
|
echo 'graph_args --base 1000 -l 0'
|
|
|
|
echo 'graph_vlabel connections'
|
|
|
|
echo 'graph_scale no'
|
|
|
|
echo 'graph_category cyrus'
|
|
|
|
echo 'graph_info Current connections to the imap server. <a href="http://trac.bawue.org/">bawue.net e.V. Trac repository</a>.'
|
2011-07-15 11:15:20 +02:00
|
|
|
echo 'graph_order connections authenticated_users unique_users'
|
2009-02-09 19:08:29 +01:00
|
|
|
echo 'connections.label Connections'
|
|
|
|
echo 'connections.info Number of connections to the imap server.'
|
|
|
|
echo 'authenticated_users.label Authenticated Users'
|
|
|
|
echo 'authenticated_users.info Number of authenticated users logged into the imap server.'
|
|
|
|
echo 'unique_users.label Unique Users'
|
|
|
|
echo 'unique_users.info Number of unique users on the imap server.'
|
|
|
|
|
|
|
|
# Last, if run with the "config"-parameter, quit here (don't
|
|
|
|
# display any data)
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-07-15 11:15:20 +02:00
|
|
|
cons=$(ls ${PROCDIR} | wc -l)
|
2009-02-09 19:08:29 +01:00
|
|
|
|
2011-07-15 11:15:20 +02:00
|
|
|
if [ $cons -gt 0 ]; then
|
|
|
|
# Print the number of connections to the imap server
|
|
|
|
echo "connections.value $cons"
|
2009-02-09 19:08:29 +01:00
|
|
|
|
2011-07-15 11:15:20 +02:00
|
|
|
# Read the proc files and get the logged in users
|
|
|
|
echo -n "authenticated_users.value "
|
|
|
|
awk '{ split(substr($0, match($0, "]")+1), a); if (a[1] != "") print a[1] }' ${PROCDIR}/* | wc -l
|
2009-02-09 19:08:29 +01:00
|
|
|
|
2011-07-15 11:15:20 +02:00
|
|
|
# Read the proc files and get the number of unique users
|
|
|
|
echo -n "unique_users.value "
|
|
|
|
awk '{ split(substr($0, match($0, "]")+1), a); if (a[1] != "") print a[1] }' ${PROCDIR}/* | sort -u | wc -l
|
|
|
|
else
|
|
|
|
echo "connections.value 0"
|
|
|
|
echo "authenticated_users.value 0"
|
|
|
|
echo "unique_users.value 0"
|
|
|
|
fi
|