updates
This commit is contained in:
@@ -5,6 +5,15 @@ No third-party Python packages required.
|
||||
"""
|
||||
import datetime
|
||||
import json
|
||||
|
||||
def system_uptime_seconds():
|
||||
"""Read Linux kernel uptime without privilege or external commands."""
|
||||
try:
|
||||
with open('/proc/uptime', encoding='ascii') as handle:
|
||||
return max(0, int(float(handle.read().split()[0])))
|
||||
except (OSError, ValueError, IndexError):
|
||||
return None
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import socket
|
||||
@@ -115,4 +124,5 @@ for section in dict.fromkeys(c['section'] for c in checks):
|
||||
counts = {s: sum(c['status'] == s for c in checks) for s in ('ok', 'warn', 'fail')}
|
||||
overall = 'fail' if counts['fail'] else 'warn' if counts['warn'] else 'ok'
|
||||
print(json.dumps(dict(schema=1, host=host, generatedAt=datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
||||
overall=overall, counts=counts, groups=groups, checks=checks, diagnostics=None, services=services)))
|
||||
overall=overall, counts=counts, groups=groups, checks=checks, diagnostics=None, services=services,
|
||||
uptimeSeconds=system_uptime_seconds())))
|
||||
|
||||
Reference in New Issue
Block a user