mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
ejabberd version 2.1 supported
This commit is contained in:
parent
25eaea92d3
commit
c2f5c1e441
@ -5,8 +5,8 @@
|
||||
# Written by Lasse Karstensen <lkarsten@hyse.org> 2007-05-27.
|
||||
# Based on ejabberd-plugin by Christian Dröge <Christian@draugr.de>
|
||||
#
|
||||
# Status, memory, threads, uptime, usersindays, ejabberd2 and other code
|
||||
# optimisation by Peter Viskup <skupko.sk@gmail.com>
|
||||
# Status, memory, threads, ejabberd2 and other code optimalisation
|
||||
# by Peter Viskup <skupko.sk@gmail.com>
|
||||
#
|
||||
# As connected users, registered users and server-connections have somewhat
|
||||
# different scales, this plugin uses munins suggest feature to create three
|
||||
@ -18,40 +18,31 @@
|
||||
# ejabberd_statuses
|
||||
# ejabberd_memory
|
||||
# ejabberd_threads
|
||||
# ejabberd_usersindays
|
||||
# ejabberd_userindays
|
||||
# ejabberd_uptime
|
||||
#
|
||||
# use command
|
||||
# ln -s ejabberd_ ejabberd_(connections|memory|registrations|statuses|threads|uptime|users|usersindays)
|
||||
# use ln -s ejabberd ejabberd_(connections|users|registrations)
|
||||
# to activate.
|
||||
#
|
||||
# If the autodetect-feature for vhosts breaks, you can set
|
||||
# """
|
||||
# [ejabberd_*]
|
||||
# [ejabberd*]
|
||||
# env.vhosts foo.com bar.com
|
||||
# """
|
||||
# in plugin-conf.d/munin-node to override it.
|
||||
# (user root may also be smart/not so smart depending on your setup.)
|
||||
# Be aware that datasource name of rrdtool is restricted to 19 characters maximum. It could lead to not working plugin if vhost string is too long.
|
||||
# http://oss.oetiker.ch/rrdtool/doc/rrdcreate.en.html
|
||||
#
|
||||
# For monitoring user statuses - define statuses environment variable:
|
||||
# (you can monitor only some of them)
|
||||
# [ejabberd_*]
|
||||
# env.statuses available away chat xa
|
||||
#
|
||||
# For usersindays statistics define days environment variable
|
||||
# Be careful on high loaded servers, because it will plot all days in one
|
||||
# graph.
|
||||
# [ejabberd_*]
|
||||
# env.days 1 7 30
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
|
||||
EJCTL=$(which ejabberdctl)
|
||||
# Add munin argument to ejabberdctl to prevent a lot of ejabberdctl
|
||||
# records in memory see discussion:
|
||||
# http://lists.jabber.ru/pipermail/ejabberd/2009-September/005337.html
|
||||
EJVER=$($EJCTL status | awk '/^ejabberd / {print $2}')
|
||||
|
||||
if [ "$1" == "autoconf" ]; then
|
||||
if [ -x "$EJCTL" > /dev/null ]; then
|
||||
if [ -x $EJCTL > /dev/null ]; then
|
||||
echo yes
|
||||
exit 0
|
||||
fi
|
||||
@ -87,9 +78,9 @@ if [ -z "$vhosts" ]; then
|
||||
fi
|
||||
|
||||
# get ejabberd PID
|
||||
# in GNU/Linux Debian Lenny release the pidof command can be executed only by root
|
||||
#EJPID=$(pidof -s /usr/lib/erlang/erts-5.6.3/bin/beam.smp)
|
||||
EJPID=$(ps -ef | awk '/ejabberd/ && /\/bin\/beam(.smp)?/ {print $2}')
|
||||
#EJPID=$(ps -ef | awk '/\/bin\/beam.smp/ && !/awk/ {print $2}')
|
||||
EJPID=$(cat /var/run/ejabberd/ejabberd.pid)
|
||||
|
||||
if [ -z "$vhosts" ]; then
|
||||
echo "No vhosts to sample." > /dev/stderr
|
||||
@ -105,6 +96,9 @@ if ! [ "$MODE" == "connections" -o "$MODE" == "users" \
|
||||
-o "$MODE" == "usersindays" -o "$MODE" == "uptime" ]; then
|
||||
echo "ERROR: Unknown mode \"$MODE\". Exiting." > /dev/stderr
|
||||
exit -1
|
||||
else
|
||||
# EJCTL="$EJCTL munin$MODE"
|
||||
EJCTL="$EJCTL munin"
|
||||
fi
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
@ -126,14 +120,14 @@ if [ "$1" = "config" ]; then
|
||||
echo 'graph_info This graph shows a statistic of ejabberd'
|
||||
|
||||
if [ "$MODE" == "connections" ]; then
|
||||
echo 'graph_title Server-to-server conections'
|
||||
echo 'graph_title ejabberd server-to-server conections'
|
||||
echo 'graph_vlabel s2s'
|
||||
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 Connected users'
|
||||
echo 'graph_title ejabberd connected users'
|
||||
echo 'graph_vlabel users'
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
@ -141,7 +135,7 @@ if [ "$1" = "config" ]; then
|
||||
echo "connected_unique_users_$formathost.label $host unique connected users";
|
||||
done;
|
||||
elif [ "$MODE" == "registrations" ]; then
|
||||
echo 'graph_title Number of registered users'
|
||||
echo 'graph_title ejabberd registrations'
|
||||
echo 'graph_vlabel users'
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
@ -149,13 +143,13 @@ if [ "$1" = "config" ]; then
|
||||
echo "registered_$formathost.info Registered users for vhost $host"
|
||||
done;
|
||||
elif [ "$MODE" == "statuses" ]; then
|
||||
echo 'graph_title Users with statuses'
|
||||
echo 'graph_title users with statuses'
|
||||
echo 'graph_vlabel users'
|
||||
for host in $vhosts; do
|
||||
for status in $statuses; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "status_${formathost}_${status}.label $status on $host";
|
||||
echo "status_${formathost}_${status}.info Number of users with status $status on $host [available, away, xa=not available, dnd=(do not disturb) or (busy), chat=free for chat]";
|
||||
echo "status_${formathost}_${status}.info Users with status $status on $host [xa=not available, dnd=(do not disturb) or (busy), chat=free for chat]";
|
||||
done;
|
||||
done;
|
||||
elif [ "$MODE" == "threads" ]; then
|
||||
@ -184,46 +178,110 @@ if [ "$1" = "config" ]; then
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "connections" ]; then
|
||||
echo "s2s_connections_out.value $($EJCTL outgoing-s2s-number)"
|
||||
echo "s2s_connections_in.value $($EJCTL incoming-s2s-number)"
|
||||
echo "s2s_connections_out.value $($EJCTL outgoing_s2s_number)"
|
||||
echo "s2s_connections_in.value $($EJCTL incoming_s2s_number)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "users" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "connected_users_$formathost.value $($EJCTL vhost $host stats onlineusers)";
|
||||
echo "connected_unique_users_$formathost.value $($EJCTL connected-users | awk -v var=$host -F/ '{users[$1]} END {for (user in users) {if (index(user,var)) {count++}} print count}')";
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "registrations" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
num=$($EJCTL vhost $host stats registeredusers)
|
||||
if [ "$?" != 0 ]; then
|
||||
num="U"
|
||||
fi
|
||||
echo "registered_$formathost.value $num";
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "statuses" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
for status in $statuses; do
|
||||
num=$($EJCTL vhost $host status-num $status)
|
||||
if [ "$?" != 0 ]; then
|
||||
num="U"
|
||||
fi
|
||||
echo "status_${formathost}_${status}.value $num";
|
||||
if [[ ${EJVER%\.[0-9]} == 2.1 ]]; then
|
||||
if [ "$MODE" == "users" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "connected_users_$formathost.value $($EJCTL stats_host onlineusers $host)";
|
||||
echo "connected_unique_users_$formathost.value $($EJCTL connected_users_vhost $host | awk -v var=$host -F/ '{users[$1]} END {for (user in users) {if (index(user,var)) {count++}} print count}')";
|
||||
done
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "registrations" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
num=$($EJCTL stats_host registeredusers $host)
|
||||
if [ "$?" != 0 ]; then
|
||||
num="U"
|
||||
fi
|
||||
echo "registered_$formathost.value $num";
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "statuses" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
for status in $statuses; do
|
||||
num=$($EJCTL status_num_host $host $status)
|
||||
if [ "$?" != 0 ]; then
|
||||
num="U"
|
||||
fi
|
||||
echo "status_${formathost}_${status}.value $num";
|
||||
done
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "usersindays" ]; then
|
||||
for host in $vhosts; do
|
||||
for num in $days; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "usersindays_${formathost}_${num}.value $($EJCTL num_active_users $host $num)";
|
||||
done;
|
||||
done;
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "uptime" ]; then
|
||||
echo "uptime.value $($EJCTL stats uptimeseconds | awk '{printf "%.2f", $1/86400}')"
|
||||
fi
|
||||
elif [[ ${EJVER%\.[0-9]} == 2.0 ]]; then
|
||||
if [ "$MODE" == "users" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "connected_users_$formathost.value $($EJCTL vhost $host stats onlineusers)";
|
||||
echo "connected_unique_users_$formathost.value $($EJCTL connected-users | awk -v var=$host -F/ '{users[$1]} END {for (user in users) {if (index(user,var)) {count++}} print count}')";
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "registrations" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
num=$($EJCTL vhost $host stats registeredusers)
|
||||
if [ "$?" != 0 ]; then
|
||||
num="U"
|
||||
fi
|
||||
echo "registered_$formathost.value $num"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "statuses" ]; then
|
||||
for host in $vhosts; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
for status in $statuses; do
|
||||
num=$($EJCTL vhost $host status-num $status)
|
||||
if [ "$?" != 0 ]; then
|
||||
num="U"
|
||||
fi
|
||||
echo "status_${formathost}_${status}.value $num";
|
||||
done
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "usersindays" ]; then
|
||||
for host in $vhosts; do
|
||||
for num in $days; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "usersindays_${formathost}_${num}.value $($EJCTL vhost $host num-active-users $num)";
|
||||
done;
|
||||
done;
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "uptime" ]; then
|
||||
echo "uptime.value $($EJCTL stats uptime-seconds | awk '{printf "%.2f", $1/86400}')"
|
||||
fi
|
||||
fi
|
||||
if [ "$MODE" == "memory" ]; then
|
||||
echo "ejabberd_memory_size.value $(awk '/VmSize/ {print $2*1024}' /proc/${EJPID}/status)"
|
||||
echo "ejabberd_memory_peak.value $(awk '/VmPeak/ {print $2*1024}' /proc/${EJPID}/status)"
|
||||
@ -234,17 +292,3 @@ if [ "$MODE" == "threads" ]; then
|
||||
echo "ejabberd_threads.value $(awk '/Threads/ {print $2}' /proc/${EJPID}/status)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "usersindays" ]; then
|
||||
for host in $vhosts; do
|
||||
for num in $days; do
|
||||
formathost=$(echo $host | tr '.' '_')
|
||||
echo "usersindays_${formathost}_${num}.value $($EJCTL vhost $host num-active-users $num)";
|
||||
done;
|
||||
done;
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$MODE" == "uptime" ]; then
|
||||
echo "uptime.value $($EJCTL stats uptime-seconds | awk '{printf "%.2f", $1/86400}')"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user