root / plugins / cyrus / cyrus-imapd @ c5ab6538
Historique | Voir | Annoter | Télécharger (3,55 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# |
| 3 |
# Copyright (C) 2009 - 2012 Andreas Thienemann <andreas@bawue.net> |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU Library General Public License as published by |
| 7 |
# the Free Software Foundation; version 2 only |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU Library General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU Library General Public License |
| 15 |
# along with this program; if not, write to the Free Software |
| 16 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 |
# |
| 18 |
|
| 19 |
: <<=cut |
| 20 |
|
| 21 |
=head1 NAME |
| 22 |
|
| 23 |
cyrus-imapd - Munin plugin to monitor the load on a cyrus imapd server |
| 24 |
|
| 25 |
=head1 CONFIGURATION |
| 26 |
|
| 27 |
The user running this plugin needs read and write access to the |
| 28 |
cyrus-imapd proc directory. You will need to add the following to the |
| 29 |
munin-node/plugin configuration: |
| 30 |
|
| 31 |
[cyrus-imapd] |
| 32 |
user root |
| 33 |
|
| 34 |
=head1 INTERPRETATION |
| 35 |
|
| 36 |
This plugin should be pretty self explanatory. |
| 37 |
|
| 38 |
It displays the following three datapoints: |
| 39 |
|
| 40 |
- Total number of open connections (both in authenticated and |
| 41 |
non-authenticated state) |
| 42 |
- Number of authenticated sessions |
| 43 |
- Number of unique users |
| 44 |
|
| 45 |
=head1 MAGIC MARKERS |
| 46 |
|
| 47 |
#%# family=contrib |
| 48 |
#%# capabilities=autoconf |
| 49 |
|
| 50 |
=head1 VERSION |
| 51 |
|
| 52 |
0.0.20120307 |
| 53 |
|
| 54 |
=head1 BUGS |
| 55 |
|
| 56 |
None known. If you find any, please put in a ticket at <https://trac.bawue.org/munin/newticket>. |
| 57 |
|
| 58 |
=head1 AUTHOR |
| 59 |
|
| 60 |
Andreas Thienemann <andreas@bawue.net> |
| 61 |
|
| 62 |
=head1 LICENSE |
| 63 |
|
| 64 |
GPLv2 |
| 65 |
|
| 66 |
=cut |
| 67 |
|
| 68 |
# IMAP Configuration Directory |
| 69 |
CONFIGDIR=$(awk -F : '/^configdirectory:/ { gsub(/ /, "", $2); print $2 }' /etc/imapd.conf 2> /dev/null)
|
| 70 |
PROCDIR="${CONFIGDIR}/proc"
|
| 71 |
|
| 72 |
if [ "$1" == "autoconf" ]; then |
| 73 |
if [ "x${CONFIGDIR}x" != "xx" ] && [ -d ${PROCDIR} ]; then
|
| 74 |
echo yes |
| 75 |
else |
| 76 |
echo "no (no cyrus-imapd procdir found)" |
| 77 |
fi |
| 78 |
exit 0 |
| 79 |
fi |
| 80 |
|
| 81 |
# Check if we actually got some sensible data |
| 82 |
if [ "x${CONFIGDIR}x" == "xx" ]; then
|
| 83 |
exit 1 |
| 84 |
fi |
| 85 |
|
| 86 |
# If run with the "config"-parameter, give out information on how the |
| 87 |
# graphs should look. |
| 88 |
|
| 89 |
if [ "$1" == "config" ]; then |
| 90 |
echo 'graph_title Cyrus IMAPd Load' |
| 91 |
echo 'graph_args --base 1000 -l 0' |
| 92 |
echo 'graph_vlabel connections' |
| 93 |
echo 'graph_scale no' |
| 94 |
echo 'graph_category cyrus' |
| 95 |
echo 'graph_info Current connections to the imap server. <a href="http://trac.bawue.org/">bawue.net e.V. Trac repository</a>.' |
| 96 |
echo 'graph_order connections authenticated_users unique_users' |
| 97 |
echo 'connections.label Connections' |
| 98 |
echo 'connections.info Number of connections to the imap server.' |
| 99 |
echo 'authenticated_users.label Authenticated Users' |
| 100 |
echo 'authenticated_users.info Number of authenticated users logged into the imap server.' |
| 101 |
echo 'unique_users.label Unique Users' |
| 102 |
echo 'unique_users.info Number of unique users on the imap server.' |
| 103 |
|
| 104 |
# Last, if run with the "config"-parameter, quit here (don't |
| 105 |
# display any data) |
| 106 |
exit 0 |
| 107 |
fi |
| 108 |
|
| 109 |
cons=$(ls ${PROCDIR} | wc -l)
|
| 110 |
|
| 111 |
if [ $cons -gt 0 ]; then |
| 112 |
# Print the number of connections to the imap server |
| 113 |
echo "connections.value $cons" |
| 114 |
|
| 115 |
# Read the proc files and get the logged in users |
| 116 |
echo -n "authenticated_users.value " |
| 117 |
awk '{ split(substr($0, match($0, "]")+1), a); if (a[1] != "") print a[1] }' ${PROCDIR}/* | wc -l
|
| 118 |
|
| 119 |
# Read the proc files and get the number of unique users |
| 120 |
echo -n "unique_users.value " |
| 121 |
awk '{ split(substr($0, match($0, "]")+1), a); if (a[1] != "") print a[1] }' ${PROCDIR}/* | sort -u | wc -l
|
| 122 |
else |
| 123 |
echo "connections.value 0" |
| 124 |
echo "authenticated_users.value 0" |
| 125 |
echo "unique_users.value 0" |
| 126 |
fi |
