Updates while reading the code with Luc.

This commit is contained in:
Alexis Métaireau 2023-10-19 18:10:41 +02:00
parent a9f823fbfa
commit 85735add01
9 changed files with 19 additions and 14 deletions

View file

@ -4,12 +4,20 @@ Argos is an HTTP monitoring service. It allows you to define a list of websites
Todo:
- [ ] Retrying: attempt 1413 ended with: <Future at 0x104f39390 state=finished raised RuntimeError> Cannot reopen a client instance, once it has been closed.
- [ ] Cleandb should keep max number of results by task
- [ ] Do not return empty list on / when no results from agents.
- [ ] Last seen agents
- [ ] donner un aperçu rapide de létat de la supervision.
- [ ] Rename error in unexpected error
- [ ] Use background tasks for alerting
- [ ] Add a command to generate new authentication tokens
- [ ] Delete outdated tasks from config
- [ ] Implement alerting tasks
- [ ] Handles multiple alerting backends (email, sms, gotify)
- [ ] Un flag de configuration permet dajouter automatiquement un job de vérification de redirection 301 de la version HTTP vers HTTPS
- [ ] add an "unknown" severity for check errors
- [ ] Add a way to specify the severity of the alerts in the config
- [ ] Do not send "expected" and "got" values in case check-status and body-contains suceeded
- [ ] Add a command to generate new authentication token
Features :

View file

@ -30,7 +30,7 @@ class Response:
@classmethod
def new(cls, status, **kwargs):
if type(status) == bool:
if isinstance(status, bool):
status = Status.SUCCESS if status else Status.FAILURE
return cls(status=status, context=kwargs)

View file

@ -46,7 +46,7 @@ class SSLCertificateExpiration(BaseCheck):
async def run(self):
"""Returns the number of days in which the certificate will expire."""
response = await self.http_client.get(self.task.url)
response = await self.http_client.head(self.task.url)
if response.is_error:
raise

View file

@ -5,8 +5,6 @@ import click
from argos import logging
from argos.agent import ArgosAgent
from argos.server import queries
from argos.server.main import connect_to_db, get_application, setup_database
@click.group()
@ -78,6 +76,9 @@ def clean(max_results, max_lock_seconds):
- Removes old results from the database.
- Removes locks from tasks that have been locked for too long.
"""
# The imports are made here otherwise the agent will need server configuration files.
from argos.server import queries
from argos.server.main import connect_to_db, get_application, setup_database
async def clean_old_results():
app = get_application()

View file

@ -6,7 +6,7 @@ from sqlalchemy import (
Enum,
ForeignKey,
)
from sqlalchemy.orm import DeclarativeBase, Mapped, Session, mapped_column, relationship
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
from argos.checks import BaseCheck, get_registered_check
from argos.schemas import WebsiteCheck
@ -83,6 +83,7 @@ class Result(Base):
agent_id: Mapped[str] = mapped_column(nullable=True)
submitted_at: Mapped[datetime] = mapped_column()
# XXX change "on-check" to something better.
status: Mapped[Literal["success", "failure", "error", "on-check"]] = mapped_column(
Enum("success", "failure", "error", "on-check", name="status")
)

View file

@ -12,12 +12,11 @@ from argos.server.routes.dependencies import get_config, get_db, verify_token
route = APIRouter()
# XXX Get the default limit from the config
@route.get("/tasks", response_model=list[Task], dependencies=[Depends(verify_token)])
async def read_tasks(
request: Request,
db: Session = Depends(get_db),
limit: int = 20,
limit: int = 10,
agent_id: str = None,
):
agent_id = agent_id or request.client.host

View file

@ -1 +0,0 @@
<symbol viewBox="0 0 14 14" id="status_failed" xmlns="http://www.w3.org/2000/svg"><g fill-rule="evenodd"><path d="M0 7a7 7 0 1 1 14 0A7 7 0 0 1 0 7z"></path><path d="M13 7A6 6 0 1 0 1 7a6 6 0 0 0 12 0z" fill="var(--svg-status-bg, #fff)"></path><path d="M7 5.969L5.599 4.568a.29.29 0 0 0-.413.004l-.614.614a.294.294 0 0 0-.004.413L5.968 7l-1.4 1.401a.29.29 0 0 0 .004.413l.614.614c.113.114.3.117.413.004L7 8.032l1.401 1.4a.29.29 0 0 0 .413-.004l.614-.614a.294.294 0 0 0 .004-.413L8.032 7l1.4-1.401a.29.29 0 0 0-.004-.413l-.614-.614a.294.294 0 0 0-.413-.004L7 5.968z"></path></g></symbol>

View file

@ -1 +0,0 @@
<symbol viewBox="0 0 14 14" id="status_success" xmlns="http://www.w3.org/2000/svg"><g fill-rule="evenodd"><path d="M0 7a7 7 0 1 1 14 0A7 7 0 0 1 0 7z"></path><path d="M13 7A6 6 0 1 0 1 7a6 6 0 0 0 12 0z" fill="var(--svg-status-bg, #fff)"></path><path d="M6.278 7.697L5.045 6.464a.296.296 0 0 0-.42-.002l-.613.614a.298.298 0 0 0 .002.42l1.91 1.909a.5.5 0 0 0 .703.005l.265-.265L9.997 6.04a.291.291 0 0 0-.009-.408l-.614-.614a.29.29 0 0 0-.408-.009L6.278 7.697z"></path></g></symbol>

View file

@ -2,6 +2,4 @@
code {
white-space: pre-wrap;
}