mirror of
https://github.com/cmur2/munin-dovecot.git
synced 2024-12-22 02:54:27 +01:00
Fiat lux
This commit is contained in:
commit
b921dd0e93
16
README.md
Normal file
16
README.md
Normal file
@ -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_<mode>
|
||||
|
||||
where <mode> is one of connections (currently only one option).
|
||||
|
||||
**Don't forget to restart your munin-node deamon.**
|
51
dovecot_
Executable file
51
dovecot_
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Source: https://github.com/cmur2/munin-dovecot
|
||||
|
||||
#
|
||||
# Example usage:
|
||||
# Do
|
||||
# ln -s /path/to/dovecot_ dovecot_<mode>
|
||||
# where <mode> 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
|
Loading…
Reference in New Issue
Block a user