Agents inactifs: KPI cliquable avec *, légende RHEL5/EOL, liste détaillée

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Khalid MOUTAOUAKIL 2026-04-07 00:33:54 +02:00
parent 29a377887f
commit 067dec6bcd
2 changed files with 43 additions and 2 deletions

View File

@ -463,10 +463,19 @@ async def qualys_agents_page(request: Request, db=Depends(get_db)):
ORDER BY s.hostname
""")).fetchall()
# Agents inactifs
inactive = db.execute(text("""
SELECT qa.hostname, qa.os, qa.agent_version, qa.last_checkin, s.etat
FROM qualys_assets qa
LEFT JOIN servers s ON qa.server_id = s.id
WHERE qa.agent_status ILIKE '%inactive%'
ORDER BY qa.hostname
""")).fetchall()
ctx = base_context(request, db, user)
ctx.update({
"app_name": APP_NAME, "keys": keys, "summary": summary,
"no_agent_servers": no_agent,
"no_agent_servers": no_agent, "inactive_agents": inactive,
})
return templates.TemplateResponse("qualys_agents.html", ctx)

View File

@ -13,7 +13,7 @@
<div style="display:flex;flex-wrap:nowrap;gap:8px;margin-bottom:16px;">
<div class="card p-3 text-center" style="flex:1;min-width:0"><div class="text-2xl font-bold text-cyber-accent">{{ summary.total_assets or 0 }}</div><div class="text-xs text-gray-500">Total assets</div></div>
<div class="card p-3 text-center" style="flex:1;min-width:0"><div class="text-2xl font-bold text-cyber-green">{{ summary.active or 0 }}</div><div class="text-xs text-gray-500">Agents actifs</div></div>
<div class="card p-3 text-center" style="flex:1;min-width:0"><div class="text-2xl font-bold text-cyber-red">{{ summary.inactive or 0 }}</div><div class="text-xs text-gray-500">Agents inactifs</div></div>
<a href="#inactive-list" class="card p-3 text-center hover:bg-cyber-hover" style="flex:1;min-width:0"><div class="text-2xl font-bold text-cyber-red">{{ summary.inactive or 0 }}*</div><div class="text-xs text-gray-500">Agents inactifs</div></a>
<div class="card p-3 text-center" style="flex:1;min-width:0"><div class="text-2xl font-bold text-cyber-red">{{ no_agent_servers|length }}</div><div class="text-xs text-gray-500">Sans agent (prod)</div></div>
</div>
@ -109,4 +109,36 @@
</table>
</div>
{% endif %}
<!-- Agents inactifs -->
{% if inactive_agents %}
<div id="inactive-list" class="card p-4 mb-4">
<h3 class="text-sm font-bold text-cyber-red mb-3">* Agents inactifs ({{ inactive_agents|length }})</h3>
<div class="card p-3 mb-3 text-xs text-gray-400" style="background:#111827;">
<b>* Légende :</b> Ces serveurs ont un agent Qualys installé mais qui ne communique plus avec le cloud Qualys.
Causes possibles : serveur éteint, flux réseau bloqué (port 443 vers qualysagent.qualys.eu), agent crashé, ou OS non supporté (RHEL 5 EOL).
Tous ces agents sont en version <b>6.1.0.28</b> sur <b>RHEL 5.x</b> — dernier check-in le <b>14/11/2025</b>.
</div>
<table class="w-full table-cyber text-xs">
<thead><tr>
<th class="text-left p-2">Hostname</th>
<th class="p-2">OS</th>
<th class="p-2">Version agent</th>
<th class="p-2">Dernier check-in</th>
<th class="p-2">État</th>
</tr></thead>
<tbody>
{% for a in inactive_agents %}
<tr>
<td class="p-2 font-mono text-cyber-accent">{{ a.hostname }}</td>
<td class="p-2 text-center text-gray-400">{{ a.os or '-' }}</td>
<td class="p-2 text-center font-mono">{{ a.agent_version or '-' }}</td>
<td class="p-2 text-center text-cyber-yellow">{{ a.last_checkin[:10] if a.last_checkin else '-' }}</td>
<td class="p-2 text-center">{{ a.etat or '-' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% endblock %}