diff --git a/plugins/ejabberd/ejabberd_resources_/ejabberd_resources_ b/plugins/ejabberd/ejabberd_resources_/ejabberd_resources_ index ae16d4a5..4621a5e7 100755 --- a/plugins/ejabberd/ejabberd_resources_/ejabberd_resources_ +++ b/plugins/ejabberd/ejabberd_resources_/ejabberd_resources_ @@ -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 # # 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_path to unregular erlang interpreter cli location +# - 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,25 +32,19 @@ 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 -ERL=${erl_path:-$(which erl)} +if [ -n "$erl_path" ] && [ -z "$erl_call_path" ]; then + erl_call_path="$erl_path"_call +fi + +ERL_CALL=${erl_call_path:-$(which erl_call)} function ejabberd_exec() { - COMMAND=${1//\"/\\\"} - su - ejabberd $ERL -noinput \ - -sname $ERLANG_MUNIN_NODE@$ERLANG_HOST \ - -noinput \ - -hidden \ - -eval "try {ok,S,_} = erl_scan:string(\"$COMMAND\"), - {ok,P} = erl_parse:parse_exprs(S), - {value,V,_} = rpc:call('$ERLANG_NODE', erl_eval, exprs, [P,[]]), - io:format(\"~p\n\", [V]) - catch - _:Err -> io:format(\"~p\n\", [Err]) - end." \ - -s init stop + echo "$1" | su - ejabberd -c "$ERL_CALL -e -n $ERLANG_NODE" | sed -re 's/^\{ok, (.*)\}$/\1/' } SCRIPT_NAME=$(basename $0) @@ -94,6 +90,7 @@ CONFIG done } + function ejabberd_report_memory() { if [ "$1" = "config" ]; then cat </dev/null; then echo lsof @@ -244,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 diff --git a/plugins/network/ping/ping b/plugins/network/ping/ping index 858fb6d3..3495dd77 100755 --- a/plugins/network/ping/ping +++ b/plugins/network/ping/ping @@ -70,7 +70,9 @@ use Munin::Plugin; my $ping = exists $ENV{ping} ? $ENV{ping} : "ping"; my $ping6 = exists $ENV{ping6} ? $ENV{ping6} : "ping6"; -my $ping_args = exists $ENV{ping_args} ? $ENV{ping_args} : "-c 2 -w 1"; +# Since ping sends a packet every second (-i 1) by default, +# we may need 2 total seconds (-w 2) for <1000msec replies +my $ping_args = exists $ENV{ping_args} ? $ENV{ping_args} : "-c 2 -w 2"; my $ping_args2 = exists $ENV{ping_args2} ? $ENV{ping_args2} : ""; my $fork = exists $ENV{fork} ? $ENV{fork} : 0; my $packetloss_mode = ($0 =~ /_packetloss$/);