patchcenter/scripts/snapshot_runner.py

15 lines
530 B
Python
Executable File

#!/usr/bin/env python3
"""Lance un snapshot dashboard vuln. Appele par systemd timer (1x/jour)."""
import sys, os
sys.path.insert(0, "/opt/patchcenter")
from app.database import SessionLocal
from app.services.qualys_service import compute_vuln_dashboard
s = SessionLocal()
try:
res = compute_vuln_dashboard(s, triggered_by="cron")
print(f"[snapshot] ok={res['ok']} run_id={res['run_id']} assets={res['asset_count']} dur={res['duration_sec']}s msg={res['msg']}")
sys.exit(0 if res["ok"] else 1)
finally:
s.close()