#!/bin/bash : <<=cut =head1 NAME dovecot_stats_ - Munin plugin to display statistics for the dovecot mail server =head1 CONFIGURATION This plugin must be run with permissions to run "doveadm". That usually means root, but to test, run the following as any user: doveadm who If you get a permission denied message, check the permissions on the socket mentioned in the error line. =head1 MAGIC MARKERS #%# family=contrib #%# capability=autoconf suggest =head1 AUTHOR Paul Saunders =cut . $MUNIN_LIBDIR/plugins/plugin.sh is_multigraph if [[ "$1" == "autoconf" ]]; then if [[ -x /usr/bin/doveadm ]]; then echo yes else echo no fi exit 0 fi # Dovecot 2.3 changes the stas format, but we can still access the older version with "doveadm oldstats". dovecot_version=$(/usr/sbin/dovecot --version | awk '{print $1}') verlte() { [ "$1" = "$2" ] && return 1 || [ "$2" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] } verlt() { [ "$1" = "$2" ] && return 1 || verlte $2 $1 } # The stats command is "stats" unless the version is NOT less than 2.3, in which case it's "oldstats". stats_command="stats" verlt $dovecot_version 2.3 || stats_command="oldstats" if [[ "$1" == "suggest" ]]; then doveadm $stats_command dump domain|awk 'NR!=1 {print $1}' exit 0 fi domain=$(basename $0) domain=${domain#dovecot_stats_} if [[ -z $domain ]]; then exit 1 fi if [[ "$1" == "config" ]]; then cat <