This commit is contained in:
Mark Gregory
2026-10-23 07:43:20 +01:00
parent 0a6f6ac058
commit 97a423533c
2 changed files with 154 additions and 4 deletions
+7 -4
View File
@@ -31,13 +31,16 @@ def check(section, name, status, detail):
checks.append(dict(section=section, name=name, status=status, detail=str(detail)[:500]))
host = socket.gethostname()
# CPU load is informational only.
# Do not generate health warnings without identifying
# the process responsible for excessive CPU usage.
try:
load = os.getloadavg()
cpus = os.cpu_count() or 1
check('System', 'CPU load', 'warn' if load[0] > cpus * 1.5 else 'ok',
f'1m load {load[0]:.2f}; {cpus} CPUs')
except OSError as exc:
check('System', 'CPU load', 'warn', str(exc))
check('System', 'CPU load', 'ok',
f'1m load {load[0]:.2f}; {cpus} CPUs (informational)')
except OSError:
pass
try:
with open('/proc/meminfo', encoding='utf-8') as f: