File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -523,18 +523,20 @@ _metrics_read_memory() {
523523}
524524
525525# Returns "<used_bytes> <total_bytes>" for the container home directory.
526- # Uses -B1 (POSIX/busybox-compatible) rather than --block-size=1 (GNU-only).
526+ # used = actual bytes consumed by files inside /home/container (via du).
527+ # total = total capacity of the underlying filesystem (via df -B1).
527528_metrics_read_storage () {
529+ local used=0 total=0 df_line
530+ if command -v du & > /dev/null; then
531+ used=" $( du -sb " ${CONTAINER_HOME} " 2> /dev/null | awk ' {print $1}' ) " || used=0
532+ fi
528533 if command -v df & > /dev/null; then
529- local used=0 total=0 df_line
530534 df_line=" $( df -B1 " ${CONTAINER_HOME} " 2> /dev/null | tail -1) " || df_line=" "
531535 if [ -n " $df_line " ]; then
532- read -r _ total used _ _ _ <<< " $df_line" || true
536+ read -r _ total _ _ _ _ <<< " $df_line" || true
533537 fi
534- echo " ${used:- 0} ${total:- 0} "
535- else
536- echo " 0 0"
537538 fi
539+ echo " ${used:- 0} ${total:- 0} "
538540}
539541
540542# Returns "<rx_bytes> <tx_bytes>" cumulative for all non-loopback interfaces.
You can’t perform that action at this time.
0 commit comments