Update docs for os-healthcheck toolkit layout
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
section() {
|
||||
printf '\n== %s ==\n' "$1"
|
||||
}
|
||||
|
||||
run_or_warn() {
|
||||
local description="$1"
|
||||
shift
|
||||
|
||||
if command -v "$1" >/dev/null 2>&1; then
|
||||
"$@" || printf 'WARNING: %s command failed\n' "$description"
|
||||
else
|
||||
printf 'WARNING: %s command not available\n' "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
top_processes() {
|
||||
local sort_key="$1"
|
||||
|
||||
if command -v ps >/dev/null 2>&1; then
|
||||
ps -eo pid,ppid,comm,%cpu,%mem --sort="$sort_key" | head -n 11
|
||||
else
|
||||
printf 'WARNING: ps command not available\n'
|
||||
fi
|
||||
}
|
||||
|
||||
section "Host"
|
||||
hostname
|
||||
uptime
|
||||
|
||||
section "OS"
|
||||
if [[ -r /etc/os-release ]]; then
|
||||
. /etc/os-release
|
||||
printf '%s\n' "${PRETTY_NAME:-Unknown Linux}"
|
||||
else
|
||||
printf 'WARNING: /etc/os-release not readable\n'
|
||||
fi
|
||||
uname -r
|
||||
|
||||
section "CPU Load"
|
||||
if [[ -r /proc/loadavg ]]; then
|
||||
awk '{print "1m="$1, "5m="$2, "15m="$3}' /proc/loadavg
|
||||
else
|
||||
uptime
|
||||
fi
|
||||
|
||||
section "Memory"
|
||||
run_or_warn "memory usage" free -h
|
||||
|
||||
section "Disk"
|
||||
run_or_warn "disk usage" df -h -x tmpfs -x devtmpfs
|
||||
|
||||
section "Failed systemd Services"
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl --failed --no-pager || true
|
||||
else
|
||||
printf 'WARNING: systemctl command not available\n'
|
||||
fi
|
||||
|
||||
section "Top CPU Processes"
|
||||
top_processes "-%cpu"
|
||||
|
||||
section "Top Memory Processes"
|
||||
top_processes "-%mem"
|
||||
Reference in New Issue
Block a user