From 995cb6d9a2308675ebeef8c534284d08294b6df6 Mon Sep 17 00:00:00 2001 From: Ludovic Poujol Date: Fri, 16 Oct 2020 15:33:52 +0200 Subject: [PATCH] dovecot: Update munin plugin & configure it --- dovecot/files/munin_config | 2 ++ dovecot/files/munin_plugin | 22 ++++++++++++---------- dovecot/tasks/munin.yml | 8 +++++--- 3 files changed, 19 insertions(+), 13 deletions(-) create mode 100644 dovecot/files/munin_config diff --git a/dovecot/files/munin_config b/dovecot/files/munin_config new file mode 100644 index 00000000..1a0553d8 --- /dev/null +++ b/dovecot/files/munin_config @@ -0,0 +1,2 @@ +[dovecot] +group adm diff --git a/dovecot/files/munin_plugin b/dovecot/files/munin_plugin index e5a6d1d1..f12c2b04 100755 --- a/dovecot/files/munin_plugin +++ b/dovecot/files/munin_plugin @@ -2,21 +2,22 @@ # # Munin Plugin # to count logins to your dovecot mailserver -# +# # Created by Dominik Schulz # http://developer.gauner.org/munin/ # Contributions by: # - Stephane Enten # - Steve Schnepp -# +# - pcy (make 'Connected Users' DERIVE, check existence of logfile in autoconf) +# # Parameters understood: # # config (required) # autoconf (optional - used by munin-config) -# +# # Config variables: # -# logfile - Where to find the syslog file +# logfile - Where to find the syslog file # # Add the following line to a file in /etc/munin/plugin-conf.d: # env.logfile /var/log/your/logfile.log @@ -34,13 +35,13 @@ LOGFILE=${logfile:-/var/log/mail.log} ###################### if [ "$1" = "autoconf" ]; then - echo yes + [ -f "$LOGFILE" ] && echo yes || echo "no (logfile $LOGFILE not found)" exit 0 fi if [ "$1" = "config" ]; then echo 'graph_title Dovecot Logins' - echo 'graph_category Mail' + echo 'graph_category mail' echo 'graph_args --base 1000 -l 0' echo 'graph_vlabel Login Counters' @@ -53,6 +54,7 @@ if [ "$1" = "config" ]; then done echo 'connected.label Connected Users' + echo "connected.type DERIVE" exit 0 fi @@ -86,7 +88,7 @@ echo -n echo -en "login_tls.value " VALUE=$(egrep -c '[dovecot]?.*Login.*TLS' $LOGFILE) if [ ! -z "$VALUE" ]; then - echo "$VALUE" + echo "$VALUE" else echo "0" fi @@ -97,7 +99,7 @@ echo -n echo -en "login_ssl.value " VALUE=$(egrep -c '[dovecot]?.*Login.*SSL' $LOGFILE) if [ ! -z "$VALUE" ]; then - echo "$VALUE" + echo "$VALUE" else echo "0" fi @@ -108,7 +110,7 @@ echo -n echo -en "login_imap.value " VALUE=$(egrep -c '[dovecot]?.*imap.*Login' $LOGFILE) if [ ! -z "$VALUE" ]; then - echo "$VALUE" + echo "$VALUE" else echo "0" fi @@ -119,7 +121,7 @@ echo -n echo -en "login_pop3.value " VALUE=$(egrep -c '[dovecot]?.*pop3.*Login' $LOGFILE) if [ ! -z "$VALUE" ]; then - echo "$VALUE" + echo "$VALUE" else echo "0" fi diff --git a/dovecot/tasks/munin.yml b/dovecot/tasks/munin.yml index 21d17519..c6b58d28 100644 --- a/dovecot/tasks/munin.yml +++ b/dovecot/tasks/munin.yml @@ -14,8 +14,10 @@ dest: /etc/munin/plugins/dovecot mode: "0755" -# TODO : add in /etc/munin/plugin-conf.d/munin-node -# [dovecot] -# group adm + - name: Install munin config + copy: + src: munin_config + dest: /etc/munin/plugin-conf.d/dovecot + mode: "0644" when: munin_node_plugins_config.stat.exists