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