add header

This commit is contained in:
2026-07-13 10:54:35 -04:00
parent 681eb144ae
commit 81f704f248
+9 -2
View File
@@ -89,9 +89,11 @@ COLOR=false
C_BOLD=""
C_RED=""
C_RESET=""
C_DIM=""
if [ -t 1 ]; then
COLOR=true
C_BOLD=$'\e[1m'
C_DIM=$'\e[2m'
C_RED=$'\e[1;38;2;207;34;46m'
C_RESET=$'\e[0m'
fi
@@ -127,6 +129,7 @@ usage_txt() {
# ─── SMART Disk Health (SATA/SAS) ───────────────────────────────
STATUS+="${C_BOLD}SMART (SATA):${C_RESET}\n"
STATUS+="${C_DIM}$(printf ' %-13s %-24s %5s %7s %s' Disk Model Temp Hours Health)${C_RESET}\n"
for disk in /dev/sd?; do
[ -b "$disk" ] || continue
@@ -173,6 +176,7 @@ done
# ─── SMART Disk Health (NVMe) ───────────────────────────────────
STATUS+="\n${C_BOLD}SMART (NVMe):${C_RESET}\n"
STATUS+="${C_DIM}$(printf ' %-13s %-24s %5s %7s %s' Disk Model Temp Hours Health)${C_RESET}\n"
for disk in /dev/nvme[0-9]*; do
# Match only controller devices (nvme0, nvme1), not namespaces (nvme0n1)
[[ "$disk" =~ ^/dev/nvme[0-9]+$ ]] || continue
@@ -209,6 +213,7 @@ done
# ─── ZFS Pool Health ─────────────────────────────────────────────
STATUS+="\n${C_BOLD}ZFS Pools:${C_RESET}\n"
STATUS+="${C_DIM}$(printf ' %-12s %7s %7s %7s %5s %s' Pool Size Alloc Free Cap State)${C_RESET}\n"
while IFS= read -r pool; do
[ -n "$pool" ] || continue
state=$(zpool list -H -o health "$pool" 2>/dev/null) || true
@@ -258,6 +263,7 @@ done < <(zpool list -H -o name 2>/dev/null || true)
# hit the wall. Lists every dataset with a quota set (with -p, an unset
# quota reads as 0).
STATUS+="\n${C_BOLD}Quotas:${C_RESET}\n"
STATUS+="${C_DIM}$(printf ' %-18s %4s %7s %7s' Dataset 'Use%' Used Quota)${C_RESET}\n"
HTML_QUOTA=""
while IFS=$'\t' read -r ds used quota; do
[ -n "$ds" ] || continue
@@ -265,7 +271,7 @@ while IFS=$'\t' read -r ds used quota; do
pct=$(( used * 100 / quota ))
used_h=$(numfmt --to=iec "$used" 2>/dev/null || echo "$used")
quota_h=$(numfmt --to=iec "$quota" 2>/dev/null || echo "$quota")
STATUS+=$(printf ' %-18s ' "$ds")$(usage_txt "$pct" "$(printf '%4s' "${pct}%")")" (${used_h}/${quota_h})\n"
STATUS+=$(printf ' %-18s ' "$ds")$(usage_txt "$pct" "$(printf '%4s' "${pct}%")")$(printf ' %7s %7s' "$used_h" "$quota_h")"\n"
weight=""
if [ "$pct" -gt "$QUOTA_THRESHOLD" ]; then
PROBLEMS+="[QUOTA] $ds is at ${pct}% of its ${quota_h} quota\n"
@@ -276,6 +282,7 @@ done < <(zfs list -Hp -o name,used,quota -t filesystem 2>/dev/null || true)
# ─── Disk Space ──────────────────────────────────────────────────
STATUS+="\n${C_BOLD}Disk Space:${C_RESET}\n"
STATUS+="${C_DIM}$(printf ' %-12s %4s %7s %7s %7s' Mount 'Use%' Used Size Avail)${C_RESET}\n"
while IFS= read -r line; do
[ -n "$line" ] || continue
usage=$(echo "$line" | awk '{print $5}' | tr -d '%')
@@ -283,7 +290,7 @@ while IFS= read -r line; do
size=$(echo "$line" | awk '{print $2}')
used=$(echo "$line" | awk '{print $3}')
avail=$(echo "$line" | awk '{print $4}')
STATUS+=$(printf ' %-12s ' "$mount")$(usage_txt "$usage" "$(printf '%4s' "${usage}%")")" (${used}/${size}, ${avail} free)\n"
STATUS+=$(printf ' %-12s ' "$mount")$(usage_txt "$usage" "$(printf '%4s' "${usage}%")")$(printf ' %7s %7s %7s' "$used" "$size" "$avail")"\n"
weight=""
if [ "$usage" -gt "$SPACE_THRESHOLD" ] 2>/dev/null; then
PROBLEMS+="[SPACE] $mount is ${usage}% full\n"