From 2ad0bfab3942b41356d1ef6ee3663f27c22f8314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Tue, 17 Oct 2023 19:24:53 +0200 Subject: [PATCH] Update the CLI interface. - server and auth are now arguments rather than required options. --- README.md | 21 +++++++++++---------- argos/commands.py | 18 ++++++++++++------ argos/schemas/config.py | 1 - 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 0522c5b..f7803bf 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,17 @@ Argos is an HTTP monitoring service. It's meant to be simple to configure and simple to use. +Todo: + +- [ ] Use Postgresql as a database +- [ ] Use background tasks for alerting +- [ ] Add a command to generate new authentication tokens +- [ ] Task for database cleanup (to run periodically) +- [ ] Handles multiple alerting backends (email, sms, gotify) +- [ ] Expose a simple read-only website. +- [ ] 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 + Features : - [x] Uses `.yaml` files for configuration ; @@ -13,16 +24,6 @@ Features : - [x] Handle jobs failures on the clients - [x] Exposes an HTTP API that can be consumed by other systems ; - [x] Checks can be distributed on the network thanks to a job queue ; -- [x] Change the naming and use service/agent. -- [x] Packaging (and `argos agent` / `argos service` commands) -- [x] Endpoints are protected by an authentication token -- [x] Task frequency can be defined in the configuration -- [ ] Add a command to generate new authentication tokens -- [ ] Local task for database cleanup (to run periodically) -- [ ] Handles multiple alerting backends (email, sms, gotify) ; -- [ ] Exposes a simple read-only website. -- [ ] Add a way to specify the severity of the alerts in the config -- [ ] No need to return the expected and got values in case it worked in check-status and body-contains Implemented checks : diff --git a/argos/commands.py b/argos/commands.py index b998b8b..eabb079 100644 --- a/argos/commands.py +++ b/argos/commands.py @@ -5,7 +5,6 @@ import click from argos import logging from argos.agent import run_agent -from argos.logging import logger @click.group() @@ -14,13 +13,17 @@ def cli(): @cli.command() -@click.option("--server", required=True, help="Server URL") -@click.option("--auth", required=True, help="The authentication token") -@click.option("--max-tasks", default=10, help="Maximum number of concurrent tasks") +@click.argument("server") +@click.argument("auth") +@click.option( + "--max-tasks", + default=10, + help="Number of concurrent tasks this agent can run", +) @click.option( "--wait-time", default=10, - help="Wait time (in seconds) between two polls on the server", + help="Waiting time between two polls on the server (seconds)", ) @click.option( "--log-level", @@ -28,7 +31,10 @@ def cli(): type=click.Choice(logging.LOG_LEVELS, case_sensitive=False), ) def agent(server, auth, max_tasks, wait_time, log_level): - """Runs an agent""" + """Get and run tasks to the provided server. Will wait for new tasks. + + Usage: argos agent https://argos.server "auth-token-here" + """ logging.set_log_level(log_level) asyncio.run(run_agent(server, auth, max_tasks, wait_time)) diff --git a/argos/schemas/config.py b/argos/schemas/config.py index 2feed4b..5727d57 100644 --- a/argos/schemas/config.py +++ b/argos/schemas/config.py @@ -9,7 +9,6 @@ from argos.schemas.utils import string_to_duration # This file contains the pydantic schemas. # For the database models, check in argos.server.models. - Severity = Literal["warning", "error", "critical"]