Files
server-config/scripts/server-status.sh
T
Floweynt 76fa38e34c
flake-check / flake-check (push) Canceled after 0s
lint / lint (push) Canceled after 0s
diff-tag / dix (push) Canceled after 0s
initial commit
2026-08-31 08:41:45 -05:00

22 lines
864 B
Bash

state=$(systemctl is-system-running 2>/dev/null || true)
uptime_str() {
awk '{s=int($1);d=int(s/86400);h=int((s%86400)/3600);m=int((s%3600)/60);
if(d>0)printf "%d days %d hours",d,h;
else if(h>0)printf "%d hours %d min",h,m;
else printf "%d min",m}' /proc/uptime
}
printf 'HOST: %s UP: %s STATE: %s\n' "$(hostname)" "$(uptime_str)" "$state"
printf '%0.s-' {1..60}; printf '\n'
systemctl list-units --all --type=service \
--state=active,failed --no-legend --no-pager --plain 2>/dev/null \
| awk '
NF >= 4 {
unit=$1; active=$3; sub=$4
if (unit ~ /^(getty@|console-getty\.service)/) next
if (unit ~ /^systemd-(tmpfiles|binfmt|modules-load|sysctl|ask-password|remount|random-seed|update-done|hibernate|sleep|suspend|reboot|poweroff)/) next
state = (active == "failed") ? "FAILED" : sub
printf " %-50s %s\n", unit, state
}
'