diff --git a/emhttp/plugins/dynamix.docker.manager/system/Docker b/emhttp/plugins/dynamix.docker.manager/system/Docker new file mode 100755 index 000000000..9aa6220e0 --- /dev/null +++ b/emhttp/plugins/dynamix.docker.manager/system/Docker @@ -0,0 +1,28 @@ +#!/bin/bash +# Get active containers +ACTIVE_CONTAINERS="$(docker ps -q --no-trunc 2>/dev/null)" + +# Exit if no containers are active and return zero +if [ -z "${ACTIVE_CONTAINERS}" ]; then + echo "0" + exit +fi + +# Get all relevant memory entries from containers +for container in ${ACTIVE_CONTAINERS} ; do + CONT_MEMORY="$(cat /sys/fs/cgroup/docker/${container}/memory.stat 2>/dev/null | grep -Ew "anon|kernel|kernel_stack|pagetables|sec_pagetables|percpu|sock|vmalloc|shmem" | awk '{print $2}')" + # Add up memory values + for value in ${CONT_MEMORY} ; do + if [[ ${value} =~ ^[0-9]+$ ]]; then + ((MEMORY_USAGE += value)) + fi + done + unset CONT_MEMORY +done + +# Check if value is a integer and return the value otherwiese return zero +if [[ ${MEMORY_USAGE} =~ ^[0-9]+$ ]]; then + echo "${MEMORY_USAGE}" +else + echo "0" +fi diff --git a/emhttp/plugins/dynamix/nchan/update_1 b/emhttp/plugins/dynamix/nchan/update_1 index 7668a2bf7..d60d21881 100755 --- a/emhttp/plugins/dynamix/nchan/update_1 +++ b/emhttp/plugins/dynamix/nchan/update_1 @@ -59,7 +59,7 @@ while (true) { exec("sensors -uA 2>/dev/null|grep -Po 'fan\d_input: \K\d+'",$fans); [$total,$free] = $memory; $used = $total-$free; - $names = [_('Services'),_('Free')]; + $names = [_('System'),_('Free')]; $bytes = $echo = []; $hooks = array_filter(glob("/usr/local/emhttp/plugins/*/system/*",GLOB_NOSORT),function($file){return is_executable($file);}); foreach ($hooks as $hook) { diff --git a/emhttp/plugins/dynamix/system/VM_usage b/emhttp/plugins/dynamix/system/VM similarity index 100% rename from emhttp/plugins/dynamix/system/VM_usage rename to emhttp/plugins/dynamix/system/VM