commit b921dd0e93b0af8512d5f46657afde1b584b28ed Author: cn Date: Wed Sep 18 17:29:02 2013 +0200 Fiat lux diff --git a/README.md b/README.md new file mode 100644 index 0000000..d9caad3 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +munin-dovecot +============= + +Creates Munin graphs from the stats gathered via `doveadm stats dump` from a [Dovecot](http://dovecot.org/) server running on the same host. + +Install +------- + +Clone this repository or download the dovecot_ file and create a +symlink as *root* in /etc/munin/plugins by using e.g.: + + cd /etc/munin/plugins; ln -s /path/to/dovecot_ dovecot_ + +where is one of connections (currently only one option). + +**Don't forget to restart your munin-node deamon.** diff --git a/dovecot_ b/dovecot_ new file mode 100755 index 0000000..9b1c017 --- /dev/null +++ b/dovecot_ @@ -0,0 +1,51 @@ +#!/usr/bin/env ruby + +# Source: https://github.com/cmur2/munin-dovecot + +# +# Example usage: +# Do +# ln -s /path/to/dovecot_ dovecot_ +# where is one of connections. +# +# Example config: +# [dovecot_*] +# + +require 'csv' +require 'open-uri' + +script = File.basename($0) +@mode = script.gsub('dovecot_', '') +@cmd = ARGV[0] + +def echo_connections() + case @cmd + when 'config' + puts "graph_title Dovecot connections" + puts "graph_args --lower-limit 0" + puts "graph_vlabel connections" + puts "graph_category dovecot" + puts "graph_scale no" + puts "graph_info This graph shows the number of connections to Dovecot." + puts "nimap.label imap" + puts "nimap.info Number of imap connections currently open." + puts "nimap.type GAUGE" + else + output = `doveadm stats dump session connected` + csv_data = CSV.parse(output, {:col_sep => "\t"}) + exit 1 if csv_data.empty? + puts "nimap.value #{csv_data.select { |x| x[3] == 'imap'}.size}" + end +end + +# open stderr +$stderr = IO.new(2, "w") + +case @mode +when 'connections' + echo_connections() +else + $stderr.puts "Unknown mode #{@mode} for dovecot_!" + exit 3 +end