Changeset 12 for cyrus-imapd

Show
Ignore:
Timestamp:
07/04/11 23:48:53 (13 years ago)
Author:
ixs
Message:

Reworked plugin slightly, added perldoc block, fixed use case with 0 connections.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cyrus-imapd

    r1 r12  
    11#!/bin/sh 
    22 
    3 # Copyright (C) 2009 Andreas Thienemann <andreas@bawue.net> 
     3# Copyright (C) 2009-2011 Andreas Thienemann <andreas@bawue.net> 
    44# 
    55# This program is free software; you can redistribute it and/or modify 
     
    1717# 
    1818 
    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 
     19: <<=cut 
     20 
     21=head1 NAME 
     22 
     23cyrus-imapd - Munin plugin to monitor the load on a cyrus imapd server 
     24 
     25=head1 CONFIGURATION 
     26 
     27The user running this plugin needs read and write access to the 
     28cyrus-imapd proc directory.  You will need to add the following to the  
     29munin-node/plugin configuration: 
     30 
     31  [cyrus-imapd] 
     32  user root 
     33 
     34=head1 INTERPRETATION 
     35 
     36This plugin should be pretty self explanatory. 
     37 
     38It 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 suggest 
     49 
     50=head1 VERSION 
     51 
     52  $Id$ 
     53 
     54=head1 BUGS 
     55 
     56None known. If you find any, please put in a ticket at <https://trac.bawue.org/munin/newticket>. 
     57 
     58=head1 AUTHOR 
     59 
     60Andreas Thienemann <andreas@bawue.net> 
     61 
     62=head1 LICENSE 
     63 
     64GPLv2 
     65 
     66=cut 
    3467 
    3568# IMAP Configuration Directory 
     
    74107fi 
    75108 
    76 # Print the number of connections to the imap server 
    77 echo -n "connections.value " 
    78 ls ${PROCDIR} | wc -l 
     109# If run with the "config"-parameter, give out information on how the 
     110# graphs should look.  
    79111 
    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 
     112if [ "$1" = "suggest" ]; then 
     113        if [ -d ${PROCDIR} ]; then 
     114                echo "yes" 
     115        else 
     116                echo "no (no cyrus-imapd procdir found)" 
     117        exit 0 
     118fi 
    83119 
    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 
     120cons=$(ls ${PROCDIR} | wc -l) 
    87121 
     122if [ $cons -lt 0 ]; then 
     123        # Print the number of connections to the imap server 
     124        echo "connections.value $cons" 
     125 
     126        # Read the proc files and get the logged in users 
     127        echo -n "authenticated_users.value " 
     128        awk '{ split(substr($0, match($0, "]")+1), a); if (a[1] != "") print a[1] }' ${PROCDIR}/* | wc -l 
     129 
     130        # Read the proc files and get the number of unique users 
     131        echo -n "unique_users.value " 
     132        awk '{ split(substr($0, match($0, "]")+1), a); if (a[1] != "") print a[1] }' ${PROCDIR}/* | sort -u | wc -l 
     133else 
     134        echo "connections.value 0" 
     135        echo "authenticated_users.value 0" 
     136        echo "unique_users.value 0" 
     137fi