mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
💄 — Quick supervision overview on homepage
This commit is contained in:
parent
2383326af8
commit
d2a12aea30
5 changed files with 92 additions and 32 deletions
|
@ -19,7 +19,7 @@ Internally, a HTTP API is exposed, and a job queue is used to distribute the che
|
||||||
## Todo:
|
## Todo:
|
||||||
|
|
||||||
- [ ] Do not return empty list on / when no results from agents.
|
- [ ] Do not return empty list on / when no results from agents.
|
||||||
- [ ] donner un aperçu rapide de l’état de la supervision.
|
- [X] donner un aperçu rapide de l’état de la supervision.
|
||||||
- [ ] Allow passing a dict to check
|
- [ ] Allow passing a dict to check
|
||||||
- [ ] Rename error in unexpected error
|
- [ ] Rename error in unexpected error
|
||||||
- [ ] Use background tasks for alerting
|
- [ ] Use background tasks for alerting
|
||||||
|
|
|
@ -7,6 +7,7 @@ from sqlalchemy import desc
|
||||||
from sqlalchemy.orm import Session, aliased
|
from sqlalchemy.orm import Session, aliased
|
||||||
|
|
||||||
from argos.schemas import Config
|
from argos.schemas import Config
|
||||||
|
from argos.server import queries
|
||||||
from argos.server.models import Result, Task
|
from argos.server.models import Result, Task
|
||||||
from argos.server.routes.dependencies import get_config, get_db
|
from argos.server.routes.dependencies import get_config, get_db
|
||||||
|
|
||||||
|
@ -16,6 +17,25 @@ templates = Jinja2Templates(directory="argos/server/templates")
|
||||||
|
|
||||||
|
|
||||||
@route.get("/")
|
@route.get("/")
|
||||||
|
async def get_severity_counts(request: Request, db: Session = Depends(get_db)):
|
||||||
|
"""Returns the number of results per severity"""
|
||||||
|
counts = await queries.get_severity_counts(db)
|
||||||
|
counts_dict = dict(counts)
|
||||||
|
for key in ("ok", "warning", "critical"):
|
||||||
|
counts_dict.setdefault(key, 0)
|
||||||
|
|
||||||
|
agents = db.query(Result.agent_id).distinct().all()
|
||||||
|
|
||||||
|
return templates.TemplateResponse(
|
||||||
|
"index.html",
|
||||||
|
{
|
||||||
|
"request": request,
|
||||||
|
"counts_dict": counts_dict,
|
||||||
|
"agents": agents,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
@route.get("/details")
|
||||||
async def read_tasks(request: Request, db: Session = Depends(get_db)):
|
async def read_tasks(request: Request, db: Session = Depends(get_db)):
|
||||||
tasks = db.query(Task).order_by(Task.domain).all()
|
tasks = db.query(Task).order_by(Task.domain).all()
|
||||||
|
|
||||||
|
@ -46,7 +66,7 @@ async def read_tasks(request: Request, db: Session = Depends(get_db)):
|
||||||
agents = db.query(Result.agent_id).distinct().all()
|
agents = db.query(Result.agent_id).distinct().all()
|
||||||
|
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
"index.html",
|
"details.html",
|
||||||
{
|
{
|
||||||
"request": request,
|
"request": request,
|
||||||
"domains": domains,
|
"domains": domains,
|
||||||
|
|
|
@ -3,3 +3,15 @@
|
||||||
code {
|
code {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.grid-index {
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
.text-center,
|
||||||
|
.grid-index {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.grid-index article {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
|
|
35
argos/server/templates/details.html
Normal file
35
argos/server/templates/details.html
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<div id="domains" class="frame">
|
||||||
|
<p>
|
||||||
|
{{domains | length}} domains,
|
||||||
|
{{ total_task_count }} tasks,
|
||||||
|
<a href="/agents">{{ agents |length }} agent{% if agents|length > 1 %}s{% endif %}</a>
|
||||||
|
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table id="domains-list" role="grid">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Domain</th>
|
||||||
|
<th class="today">Current status</th>
|
||||||
|
<th>Last check</th>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody id="domains-body">
|
||||||
|
{% for (domain, status) in domains %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="/domain/{{domain}}">
|
||||||
|
{{ domain }} </a>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="status highlight">{% if status == "ok" %}✅ OK {% elif statuts == "warning"%}⚠ Warning{% elif status == "critical"%}❌ Critical{% elif status == "to-process" %}⏱︎ Waiting for the jobs{% endif %}</td>
|
||||||
|
<td>{{ last_checks.get(domain) }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -2,34 +2,27 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="domains" class="frame">
|
<div id="domains" class="frame">
|
||||||
<p>
|
<p>
|
||||||
{{domains | length}} domains,
|
|
||||||
{{ total_task_count }} tasks,
|
|
||||||
<a href="/agents">{{ agents | length }} agent{% if agents| length > 1 %}s{% endif %}</a>
|
<a href="/agents">{{ agents | length }} agent{% if agents| length > 1 %}s{% endif %}</a>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table id="domains-list" role="grid">
|
<div class="container">
|
||||||
<thead>
|
<div class="grid grid-index">
|
||||||
<tr>
|
<article>
|
||||||
<th>Domain</th>
|
<header>✅ OK </header>
|
||||||
<th class="today">Current status</th>
|
{{ counts_dict['ok'] }}
|
||||||
<th>Last check</th>
|
</article>
|
||||||
</thead>
|
<article>
|
||||||
|
<header> ⚠️ Warning</header>
|
||||||
<tbody id="domains-body">
|
{{ counts_dict['warning'] }}
|
||||||
{% for (domain, status) in domains %}
|
</article>
|
||||||
<tr>
|
<article>
|
||||||
<td>
|
<header>❌ Critical</header>
|
||||||
<a href="/domain/{{domain}}">
|
{{ counts_dict['critical'] }}
|
||||||
{{ domain }} </a>
|
</article>
|
||||||
</td>
|
</div>
|
||||||
|
<p class="text-center">
|
||||||
<td class="status highlight">{% if status == "ok" %}✅ OK {% elif statuts == "warning"%}⚠ Warning{% elif status == "critical"%}❌ Critical{% elif status == "to-process" %}⏱︎ Waiting for the jobs{% endif %}</td>
|
<a href="/details" role="button">Details</a>
|
||||||
<td>{{ last_checks.get(domain) }}</td>
|
</p>
|
||||||
</tr>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in a new issue