From 70af6cca4b8bd7ba6c6e287d827cc65098e22831 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 8 Jun 2012 12:33:12 -0300 Subject: refactor things for >2.7 --- manifests/base.pp | 4 ++-- manifests/init.pp | 15 ++++++++++----- manifests/munin.pp | 10 ++++------ manifests/nagios.pp | 21 +++++++-------------- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/manifests/base.pp b/manifests/base.pp index 12dd9e7..4b9f035 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -4,8 +4,8 @@ class ejabberd::base { } file{'/etc/ejabberd/ejabberd.cfg': - source => [ "puppet:///modules/site-ejabberd/${fqdn}/ejabberd.cfg", - "puppet:///modules/site-ejabberd/ejabberd.cfg", + source => [ "puppet:///modules/site_ejabberd/${::fqdn}/ejabberd.cfg", + "puppet:///modules/site_ejabberd/ejabberd.cfg", "puppet:///modules/ejabberd/ejabberd.cfg" ], require => Package['ejabberd'], notify => Service['ejabberd'], diff --git a/manifests/init.pp b/manifests/init.pp index d8b9d44..91c8e1f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -2,19 +2,24 @@ # Copyright (C) 2007 admin@immerda.ch # GPLv3 -class ejabberd { - case $operatingsystem { +class ejabberd( + $domains = $::fqdn, + $nagios_domain = hiera('ejabberd_nagios_domain', $::fqdn), + $nagios_user = hiera('ejabberd_nagios_user', 'nagios'), + $nagios_pwd = hiera('ejabberd_nagios_pwd','') +) { + case $::operatingsystem { default: { include ejabberd::base } } - if $use_nagios { + if hiera('use_nagios',false) { include ejabberd::nagios } - if $use_munin { + if hiera('use_munin',false) { include ejabberd::munin } - if $use_shorewall { + if hiera('use_shorewall',false) { include shorewall::rules::jabberserver } } diff --git a/manifests/munin.pp b/manifests/munin.pp index 1357e98..61d6432 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -1,14 +1,12 @@ class ejabberd::munin { - case $ejabberd_domains { - '': { $ejabberd_domains = $fqdn } - } - munin::plugin::deploy{'ejabberd_': - source => "ejabberd/munin/ejabberd_", + munin::plugin::deploy{'ejabberd_': + source => "ejabberd/munin/ejabberd_", ensure => absent, } + $domains = join($ejabberd::domains, ' ') munin::plugin{['ejabberd_users','ejabberd_connections','ejabberd_registrations']: require => Munin::Plugin::Deploy['ejabberd_'], ensure => 'ejabberd_', - config => "env.vhosts ${ejabberd_domains}\ntimeout 20\nuser root\ngroup root" + config => "env.vhosts ${domains}\ntimeout 20\nuser root\ngroup root" } } diff --git a/manifests/nagios.pp b/manifests/nagios.pp index 85a7b10..27df382 100644 --- a/manifests/nagios.pp +++ b/manifests/nagios.pp @@ -1,25 +1,18 @@ # manifests/nagios.pp class ejabberd::nagios { - case $jabber_nagios_domain { - '': { $jabber_nagios_domain = $fqdn } - } - nagios::service{ "jabber_${fqdn}": check_command => "check_jabber!${jabber_nagios_domain}" } + nagios::service{ "jabber_${::fqdn}": check_command => "check_jabber!${ejabberd::nagios_domain}" } @@nagios_command{ 'check_jabber_ssl': command_line => '$USER1$/check_jabber -S -p 5223 -H $ARG1$', } - nagios::service{ "jabber_ssl_${fqdn}": check_command => "check_jabber_ssl!${jabber_nagios_domain}" } + nagios::service{ "jabber_ssl_${::fqdn}": check_command => "check_jabber_ssl!${ejabberd::nagios_domain}" } @@nagios_command{ 'check_jabber_cert': command_line => '$USER1$/check_jabber -S -D 10 -p 5223 -H $ARG1$', } - nagios::service{ "jabber_cert_${fqdn}": check_command => "check_jabber_cert!${jabber_nagios_domain}" } - - case $jabber_nagios_user { - '': { $jabber_nagios_user = 'nagios' } - } + nagios::service{ "jabber_cert_${::fqdn}": check_command => "check_jabber_cert!${ejabberd::nagios_domain}" } @@nagios_command{ 'check_jabber_login': @@ -27,10 +20,10 @@ class ejabberd::nagios { require => Nagios::Plugin['check_jabber_login']; } - case $jabber_nagios_pwd { - '': { info("no \$jabber_nagios_pwd supplied for ${fqdn}! Can't test jabber login") } - default: { - nagios::service{ "jabber_login_${fqdn}": check_command => "check_jabber_login!${jabber_nagios_user}@${jabber_nagios_domain}!${jabber_nagios_pwd}" } + case $ejabberd::nagios_pwd { + '': { info("no \$ejabberd::nagios_pwd supplied for ${::fqdn}! Can't test jabber login") } + default: { + nagios::service{ "jabber_login_${::fqdn}": check_command => "check_jabber_login!${ejabberd::nagios_user}@${ejabberd::nagios_domain}!${ejabberd::nagios_pwd}" } } } } -- cgit v1.2.3 From bd7892775e041aec63d645547d9804526cf95839 Mon Sep 17 00:00:00 2001 From: o Date: Thu, 14 Jun 2012 11:23:37 -0300 Subject: remove hiera --- manifests/init.pp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 91c8e1f..5ba015a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,23 +3,26 @@ # GPLv3 class ejabberd( - $domains = $::fqdn, - $nagios_domain = hiera('ejabberd_nagios_domain', $::fqdn), - $nagios_user = hiera('ejabberd_nagios_user', 'nagios'), - $nagios_pwd = hiera('ejabberd_nagios_pwd','') + $domains = $::fqdn, + $nagios_domain = $::fqdn, + $nagios_user = 'nagios', + $nagios_pwd = '', + $manage_nagios = false, + $manage_munin = false, + $manage_shorewall = false ) { case $::operatingsystem { default: { include ejabberd::base } } - if hiera('use_nagios',false) { + if $manage_nagios { include ejabberd::nagios } - if hiera('use_munin',false) { + if $manage_munin { include ejabberd::munin } - if hiera('use_shorewall',false) { + if $manage_shorewall { include shorewall::rules::jabberserver } } -- cgit v1.2.3 From 8b8747039d5312519815b590a5969641ef41b17c Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 21 Oct 2012 12:03:40 +0200 Subject: make it possible to pass the config content, linting --- manifests/base.pp | 28 ++++++++++++++++++++-------- manifests/init.pp | 2 ++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/manifests/base.pp b/manifests/base.pp index 4b9f035..6eee36f 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -1,21 +1,33 @@ +# manages the basic stuff for the service class ejabberd::base { package{'ejabberd': ensure => installed, } file{'/etc/ejabberd/ejabberd.cfg': - source => [ "puppet:///modules/site_ejabberd/${::fqdn}/ejabberd.cfg", - "puppet:///modules/site_ejabberd/ejabberd.cfg", - "puppet:///modules/ejabberd/ejabberd.cfg" ], require => Package['ejabberd'], - notify => Service['ejabberd'], - owner => root, group => ejabberd, mode => 0640; + notify => Service['ejabberd'], + owner => 'root', + group => 'ejabberd', + mode => '0640'; + } + + if $ejabberd::config_content { + File['/etc/ejabberd/ejabberd.cfg']{ + content => $ejabberd::config_content + } + } else { + File['/etc/ejabberd/ejabberd.cfg']{ + source => [ "puppet:///modules/site_ejabberd/${::fqdn}/ejabberd.cfg", + 'puppet:///modules/site_ejabberd/ejabberd.cfg', + 'puppet:///modules/ejabberd/ejabberd.cfg' ] + } } service{'ejabberd': - ensure => running, - enable => true, + ensure => running, + enable => true, hasstatus => true, - require => Package[ejabberd], + require => Package['ejabberd'], } } diff --git a/manifests/init.pp b/manifests/init.pp index 5ba015a..8c21344 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -2,8 +2,10 @@ # Copyright (C) 2007 admin@immerda.ch # GPLv3 +# Manage an ejabberd server class ejabberd( $domains = $::fqdn, + $config_content = false, $nagios_domain = $::fqdn, $nagios_user = 'nagios', $nagios_pwd = '', -- cgit v1.2.3 From 9c67b4bcb9e50e7cc5716ee815403ba82d7dc166 Mon Sep 17 00:00:00 2001 From: mh Date: Sun, 21 Oct 2012 13:58:21 +0200 Subject: increase timeout --- manifests/munin.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/munin.pp b/manifests/munin.pp index 61d6432..b4218f5 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -7,6 +7,6 @@ class ejabberd::munin { munin::plugin{['ejabberd_users','ejabberd_connections','ejabberd_registrations']: require => Munin::Plugin::Deploy['ejabberd_'], ensure => 'ejabberd_', - config => "env.vhosts ${domains}\ntimeout 20\nuser root\ngroup root" + config => "env.vhosts ${domains}\ntimeout 30\nuser root\ngroup root" } } -- cgit v1.2.3 From 9d0260a10ab737a4b1e57403fadcda95e15ce80b Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 27 Nov 2012 14:08:57 +0100 Subject: improve performance of the ejabberd plugin --- files/munin/ejabberd_ | 195 ++++++++++++++++---------------- files/munin/ejabberd_registrations.cron | 6 + manifests/munin.pp | 17 ++- 3 files changed, 117 insertions(+), 101 deletions(-) create mode 100644 files/munin/ejabberd_registrations.cron diff --git a/files/munin/ejabberd_ b/files/munin/ejabberd_ index 84f52bd..1b53683 100755 --- a/files/munin/ejabberd_ +++ b/files/munin/ejabberd_ @@ -1,5 +1,5 @@ #!/bin/bash -# +# # Munin plugin for ejabberd. # # Written by Lasse Karstensen 2007-05-27. @@ -8,15 +8,15 @@ # As connected users, registered users and server-connections have somewhat # different scales, this plugin uses munins suggest feature to create three # different graphs. -# +# # ejabberd_connections # ejabberd_users -# ejabberd_registrations +# ejabberd_registrations # -# use ln -s ejabberd ejabberd_(connections|users|registrations) +# use ln -s ejabberd ejabberd_(connections|users|registrations) # to activate. # -# If the autodetect-feature for vhosts breaks, you can set +# If the autodetect-feature for vhosts breaks, you can set # """ # [ejabberd*] # env.vhosts foo.com bar.com @@ -29,59 +29,59 @@ EJCTL=$ejctl if [ "$EJCTL" == "" ]; then - EJCTL=`which ejabberdctl||echo "/usr/sbin/ejabberdctl"` + EJCTL=`which ejabberdctl||echo "/usr/sbin/ejabberdctl"` fi if [ "$1" == "autoconf" ]; then - if [ -x $EJCTL > /dev/null ]; then - echo yes - exit 0 - fi - echo "no (ejabberdctl not found)" - exit 1 + if [ -x $EJCTL > /dev/null ]; then + echo yes + exit 0 + fi + echo "no (ejabberdctl not found)" + exit 1 fi if [ "$1" == "suggest" ]; then - echo "connections" - echo "users" - echo "registrations" - exit 0 + echo "connections" + echo "users" + echo "registrations" + exit 0 fi # trying to autodetect running vhosts. if [ -z "$vhosts" ]; then - for CFGPATH in /etc/ejabberd /usr/local/ejabberd/etc; do - if [ -f "$CFGPATH/ejabberd.cfg" ]; then - EJCFG=$CFGPATH/ejabberd.cfg; - fi - done - if [ -z "$EJCFG" ]; then - echo "Unable to find ejabberd.cfg. Exiting." > /dev/stderr - exit -1 + for CFGPATH in /etc/ejabberd /usr/local/ejabberd/etc; do + if [ -f "$CFGPATH/ejabberd.cfg" ]; then + EJCFG=$CFGPATH/ejabberd.cfg; fi + done + if [ -z "$EJCFG" ]; then + echo "Unable to find ejabberd.cfg. Exiting." > /dev/stderr + exit -1 + fi - # this is pretty trivial, and may break if you have many vhosts. - vhosts=$(egrep -A5 '^\{hosts' $EJCFG | \ - egrep -v "^#" | \ + # this is pretty trivial, and may break if you have many vhosts. + vhosts=$(egrep -A5 '^\{hosts' $EJCFG | \ + egrep -v "^#" | \ # make it one whole line. - tr '\n' ' ' | \ + tr '\n' ' ' | \ # eat what is before [ and after ] on the line. - sed -e 's/.*\[//' -e 's/\].*//' | \ + sed -e 's/.*\[//' -e 's/\].*//' | \ # remove the "s - sed -e 's/\"//g' | \ + sed -e 's/\"//g' | \ # clean up whitespaces - sed -e 's/ //g' | \ - sed -e 's/,/ /g' | \ - # hmm, wonder if this should be here. - sed -e 's/localhost//' ) + sed -e 's/ //g' | \ + sed -e 's/,/ /g' | \ + # hmm, wonder if this should be here. + sed -e 's/localhost//' ) # all set! - # okay, not so trivial. hope it works. if you get funky results, - # try adjusting the "egrep -Ax" above. + # okay, not so trivial. hope it works. if you get funky results, + # try adjusting the "egrep -Ax" above. fi if [ -z "$vhosts" ]; then - echo "No vhosts to sample." > /dev/stderr - echo "Please set env.vhosts in plugins-conf.d/munin-node." > /dev/stderr - exit -1 + echo "No vhosts to sample." > /dev/stderr + echo "Please set env.vhosts in plugins-conf.d/munin-node." > /dev/stderr + exit -1 fi MODE=`basename $0 | sed 's/^ejabberd_//g'` @@ -93,73 +93,74 @@ if ! [ "$MODE" == "connections" -o "$MODE" == "users" \ fi if [ "$1" = "config" ]; then - echo 'graph_args --base 1000 -l 0' - echo 'graph_scale no' - echo 'graph_category ejabberd' - echo 'graph_info This graph shows a statistic of ejabberd ' - - if [ "$MODE" == "connections" ]; then - echo 's2s_connections_out.label incoming s2s connections' - echo 's2s_connections_out.info Number of outgoing server to server connections' - - echo 's2s_connections_in.label outgoing s2s connections' - echo 's2s_connections_in.info Number of incoming server to server connections' - elif [ "$MODE" == "users" ]; then - echo 'graph_title ejabberd connected users' - echo 'graph_vlabel users' -# echo 'connected_users.info Number of logged in users' -# echo 'connected_users.label connected users' - for host in $vhosts; do - formathost=$(echo $host | tr '.-' '_') - echo "connected_users_$formathost.label $host connected users"; - echo "connected_unique_users_$formathost.label $host unique connected users"; - done; - elif [ "$MODE" == "registrations" ]; then - echo 'graph_title ejabberd registrations' - echo 'graph_vlabel users' - for host in $vhosts; do - formathost=$(echo $host | tr '.-' '_') - echo "registered_$formathost.label $host registered users"; - echo "registered_$formathost.info Registered users for vhost $host" - done; - fi - exit 0 + echo 'graph_args --base 1000 -l 0' + echo 'graph_scale no' + echo 'graph_category ejabberd' + echo 'graph_info This graph shows a statistic of ejabberd ' + + if [ "$MODE" == "connections" ]; then + echo 's2s_connections_out.label incoming s2s connections' + echo 's2s_connections_out.info Number of outgoing server to server connections' + + echo 's2s_connections_in.label outgoing s2s connections' + echo 's2s_connections_in.info Number of incoming server to server connections' + elif [ "$MODE" == "users" ]; then + echo 'graph_title ejabberd connected users' + echo 'graph_vlabel users' + for host in $vhosts; do + formathost=$(echo $host | tr '.-' '_') + echo "connected_users_$formathost.label $host connected users"; + echo "connected_unique_users_$formathost.label $host unique connected users"; + done; + elif [ "$MODE" == "registrations" ]; then + echo 'graph_title ejabberd registrations' + echo 'graph_vlabel users' + for host in $vhosts; do + formathost=$(echo $host | tr '.-' '_') + echo "registered_$formathost.label $host registered users"; + echo "registered_$formathost.info Registered users for vhost $host" + done; + fi + exit 0 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 - exit 0 + echo -n "s2s_connections_out.value " + $EJCTL outgoing-s2s-number + echo -n "s2s_connections_in.value " + $EJCTL incoming-s2s-number + exit 0 fi if [ "$MODE" == "users" ]; then -# echo -n "connected_unique_users.value " -# $EJCTL connected-users | awk -F/ '{print $1}' | sort | uniq | wc -l - - for host in $vhosts; do - formathost=$(echo $host | tr '.-' '_') - echo -n "connected_users_$formathost.value "; - $EJCTL connected-users | grep "@$host" | wc -l - echo -n "connected_unique_users_$formathost.value "; - $EJCTL connected-users | grep "@$host" | awk -F/ '{print $1}' | sort | uniq | wc -l - done - exit 0 + connected_users=`$EJCTL connected-users` + for host in $vhosts; do + formathost=$(echo $host | tr '.-' '_') + echo -n "connected_users_$formathost.value "; + echo $connected_users | grep "@$host" | wc -l + echo -n "connected_unique_users_$formathost.value "; + echo $connected_users | grep "@$host" | awk -F/ '{print $1}' | sort | uniq | wc -l + done + exit 0 fi if [ "$MODE" == "registrations" ]; then - for host in $vhosts; do - formathost=$(echo $host | tr '.-' '_') - echo -n "registered_$formathost.value "; - num=$($EJCTL registered-users $host) - if [ "$?" != 0 ]; then - echo "U" - else - echo $num | wc -w - fi - done - exit 0 + for host in $vhosts; do + formathost=$(echo $host | tr '.-' '_') + echo -n "registered_$formathost.value "; + stat_file="/var/lib/munin/plugin-state/ejabberd_registrations_${host}" + if [ -f $stat_file ]; then + num=$(cat $stat_file) + else + num=$($EJCTL registered-users $host) + fi + if [ "$?" != 0 ]; then + echo "U" + else + echo $num | wc -w + fi + done + exit 0 fi diff --git a/files/munin/ejabberd_registrations.cron b/files/munin/ejabberd_registrations.cron new file mode 100644 index 0000000..34caf22 --- /dev/null +++ b/files/munin/ejabberd_registrations.cron @@ -0,0 +1,6 @@ +#!/bin/bash + +for host in `cat /etc/munin/plugin-conf.d/ejabberd_registrations.conf | grep env.vhosts | sed 's/env.vhosts //'`; do + stat_file="/var/lib/munin/plugin-state/ejabberd_registrations_${host}" + ejabberdctl registered-users $host > $stat_file +done diff --git a/manifests/munin.pp b/manifests/munin.pp index b4218f5..2a15630 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -1,12 +1,21 @@ +# install munin plugin and helpers class ejabberd::munin { munin::plugin::deploy{'ejabberd_': - source => "ejabberd/munin/ejabberd_", ensure => absent, + source => 'ejabberd/munin/ejabberd_'; } $domains = join($ejabberd::domains, ' ') munin::plugin{['ejabberd_users','ejabberd_connections','ejabberd_registrations']: - require => Munin::Plugin::Deploy['ejabberd_'], - ensure => 'ejabberd_', - config => "env.vhosts ${domains}\ntimeout 30\nuser root\ngroup root" + ensure => 'ejabberd_', + require => [ Munin::Plugin::Deploy['ejabberd_'] ], + config => "env.vhosts ${domains}\ntimeout 30\nuser root\ngroup root"; + } + 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'; } } -- cgit v1.2.3 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 From cc06c35787d5ad3145f3e7849a6640d141e996e4 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 28 Nov 2012 23:57:30 +0100 Subject: fix cron --- files/munin/ejabberd_munin.cron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/munin/ejabberd_munin.cron b/files/munin/ejabberd_munin.cron index fd8b5ae..f3bf686 100644 --- a/files/munin/ejabberd_munin.cron +++ b/files/munin/ejabberd_munin.cron @@ -1,4 +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 incoming-s2s-number > /var/lib/munin/plugin-state/ejabberd_conns_in && chgrp munin /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 -- cgit v1.2.3 From b6396f5a1ebb2221e00ee2f9fa0fb11f317bb7df Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 1 Dec 2012 13:25:56 +0100 Subject: workaround a possible scoping bug in puppet --- manifests/munin.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/munin.pp b/manifests/munin.pp index f87a1b5..8809a8d 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -11,15 +11,16 @@ class ejabberd::munin { config => "env.vhosts ${domains}"; } File { - require => Munin::Plugin['ejabberd_registrations'], owner => root, group => 0, mode => '0700', } file{ '/etc/cron.daily/ejabberd_registrations': + require => Munin::Plugin['ejabberd_registrations'], source => 'puppet:///modules/ejabberd/munin/ejabberd_registrations.cron'; '/etc/cron.d/ejabberd_munin': + require => Munin::Plugin['ejabberd_registrations'], source => 'puppet:///modules/ejabberd/munin/ejabberd_munin.cron'; } } -- cgit v1.2.3 From e34218f03210c7cdb0a794f0aa4a1574e466545a Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 1 Dec 2012 13:32:35 +0100 Subject: require ments --- manifests/munin.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/munin.pp b/manifests/munin.pp index 8809a8d..ea41b0e 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -7,7 +7,7 @@ class ejabberd::munin { $domains = join($ejabberd::domains, ' ') munin::plugin{['ejabberd_users','ejabberd_connections','ejabberd_registrations']: ensure => 'ejabberd_', - require => [ Munin::Plugin::Deploy['ejabberd_'] ], + require => Munin::Plugin::Deploy['ejabberd_'], config => "env.vhosts ${domains}"; } File { @@ -20,7 +20,7 @@ class ejabberd::munin { require => Munin::Plugin['ejabberd_registrations'], source => 'puppet:///modules/ejabberd/munin/ejabberd_registrations.cron'; '/etc/cron.d/ejabberd_munin': - require => Munin::Plugin['ejabberd_registrations'], + require => Munin::Plugin['ejabberd_users','ejabberd_connections'], source => 'puppet:///modules/ejabberd/munin/ejabberd_munin.cron'; } } -- cgit v1.2.3 From 68a54389de6ca6af13ecde7f4988787a83132d01 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 1 Dec 2012 13:35:50 +0100 Subject: should not be readable by everyone --- files/munin/ejabberd_registrations.cron | 2 ++ 1 file changed, 2 insertions(+) diff --git a/files/munin/ejabberd_registrations.cron b/files/munin/ejabberd_registrations.cron index 34caf22..fc9de3e 100644 --- a/files/munin/ejabberd_registrations.cron +++ b/files/munin/ejabberd_registrations.cron @@ -3,4 +3,6 @@ for host in `cat /etc/munin/plugin-conf.d/ejabberd_registrations.conf | grep env.vhosts | sed 's/env.vhosts //'`; do stat_file="/var/lib/munin/plugin-state/ejabberd_registrations_${host}" ejabberdctl registered-users $host > $stat_file + chgrp munin $stat_file + chmod o-rwx $stat_file done -- cgit v1.2.3 From 591ff480a44bbbd040a102d4941f53a8ba29f8cb Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 1 Dec 2012 14:35:54 +0100 Subject: run as munin group --- manifests/munin.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/munin.pp b/manifests/munin.pp index ea41b0e..83146ef 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -8,7 +8,7 @@ class ejabberd::munin { munin::plugin{['ejabberd_users','ejabberd_connections','ejabberd_registrations']: ensure => 'ejabberd_', require => Munin::Plugin::Deploy['ejabberd_'], - config => "env.vhosts ${domains}"; + config => "group munin\nenv.vhosts ${domains}"; } File { owner => root, -- cgit v1.2.3 From 890e62c6dd78e0d4d96256b99ab1f57098ee4233 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 1 Dec 2012 14:38:36 +0100 Subject: correct filemode --- manifests/munin.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/munin.pp b/manifests/munin.pp index 83146ef..33f15d4 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -21,6 +21,7 @@ class ejabberd::munin { source => 'puppet:///modules/ejabberd/munin/ejabberd_registrations.cron'; '/etc/cron.d/ejabberd_munin': require => Munin::Plugin['ejabberd_users','ejabberd_connections'], + mode => '0600', source => 'puppet:///modules/ejabberd/munin/ejabberd_munin.cron'; } } -- cgit v1.2.3 From 199551906b8eca94e23c16b5619c206488cc112a Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 15 Dec 2012 19:20:36 +0100 Subject: fix output of a prerecorded value --- files/munin/ejabberd_ | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/files/munin/ejabberd_ b/files/munin/ejabberd_ index 3837fb4..34a5365 100755 --- a/files/munin/ejabberd_ +++ b/files/munin/ejabberd_ @@ -153,9 +153,9 @@ if [ "$MODE" == "users" ]; then for host in $vhosts; do formathost=$(echo $host | tr '.-' '_') echo -n "connected_users_$formathost.value "; - echo $connected_users | grep "@$host" | wc -l + echo "${connected_users}" | grep "@$host" | wc -l echo -n "connected_unique_users_$formathost.value "; - echo $connected_users | grep "@$host" | awk -F/ '{print $1}' | sort | uniq | wc -l + echo "${connected_users}" | grep "@$host" | awk -F/ '{print $1}' | sort | uniq | wc -l done exit 0 fi @@ -173,7 +173,7 @@ if [ "$MODE" == "registrations" ]; then if [ "$?" != 0 ]; then echo "U" else - echo $num | wc -w + echo "${num}" | wc -l fi done exit 0 -- cgit v1.2.3