This commit is contained in:
Mark Gregory
2026-10-22 09:27:17 +01:00
parent ed5bf665b9
commit 0a6f6ac058
22 changed files with 791 additions and 68 deletions
+25 -1
View File
@@ -49,6 +49,25 @@ def output():
match = re.match(r'^\[(OK\s*|WARN|FAIL)\]\s+(.+?)(?:\s+—\s+(.*))?$', line)
if match:
checks.append({'name': match[2].strip(), 'status': match[1].strip().lower(), 'detail': (match[3] or '').strip(), 'section': section})
# Noncritical firmware metadata failures are warnings.
# Other failed systemd units remain critical.
for item in checks:
if item['name'] != 'Failed systemd units':
continue
if item['status'] != 'fail':
continue
failed_units = re.findall(
r'([A-Za-z0-9@_.:-]+\\.service)\\s+loaded\\s+failed\\s+failed',
item['detail']
)
if failed_units and all(
unit == 'fwupd-refresh.service'
for unit in failed_units
):
item['status'] = 'warn'
lookup = {c['name']: c['status'] for c in checks}
groups = []
for title, names in GROUPS:
@@ -62,7 +81,12 @@ def output():
groups.append({'name':label, 'status':state, 'missing':[n for n in relevant if n not in lookup]})
counts_match = re.search(r'SUMMARY:\s*(\d+) OK\s*\|\s*(\d+) WARN\s*\|\s*(\d+) FAIL', plain)
counts = dict(zip(('ok','warn','fail'), (int(x) for x in counts_match.groups()))) if counts_match else {'ok':0,'warn':0,'fail':1}
if not checks:
if checks:
counts = {
state: sum(c['status'] == state for c in checks)
for state in ('ok', 'warn', 'fail')
}
else:
counts['fail'] = max(1, counts['fail'])
overall = 'fail' if counts['fail'] or any(g['status']=='fail' for g in groups) else 'warn' if counts['warn'] or any(g['status']=='warn' for g in groups) else 'ok'
print(json.dumps({'schema':1, 'host':'pegasus', 'uptimeSeconds':system_uptime_seconds(), 'generatedAt':datetime.datetime.now(datetime.timezone.utc).isoformat(), 'overall':overall, 'counts':counts,'groups':groups,'checks':checks, 'diagnostics':plain[-24000:], 'commandExitCode':p.returncode}, ensure_ascii=False))