fix motd.sh disks for btrfs

This commit is contained in:
Alice Gaudon 2024-03-21 10:12:30 +01:00
parent 025f53864b
commit eaf18459e9

30
motd.sh
View File

@ -109,7 +109,7 @@ max_usage=80
bar_width=50 bar_width=50
# disk usage: ignore zfs, squashfs & tmpfs # disk usage: ignore zfs, squashfs & tmpfs
DISKS=$(df -H -x squashfs -x tmpfs -x devtmpfs -x zfs --output=target,pcent,size,used | tail -n+2)" 0 0 0 -" DISKS=$(df -H -x squashfs -x tmpfs -x devtmpfs -x zfs -x overlay --output=target,pcent,size,used | tail -n+2)" 0 0 0 -"
if test $(command -v zfs); then if test $(command -v zfs); then
DISKS+="\n" DISKS+="\n"
@ -134,19 +134,29 @@ while read line; do
fi fi
# get disk usage # get disk usage
dds=$(echo "$line" | awk '{print $6}' | sed 's/%//') dds=$(echo "$line" | awk '{print $6}' | sed 's/%//')
dds_width=$((($dds*$bar_width)/100)) if [ -z "$dds" ]; then
child=$(echo "$line" | awk '{print $7}' | sed 's/%//') dds_width=0
child_width=$((($child*$bar_width)/100)) child_width=0
snap=$(echo "$line" | awk '{print $5}' | sed 's/%//') snap_width=0
snap_width=$((($snap*$bar_width)/100)) usage=$(echo "$line" | sed -E "s/.+([0-9]{2,3})%.+/\1/")
usage=$(echo "$line" | awk '{print $2}' | sed 's/%//') else
used_width=$((($usage*$bar_width)/100)) dds_width=$((($dds*$bar_width)/100))
#echo "$line" child=$(echo "$line" | awk '{print $7}' | sed 's/%//')
child_width=$((($child*$bar_width)/100))
snap=$(echo "$line" | awk '{print $5}' | sed 's/%//')
snap_width=$((($snap*$bar_width)/100))
usage=$(echo "$line" | awk '{print $2}' | sed 's/%//')
fi
used_width=$((($usage*$bar_width)/100))
#echo "$line"
#echo "$dds,$dds_width|$child,$child_width|$snap,$snap_width|$usage,$used_width" #echo "$dds,$dds_width|$child,$child_width|$snap,$snap_width|$usage,$used_width"
i=0 i=0
# [ # [
bar="[" bar="["
# DDS # DDS