Show Docker RAM usage on Dashboard

- Add Docker RAM usage to Dashbaord page
- Rename 'Services' to 'System'
- Remove 'usage' suffix from Services naming scheme
This commit is contained in:
root
2024-07-16 13:57:21 +02:00
parent bbed6047e3
commit 58c31f4ef6
3 changed files with 29 additions and 1 deletions
+28
View File
@@ -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
+1 -1
View File
@@ -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) {