root/cyrus-imapd

Revision 1, 2.8 kB (checked in by ixs, 16 years ago)

initial checkin

  • Property svn:executable set to *
Line 
1 #!/bin/sh
2
3 # Copyright (C) 2009 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 #
20 # Plugin to monitor the load on a cyrus imapd server
21 #
22 # Usage: Link or copy into the munin-node plugin directory
23 #
24 # Installation node: Should most likely run as root:
25 # [cyrus-imapd]
26 # user root
27 #
28 #
29 # Magic markers (optional - only used by munin-config and some
30 # installation scripts):
31 #
32 #%# family=contrib
33 #%# capabilities=autoconf
34
35 # IMAP Configuration Directory
36 CONFIGDIR=$(awk -F : '/^configdirectory:/ { gsub(/ /, "", $2); print $2 }' /etc/imapd.conf 2> /dev/null)
37 PROCDIR="${CONFIGDIR}/proc"
38
39 if [ "$1" = "autoconf" ]; then
40         if [ "x${CONFIGDIR}x" != "xx" ] && [ -d ${PROCDIR} ]; then
41                 echo yes
42         else
43                 echo no
44         fi
45         exit 0
46 fi
47
48 # Check if we actually got some sensible data
49 if [ "x${CONFIGDIR}x" == "xx" ]; then
50         exit 1
51 fi
52
53 # If run with the "config"-parameter, give out information on how the
54 # graphs should look.
55  
56 if [ "$1" = "config" ]; then
57         echo 'graph_title Cyrus IMAPd Load'
58         echo 'graph_args --base 1000 -l 0'
59         echo 'graph_vlabel connections'
60         echo 'graph_scale no'
61         echo 'graph_category cyrus'
62         echo 'graph_info Current connections to the imap server. <a href="http://trac.bawue.org/">bawue.net e.V. Trac repository</a>.'
63         echo 'graph_oder connections authenticated_users unique_users'
64         echo 'connections.label Connections'
65         echo 'connections.info Number of connections to the imap server.'
66         echo 'authenticated_users.label Authenticated Users'
67         echo 'authenticated_users.info Number of authenticated users logged into the imap server.'
68         echo 'unique_users.label Unique Users'
69         echo 'unique_users.info Number of unique users on the imap server.'
70
71         # Last, if run with the "config"-parameter, quit here (don't
72         # display any data)
73         exit 0
74 fi
75
76 # Print the number of connections to the imap server
77 echo -n "connections.value "
78 ls ${PROCDIR} | wc -l
79
80 # Read the proc files and get the logged in users
81 echo -n "authenticated_users.value "
82 awk '{ split(substr($0, match($0, "]")+1), a); if (a[1] != "") print a[1] }' ${PROCDIR}/* | wc -l
83
84 # Read the proc files and get the number of unique users
85 echo -n "unique_users.value "
86 awk '{ split(substr($0, match($0, "]")+1), a); if (a[1] != "") print a[1] }' ${PROCDIR}/* | sort -u | wc -l
87
Note: See TracBrowser for help on using the browser.