add header
This commit is contained in:
@@ -89,9 +89,11 @@ COLOR=false
|
|||||||
C_BOLD=""
|
C_BOLD=""
|
||||||
C_RED=""
|
C_RED=""
|
||||||
C_RESET=""
|
C_RESET=""
|
||||||
|
C_DIM=""
|
||||||
if [ -t 1 ]; then
|
if [ -t 1 ]; then
|
||||||
COLOR=true
|
COLOR=true
|
||||||
C_BOLD=$'\e[1m'
|
C_BOLD=$'\e[1m'
|
||||||
|
C_DIM=$'\e[2m'
|
||||||
C_RED=$'\e[1;38;2;207;34;46m'
|
C_RED=$'\e[1;38;2;207;34;46m'
|
||||||
C_RESET=$'\e[0m'
|
C_RESET=$'\e[0m'
|
||||||
fi
|
fi
|
||||||
@@ -127,6 +129,7 @@ usage_txt() {
|
|||||||
|
|
||||||
# ─── SMART Disk Health (SATA/SAS) ───────────────────────────────
|
# ─── SMART Disk Health (SATA/SAS) ───────────────────────────────
|
||||||
STATUS+="${C_BOLD}SMART (SATA):${C_RESET}\n"
|
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
|
for disk in /dev/sd?; do
|
||||||
[ -b "$disk" ] || continue
|
[ -b "$disk" ] || continue
|
||||||
|
|
||||||
@@ -173,6 +176,7 @@ done
|
|||||||
|
|
||||||
# ─── SMART Disk Health (NVMe) ───────────────────────────────────
|
# ─── SMART Disk Health (NVMe) ───────────────────────────────────
|
||||||
STATUS+="\n${C_BOLD}SMART (NVMe):${C_RESET}\n"
|
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
|
for disk in /dev/nvme[0-9]*; do
|
||||||
# Match only controller devices (nvme0, nvme1), not namespaces (nvme0n1)
|
# Match only controller devices (nvme0, nvme1), not namespaces (nvme0n1)
|
||||||
[[ "$disk" =~ ^/dev/nvme[0-9]+$ ]] || continue
|
[[ "$disk" =~ ^/dev/nvme[0-9]+$ ]] || continue
|
||||||
@@ -209,6 +213,7 @@ done
|
|||||||
|
|
||||||
# ─── ZFS Pool Health ─────────────────────────────────────────────
|
# ─── ZFS Pool Health ─────────────────────────────────────────────
|
||||||
STATUS+="\n${C_BOLD}ZFS Pools:${C_RESET}\n"
|
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
|
while IFS= read -r pool; do
|
||||||
[ -n "$pool" ] || continue
|
[ -n "$pool" ] || continue
|
||||||
state=$(zpool list -H -o health "$pool" 2>/dev/null) || true
|
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
|
# hit the wall. Lists every dataset with a quota set (with -p, an unset
|
||||||
# quota reads as 0).
|
# quota reads as 0).
|
||||||
STATUS+="\n${C_BOLD}Quotas:${C_RESET}\n"
|
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=""
|
HTML_QUOTA=""
|
||||||
while IFS=$'\t' read -r ds used quota; do
|
while IFS=$'\t' read -r ds used quota; do
|
||||||
[ -n "$ds" ] || continue
|
[ -n "$ds" ] || continue
|
||||||
@@ -265,7 +271,7 @@ while IFS=$'\t' read -r ds used quota; do
|
|||||||
pct=$(( used * 100 / quota ))
|
pct=$(( used * 100 / quota ))
|
||||||
used_h=$(numfmt --to=iec "$used" 2>/dev/null || echo "$used")
|
used_h=$(numfmt --to=iec "$used" 2>/dev/null || echo "$used")
|
||||||
quota_h=$(numfmt --to=iec "$quota" 2>/dev/null || echo "$quota")
|
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=""
|
weight=""
|
||||||
if [ "$pct" -gt "$QUOTA_THRESHOLD" ]; then
|
if [ "$pct" -gt "$QUOTA_THRESHOLD" ]; then
|
||||||
PROBLEMS+="[QUOTA] $ds is at ${pct}% of its ${quota_h} quota\n"
|
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 ──────────────────────────────────────────────────
|
# ─── Disk Space ──────────────────────────────────────────────────
|
||||||
STATUS+="\n${C_BOLD}Disk Space:${C_RESET}\n"
|
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
|
while IFS= read -r line; do
|
||||||
[ -n "$line" ] || continue
|
[ -n "$line" ] || continue
|
||||||
usage=$(echo "$line" | awk '{print $5}' | tr -d '%')
|
usage=$(echo "$line" | awk '{print $5}' | tr -d '%')
|
||||||
@@ -283,7 +290,7 @@ while IFS= read -r line; do
|
|||||||
size=$(echo "$line" | awk '{print $2}')
|
size=$(echo "$line" | awk '{print $2}')
|
||||||
used=$(echo "$line" | awk '{print $3}')
|
used=$(echo "$line" | awk '{print $3}')
|
||||||
avail=$(echo "$line" | awk '{print $4}')
|
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=""
|
weight=""
|
||||||
if [ "$usage" -gt "$SPACE_THRESHOLD" ] 2>/dev/null; then
|
if [ "$usage" -gt "$SPACE_THRESHOLD" ] 2>/dev/null; then
|
||||||
PROBLEMS+="[SPACE] $mount is ${usage}% full\n"
|
PROBLEMS+="[SPACE] $mount is ${usage}% full\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user