diff --git a/plugins/ejabberd/ejabberd_resources_/ejabberd_resources_ b/plugins/ejabberd/ejabberd_resources_/ejabberd_resources_ index 43d6ed27..f725183d 100755 --- a/plugins/ejabberd/ejabberd_resources_/ejabberd_resources_ +++ b/plugins/ejabberd/ejabberd_resources_/ejabberd_resources_ @@ -14,6 +14,7 @@ # - connect to a running ejabberd node # # OS: *NIX +# Requires lsof/fstat for open_files. # # Author: Artem Sheremet # @@ -120,7 +121,7 @@ code.info The total amount of memory currently allocated for Erlang code. This m ets.info The total amount of memory currently allocated for ets tables. This memory is part of the memory presented as system memory. INFO_FROM_DOC else - pid=$(<$EJABBERD_PID_PATH) + local pid=$(<$EJABBERD_PID_PATH) for memory_type in rss vsz; do memory_value=$(ps -p $pid -o $memory_type=) let memory_value=$memory_value*1024 @@ -140,42 +141,69 @@ function ejabberd_report_ports() { local limit=$(ejabberd_exec 'os:getenv("ERL_MAX_PORTS").' | tr '"' ' ') # string "false" indicates that this variable is not defined, thus a default of 1024 [ $limit = false ] && limit=1024 - local os_limit=$(ejabberd_exec 'os:cmd("ulimit -n").' | tr '"\\n' ' ') - if [ $limit -gt $os_limit ]; then - local real_limit=$os_limit - else - local real_limit=$limit - fi if [ "$1" = "config" ]; then cat </dev/null; then + echo lsof + return 0 + elif hash fstat &>/dev/null; then + echo fstat + return 0 + fi + return 1 +} + +function open_files_number() { + echo $[$($(open_files_counter_util) -np $(<$EJABBERD_PID_PATH) | wc -l)-1] +} + +function ejabberd_report_open_files() { + # this spawns a child process, but in most cases the open files limit is inherited + local limit=$(ejabberd_exec 'os:cmd("ulimit -n").' | tr '"\\n' ' ') + if [ "$1" = "config" ]; then + cat </dev/null && echo open_files exit 0 ;; config)