diff options
Diffstat (limited to 'remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats')
-rwxr-xr-x | remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats index 6f4e25ec..4dd53d7b 100755 --- a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats +++ b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats @@ -107,12 +107,22 @@ fi # 8) ID44 partition size ID44=0 -for c in $(fdisk -l | grep -E '[0-9]+[\-\+]?\s+44\s+' | awk '{print $1}'); do - val=$(blockdev --getsize64 "$c") - [ -z "$val" ] && continue - [ "$val" -gt "$ID44" ] && ID44=$val -done -ID44=$(( $ID44 / 1058576 )) # we'd rather underreport +# Try df first, make sure device starts with /dev +read -r df_dev df_size df_used df_avail df_usepercent df_mountpoint df_crap < <(df /tmp | grep ' /tmp$') +if [ -n "${df_size}" ] && [ "${df_dev:0:5}" = "/dev/" ]; then + # df reports kbytes, convert to MB + ID44=$(( df_size / 1024 )) +fi +if [ "$ID44" = 0 ]; then + # fdisk fallback + for c in $(fdisk -l | grep -E '[0-9]+[\-\+]?\s+44\s+' | awk '{print $1}'); do + val=$(blockdev --getsize64 "$c") + [ -z "$val" ] && continue + [ "$val" -gt "$ID44" ] && ID44=$val + done + # blockdev reports bytes, convert to MB + ID44=$(( $ID44 / 1058576 )) # we'd rather underreport +fi # 9) check smart values FDISK=$(mktemp) |