2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

ejabberd_resources: add mnesia table info support

This commit is contained in:
Artem Sheremet 2015-03-09 10:33:42 +01:00
parent 85072bf99d
commit b518af0f69

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# ejabberd_resources_ revision 3 (Nov 2013)
# ejabberd_resources_ revision 4 (Mar 2015)
#
# Tested with ejabberd 2.1.x
#
@ -8,6 +8,7 @@
# - ejabberd memory usage (RSS, VSZ, erlang internal)
# - ejabberd ports/processes usage
# - online/registered users by vhost
# - mnesia table sizes and location
#
# Required permissions:
# - read ejabberdctl configuration file
@ -19,9 +20,10 @@
# Author: Artem Sheremet <dot.doom@gmail.com>
#
# Configuration:
# - set env.ejabberdctl_cfg to ejabberdctl.cfg path if necessary
# - set env.ejabberdctl_cfg to ejabberdctl.cfg path if not in /etc
# - or set env.ERLANG_NODE, env.EJABBERD_PID_PATH to proper values manually
# - set erl_call_path to unregular erl_call location
# - set env.ejabberdctl to ejabberdctl script path if not on PATH
#%# family=auto
#%# capabilities=autoconf suggest
@ -30,6 +32,8 @@ EJABBERDCTL_CFG=${ejabberdctl_cfg:-/etc/ejabberd/ejabberdctl.cfg}
source $EJABBERDCTL_CFG 2>/dev/null
source $MUNIN_LIBDIR/plugins/plugin.sh
EJABBERDCTL=${ejabberdctl:-$(which ejabberdctl)}
ERLANG_HOST=${ERLANG_NODE/*@/}
ERLANG_MUNIN_NODE=munin
@ -155,6 +159,53 @@ DATA
fi
}
function ejabberd_report_mnesia() {
local draw sed_re long_bits
sed_re='([a-z_]+) *: with ([0-9]+) +records occupying ([0-9]+) +([a-z]+) o[fn] ([a-z]+)'
# 1 = table_name
# 2 = records number
# 3 = bytes/words number
# 4 = unit (bytes or words)
# 5 = storage (disc or mem)
if [ "$1" = config ]; then
echo "graph_vlabel $2"
draw=LINE2
[ "$2" = bytes ] && draw=AREASTACK
$EJABBERDCTL mnesia info | sed -re 's/'"$sed_re"'/\1 \5/;tx;d;:x' |
while read table_name table_storage; do
echo "${table_name}_${table_storage}.draw $draw"
echo "${table_name}_${table_storage}.label $table_name ($table_storage)"
done
else
if [ "$2" = recs ]; then
$EJABBERDCTL mnesia info | sed -re 's/'"$sed_re"'/\1_\5.value \2/;tx;d;:x'
else
long_bits=$(getconf LONG_BIT)
$EJABBERDCTL mnesia info |
sed -re 's/'"$sed_re"'/\1_\5.value \3 \4/;tx;d;:x' |
awk "
/ words\$/ {
print \$1, \$2 * $long_bits / 8
}
/ bytes\$/ {
print \$1, \$2
}
"
fi
fi
}
function ejabberd_report_mnesia_bytes() {
ejabberd_report_mnesia "$1" bytes
}
function ejabberd_report_mnesia_recs() {
ejabberd_report_mnesia "$1" recs
}
function open_files_counter_util() {
if hash lsof &>/dev/null; then
echo lsof
@ -232,6 +283,8 @@ processes
ports
online_users
registered_users
mnesia_recs
mnesia_bytes
SUGGESTIONS
open_files_counter_util &>/dev/null && echo open_files
exit 0