summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfiles/munin/ejabberd_210
-rw-r--r--files/munin/ejabberd_munin.cron4
-rw-r--r--files/munin/ejabberd_registrations.cron8
-rw-r--r--manifests/base.pp22
-rw-r--r--manifests/init.pp20
-rw-r--r--manifests/munin.pp27
-rw-r--r--manifests/nagios.pp21
7 files changed, 184 insertions, 128 deletions
diff --git a/files/munin/ejabberd_ b/files/munin/ejabberd_
index 84f52bd..34a5365 100755
--- a/files/munin/ejabberd_
+++ b/files/munin/ejabberd_
@@ -1,5 +1,5 @@
#!/bin/bash
-#
+#
# Munin plugin for ejabberd.
#
# Written by Lasse Karstensen <lkarsten@hyse.org> 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,89 @@ 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
+ 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
-# 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
+ 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 ";
+ 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 -l
+ fi
+ done
+ exit 0
fi
diff --git a/files/munin/ejabberd_munin.cron b/files/munin/ejabberd_munin.cron
new file mode 100644
index 0000000..f3bf686
--- /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 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
+
diff --git a/files/munin/ejabberd_registrations.cron b/files/munin/ejabberd_registrations.cron
new file mode 100644
index 0000000..fc9de3e
--- /dev/null
+++ b/files/munin/ejabberd_registrations.cron
@@ -0,0 +1,8 @@
+#!/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
+ chgrp munin $stat_file
+ chmod o-rwx $stat_file
+done
diff --git a/manifests/base.pp b/manifests/base.pp
index 1c805c3..b265547 100644
--- a/manifests/base.pp
+++ b/manifests/base.pp
@@ -1,15 +1,27 @@
+# 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':
diff --git a/manifests/init.pp b/manifests/init.pp
index d8b9d44..8c21344 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -2,19 +2,29 @@
# Copyright (C) 2007 admin@immerda.ch
# GPLv3
-class ejabberd {
- case $operatingsystem {
+# Manage an ejabberd server
+class ejabberd(
+ $domains = $::fqdn,
+ $config_content = false,
+ $nagios_domain = $::fqdn,
+ $nagios_user = 'nagios',
+ $nagios_pwd = '',
+ $manage_nagios = false,
+ $manage_munin = false,
+ $manage_shorewall = false
+) {
+ case $::operatingsystem {
default: { include ejabberd::base }
}
- if $use_nagios {
+ if $manage_nagios {
include ejabberd::nagios
}
- if $use_munin {
+ if $manage_munin {
include ejabberd::munin
}
- if $use_shorewall {
+ if $manage_shorewall {
include shorewall::rules::jabberserver
}
}
diff --git a/manifests/munin.pp b/manifests/munin.pp
index 1357e98..33f15d4 100644
--- a/manifests/munin.pp
+++ b/manifests/munin.pp
@@ -1,14 +1,27 @@
+# install munin plugin and helpers
class ejabberd::munin {
- case $ejabberd_domains {
- '': { $ejabberd_domains = $fqdn }
- }
- munin::plugin::deploy{'ejabberd_':
- source => "ejabberd/munin/ejabberd_",
+ munin::plugin::deploy{'ejabberd_':
ensure => absent,
+ source => 'ejabberd/munin/ejabberd_';
}
+ $domains = join($ejabberd::domains, ' ')
munin::plugin{['ejabberd_users','ejabberd_connections','ejabberd_registrations']:
+ ensure => 'ejabberd_',
require => Munin::Plugin::Deploy['ejabberd_'],
- ensure => 'ejabberd_',
- config => "env.vhosts ${ejabberd_domains}\ntimeout 20\nuser root\ngroup root"
+ config => "group munin\nenv.vhosts ${domains}";
+ }
+ File {
+ 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_users','ejabberd_connections'],
+ mode => '0600',
+ source => 'puppet:///modules/ejabberd/munin/ejabberd_munin.cron';
}
}
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}" }
}
}
}