patchcenter/app/scripts/refresh_agents.py
Admin MPCZ 4fa5f67c32 Qualys agents: bouton Rafraichir + cron 6h
- refresh_all_agents(): bulk sync tous les assets depuis API Qualys QPS
- Bouton "Rafraîchir depuis Qualys" sur la page agents
- Cron toutes les 6h: refresh_agents.py (prod + demo)
- Message de confirmation après refresh
2026-04-11 21:56:59 +02:00

17 lines
531 B
Python

#!/usr/bin/env python3
"""Cron script: refresh Qualys agents data every 6h"""
import sys
sys.path.insert(0, "/opt/patchcenter")
from app.database import SessionLocal, SessionLocalDemo
from app.services.qualys_service import refresh_all_agents
for factory, name in [(SessionLocal, "prod"), (SessionLocalDemo, "demo")]:
try:
db = factory()
result = refresh_all_agents(db)
print(f"[{name}] {result.get('msg', result)}")
db.close()
except Exception as e:
print(f"[{name}] ERROR: {e}")