From b41dd54597cd925a3e26879ccf21fba24c435033 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 28 Nov 2012 23:53:19 +0100 Subject: cronify all munin plugins --- files/munin/ejabberd_ | 25 ++++++++++++++++++++----- files/munin/ejabberd_munin.cron | 4 ++++ manifests/munin.pp | 16 ++++++++++------ 3 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 files/munin/ejabberd_munin.cron diff --git a/files/munin/ejabberd_ b/files/munin/ejabberd_ index 1b53683..3837fb4 100755 --- a/files/munin/ejabberd_ +++ b/files/munin/ejabberd_ @@ -126,15 +126,30 @@ fi if [ "$MODE" == "connections" ]; then - echo -n "s2s_connections_out.value " - $EJCTL outgoing-s2s-number - echo -n "s2s_connections_in.value " - $EJCTL incoming-s2s-number + stat_file="/var/lib/munin/plugin-state/ejabberd_conns_out" + if [ -f $stat_file ]; then + out=$(cat $stat_file) + else + out=$($EJCTL outgoing-s2s-number) + fi + stat_file="/var/lib/munin/plugin-state/ejabberd_conns_in" + if [ -f $stat_file ]; then + in=$(cat $stat_file) + else + in=$($EJCTL incoming-s2s-number) + fi + echo "s2s_connections_out.value ${out}" + echo "s2s_connections_in.value ${in}" exit 0 fi if [ "$MODE" == "users" ]; then - connected_users=`$EJCTL connected-users` + stat_file="/var/lib/munin/plugin-state/ejabberd_users" + if [ -f $stat_file ]; then + connected_users=$(cat $stat_file) + else + connected_users=$($EJCTL connected-users) + fi for host in $vhosts; do formathost=$(echo $host | tr '.-' '_') echo -n "connected_users_$formathost.value "; diff --git a/files/munin/ejabberd_munin.cron b/files/munin/ejabberd_munin.cron new file mode 100644 index 0000000..fd8b5ae --- /dev/null +++ b/files/munin/ejabberd_munin.cron @@ -0,0 +1,4 @@ +4-59/5 * * * * root /usr/sbin/ejabberdctl outgoing-s2s-number > /var/lib/munin/plugin-state/ejabberd_conns_out && chgrp munin /var/lib/munin/plugin-state/ejabberd_conns_out && chmod o-rwx /var/lib/munin/plugin-state/ejabberd_conns_out 2>/dev/null +4-59/5 * * * * root /usr/sbin/ejabberdctl incoming-s2s-number > /var/lib/munin/plugin-state/ejabberd_conns_in && chgrp /var/lib/munin/plugin-state/ejabberd_conns_in && chmod o-rwx /var/lib/munin/plugin-state/ejabberd_conns_in 2>/dev/null +4-59/5 * * * * root /usr/sbin/ejabberdctl connected-users > /var/lib/munin/plugin-state/ejabberd_users && chgrp munin /var/lib/munin/plugin-state/ejabberd_users && chmod o-rwx /var/lib/munin/plugin-state/ejabberd_users 2>/dev/null + diff --git a/manifests/munin.pp b/manifests/munin.pp index 2a15630..f87a1b5 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -8,14 +8,18 @@ class ejabberd::munin { munin::plugin{['ejabberd_users','ejabberd_connections','ejabberd_registrations']: ensure => 'ejabberd_', require => [ Munin::Plugin::Deploy['ejabberd_'] ], - config => "env.vhosts ${domains}\ntimeout 30\nuser root\ngroup root"; + config => "env.vhosts ${domains}"; + } + File { + require => Munin::Plugin['ejabberd_registrations'], + owner => root, + group => 0, + mode => '0700', } file{ '/etc/cron.daily/ejabberd_registrations': - source => 'puppet:///modules/ejabberd/munin/ejabberd_registrations.cron', - require => Munin::Plugin['ejabberd_registrations'], - owner => root, - group => 0, - mode => '0700'; + source => 'puppet:///modules/ejabberd/munin/ejabberd_registrations.cron'; + '/etc/cron.d/ejabberd_munin': + source => 'puppet:///modules/ejabberd/munin/ejabberd_munin.cron'; } } -- cgit v1.2.3