Index: /cyrus-imapd =================================================================== --- /cyrus-imapd (revision 1) +++ /cyrus-imapd (revision 12) @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2009 Andreas Thienemann +# Copyright (C) 2009-2011 Andreas Thienemann # # This program is free software; you can redistribute it and/or modify @@ -17,19 +17,52 @@ # -# -# Plugin to monitor the load on a cyrus imapd server -# -# Usage: Link or copy into the munin-node plugin directory -# -# Installation node: Should most likely run as root: -# [cyrus-imapd] -# user root -# -# -# Magic markers (optional - only used by munin-config and some -# installation scripts): -# -#%# family=contrib -#%# capabilities=autoconf +: <<=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 suggest + +=head1 VERSION + + $Id$ + +=head1 BUGS + +None known. If you find any, please put in a ticket at . + +=head1 AUTHOR + +Andreas Thienemann + +=head1 LICENSE + +GPLv2 + +=cut # IMAP Configuration Directory @@ -74,14 +107,31 @@ fi -# Print the number of connections to the imap server -echo -n "connections.value " -ls ${PROCDIR} | wc -l +# If run with the "config"-parameter, give out information on how the +# graphs should look. -# 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 +if [ "$1" = "suggest" ]; then + if [ -d ${PROCDIR} ]; then + echo "yes" + else + echo "no (no cyrus-imapd procdir found)" + exit 0 +fi -# 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 +cons=$(ls ${PROCDIR} | wc -l) +if [ $cons -lt 0 ]; then + # Print the number of connections to the imap server + echo "connections.value $cons" + + # 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 + + # 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