From 87b0d2dbbf9b32a2596d358b43da0d7424e6157a Mon Sep 17 00:00:00 2001 From: Alexandru-Victor Macocian Date: Thu, 30 Oct 2025 17:54:54 +0100 Subject: [PATCH] Disk usage tweaks --- custom-metrics/disk-usage.sh | 16 ++++++++++++---- custom-metrics/power-usage.sh | 3 ++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/custom-metrics/disk-usage.sh b/custom-metrics/disk-usage.sh index 19e274f..287af82 100644 --- a/custom-metrics/disk-usage.sh +++ b/custom-metrics/disk-usage.sh @@ -22,14 +22,22 @@ for i in {1..6}; do # Use process substitution instead of pipe to avoid subshell issues if [[ "$OS_TYPE" == "macos" ]]; then # macOS df format: Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on - while read -r filesystem blocks used avail capacity iused ifree iusedpct mount; do + # Mount points can have spaces, so we need to handle the full line + while IFS= read -r line; do # Skip header line - if [[ "$filesystem" == "Filesystem" ]]; then + if [[ "$line" =~ ^Filesystem ]]; then continue fi - # Convert 512-byte blocks to bytes - if [[ -n "$mount" && -n "$used" && -n "$blocks" ]]; then + # Extract fields using awk (handles multi-word mount points) + filesystem=$(echo "$line" | awk '{print $1}') + blocks=$(echo "$line" | awk '{print $2}') + used=$(echo "$line" | awk '{print $3}') + # Mount point is everything from column 9 onwards + mount=$(echo "$line" | awk '{for(i=9;i<=NF;i++) printf "%s%s", $i, (i> "$LOGFILE" diff --git a/custom-metrics/power-usage.sh b/custom-metrics/power-usage.sh index 86120d6..9765fe9 100755 --- a/custom-metrics/power-usage.sh +++ b/custom-metrics/power-usage.sh @@ -43,6 +43,7 @@ fi LogInformation "Starting power usage monitoring (OS: $OS_TYPE)" +# Run 6 iterations with 10-second intervals = 60 seconds total (no gaps) for i in {1..6}; do timestamp=$(GetTimestamp) @@ -115,7 +116,7 @@ for i in {1..6}; do fi if [ $i -lt 6 ]; then - sleep 9 + sleep 10 fi done