70 lines
1.5 KiB
Bash
70 lines
1.5 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
set -o errexit
|
||
|
|
set -o nounset
|
||
|
|
set -o pipefail
|
||
|
|
|
||
|
|
section() {
|
||
|
|
printf '\n== %s ==\n' "$1"
|
||
|
|
}
|
||
|
|
|
||
|
|
run_optional() {
|
||
|
|
local description="$1"
|
||
|
|
shift
|
||
|
|
|
||
|
|
if "$@"; then
|
||
|
|
return 0
|
||
|
|
fi
|
||
|
|
printf 'WARNING: %s failed\n' "$description"
|
||
|
|
return 0
|
||
|
|
}
|
||
|
|
|
||
|
|
section "Failed systemd units"
|
||
|
|
if command -v systemctl >/dev/null 2>&1; then
|
||
|
|
run_optional "failed systemd unit report" systemctl --failed --no-pager
|
||
|
|
|
||
|
|
section "Selected service status"
|
||
|
|
for unit in cockpit.socket docker.service libvirtd.service fail2ban.service; do
|
||
|
|
if systemctl cat "$unit" >/dev/null 2>&1; then
|
||
|
|
run_optional "$unit status" systemctl status "$unit" --no-pager
|
||
|
|
else
|
||
|
|
printf 'INFO: %s is not installed\n' "$unit"
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
else
|
||
|
|
printf 'WARNING: systemctl is unavailable\n'
|
||
|
|
fi
|
||
|
|
|
||
|
|
section "Docker"
|
||
|
|
if command -v docker >/dev/null 2>&1; then
|
||
|
|
run_optional "Docker container list" docker ps
|
||
|
|
else
|
||
|
|
printf 'INFO: Docker is not installed\n'
|
||
|
|
fi
|
||
|
|
|
||
|
|
section "Libvirt"
|
||
|
|
if command -v virsh >/dev/null 2>&1; then
|
||
|
|
run_optional "libvirt guest list" virsh list --all
|
||
|
|
else
|
||
|
|
printf 'INFO: virsh is not installed\n'
|
||
|
|
fi
|
||
|
|
|
||
|
|
section "NVIDIA"
|
||
|
|
if command -v nvidia-smi >/dev/null 2>&1; then
|
||
|
|
run_optional "NVIDIA status" nvidia-smi
|
||
|
|
else
|
||
|
|
printf 'INFO: nvidia-smi is not installed\n'
|
||
|
|
fi
|
||
|
|
|
||
|
|
section "Filesystems"
|
||
|
|
run_optional "filesystem report" df -hT
|
||
|
|
|
||
|
|
section "Listening ports"
|
||
|
|
if command -v ss >/dev/null 2>&1; then
|
||
|
|
run_optional "listening port report" ss -tulpn
|
||
|
|
else
|
||
|
|
printf 'WARNING: ss is unavailable\n'
|
||
|
|
fi
|
||
|
|
|
||
|
|
printf '\nOK: postcheck completed; review warnings above\n'
|
||
|
|
exit 0
|