From 4880c6568156989e53bd0de217e74cf758b1bc32 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Thu, 27 Jun 2024 10:04:00 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=F0=9F=92=A5=20=E2=80=94=20Rename=20ar?= =?UTF-8?q?gos=20to=20argos-monitoring=20to=20fit=20the=20package=20name?= =?UTF-8?q?=20(fix=20#53)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Uninstall argos with `pip uninstall argos-monitoring` before installing this release! --- CHANGELOG.md | 4 +- Makefile | 4 +- argos/server/__init__.py | 1 - {argos => argos_monitoring}/__init__.py | 0 {argos => argos_monitoring}/agent.py | 6 +-- .../checks/__init__.py | 4 +- {argos => argos_monitoring}/checks/base.py | 2 +- {argos => argos_monitoring}/checks/checks.py | 2 +- {argos => argos_monitoring}/commands.py | 44 +++++++++-------- .../config-example.yaml | 2 +- {argos => argos_monitoring}/logging.py | 0 .../schemas/__init__.py | 0 {argos => argos_monitoring}/schemas/config.py | 6 +-- {argos => argos_monitoring}/schemas/models.py | 2 +- {argos => argos_monitoring}/schemas/utils.py | 0 argos_monitoring/server/__init__.py | 1 + .../server/alerting.py | 9 ++-- .../server/exceptions.py | 0 {argos => argos_monitoring}/server/main.py | 13 +++-- .../server/migrations/alembic.ini | 0 .../server/migrations/env.py | 2 +- .../server/migrations/script.py.mako | 0 .../1a3497f9f71b_adding_configcache_model.py | 0 .../7d480e6f1112_initial_migrations.py | 0 .../versions/c780864dc407_add_users_table.py | 0 ...dd_on_delete_cascade_to_results_task_id.py | 0 ..._add_severity_to_task_and_add_severity_.py | 0 {argos => argos_monitoring}/server/models.py | 4 +- {argos => argos_monitoring}/server/queries.py | 6 +-- .../server/routes/__init__.py | 0 .../server/routes/api.py | 10 ++-- .../server/routes/dependencies.py | 0 .../server/routes/views.py | 8 +-- .../server/settings.py | 2 +- .../server/static/logo-64.png | Bin .../server/static/logo.png | Bin .../server/static/pico.min.css | 0 .../server/static/styles.css | 0 .../server/templates/agents.html | 0 .../server/templates/base.html | 0 .../server/templates/domain.html | 0 .../server/templates/domains.html | 0 .../server/templates/index.html | 0 .../server/templates/login.html | 0 .../server/templates/result.html | 0 .../server/templates/results.html | 0 conf/config-example.yaml | 2 +- conf/systemd-agent.service | 6 +-- conf/systemd-server.service | 8 +-- docs/cli.md | 46 +++++++++--------- docs/conf.py | 4 +- docs/configuration.md | 2 +- docs/developer/dependencies.md | 1 + docs/developer/migrations.md | 2 +- docs/developer/models.md | 2 +- docs/developer/new-check.md | 4 +- docs/developer/new-notification-way.md | 4 +- docs/developer/release.md | 8 +-- docs/installation/getting-started.md | 29 +++++------ docs/installation/tl-dr.md | 30 ++++++------ pyproject.toml | 10 ++-- tests/conftest.py | 6 +-- tests/test_api.py | 6 +-- tests/test_checks.py | 4 +- tests/test_checks_base.py | 2 +- tests/test_cli.py | 2 +- tests/test_queries.py | 6 +-- tests/test_schemas_config.py | 2 +- tests/test_schemas_utils.py | 2 +- 69 files changed, 164 insertions(+), 156 deletions(-) delete mode 100644 argos/server/__init__.py rename {argos => argos_monitoring}/__init__.py (100%) rename {argos => argos_monitoring}/agent.py (95%) rename {argos => argos_monitoring}/checks/__init__.py (60%) rename {argos => argos_monitoring}/checks/base.py (98%) rename {argos => argos_monitoring}/checks/checks.py (98%) rename {argos => argos_monitoring}/commands.py (93%) rename {argos => argos_monitoring}/config-example.yaml (96%) rename {argos => argos_monitoring}/logging.py (100%) rename {argos => argos_monitoring}/schemas/__init__.py (100%) rename {argos => argos_monitoring}/schemas/config.py (95%) rename {argos => argos_monitoring}/schemas/models.py (95%) rename {argos => argos_monitoring}/schemas/utils.py (100%) create mode 100644 argos_monitoring/server/__init__.py rename {argos => argos_monitoring}/server/alerting.py (92%) rename {argos => argos_monitoring}/server/exceptions.py (100%) rename {argos => argos_monitoring}/server/main.py (91%) rename {argos => argos_monitoring}/server/migrations/alembic.ini (100%) rename {argos => argos_monitoring}/server/migrations/env.py (97%) rename {argos => argos_monitoring}/server/migrations/script.py.mako (100%) rename {argos => argos_monitoring}/server/migrations/versions/1a3497f9f71b_adding_configcache_model.py (100%) rename {argos => argos_monitoring}/server/migrations/versions/7d480e6f1112_initial_migrations.py (100%) rename {argos => argos_monitoring}/server/migrations/versions/c780864dc407_add_users_table.py (100%) rename {argos => argos_monitoring}/server/migrations/versions/defda3f2952d_add_on_delete_cascade_to_results_task_id.py (100%) rename {argos => argos_monitoring}/server/migrations/versions/e99bc35702c9_add_severity_to_task_and_add_severity_.py (100%) rename {argos => argos_monitoring}/server/models.py (97%) rename {argos => argos_monitoring}/server/queries.py (98%) rename {argos => argos_monitoring}/server/routes/__init__.py (100%) rename {argos => argos_monitoring}/server/routes/api.py (92%) rename {argos => argos_monitoring}/server/routes/dependencies.py (100%) rename {argos => argos_monitoring}/server/routes/views.py (97%) rename {argos => argos_monitoring}/server/settings.py (91%) rename {argos => argos_monitoring}/server/static/logo-64.png (100%) rename {argos => argos_monitoring}/server/static/logo.png (100%) rename {argos => argos_monitoring}/server/static/pico.min.css (100%) rename {argos => argos_monitoring}/server/static/styles.css (100%) rename {argos => argos_monitoring}/server/templates/agents.html (100%) rename {argos => argos_monitoring}/server/templates/base.html (100%) rename {argos => argos_monitoring}/server/templates/domain.html (100%) rename {argos => argos_monitoring}/server/templates/domains.html (100%) rename {argos => argos_monitoring}/server/templates/index.html (100%) rename {argos => argos_monitoring}/server/templates/login.html (100%) rename {argos => argos_monitoring}/server/templates/result.html (100%) rename {argos => argos_monitoring}/server/templates/results.html (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2739e65..0c24d5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## [Unreleased] - 🩹 — Fix release documentation +- ♻️💥 — Rename argos to argos-monitoring to fit the package name + Uninstall argos with `pip uninstall argos-monitoring` before installing this release! ## 0.2.2 @@ -22,7 +24,7 @@ Date: 2024-06-24 - 💄📯 — Improve notifications and result(s) pages - 🔊 — Add level of log before the log message -— 🔊 — Add a warning messages in the logs if there is no tasks in database. (fix #41) +- 🔊 — Add a warning messages in the logs if there is no tasks in database. (fix #41) - ✨ — Add command to generate example configuration (fix #38) - 📝 — Improve documentation - ✨ — Add command to warn if it’s been long since last viewing an agent (fix #49) diff --git a/Makefile b/Makefile index 722f7ba..ad9d2db 100644 --- a/Makefile +++ b/Makefile @@ -25,9 +25,9 @@ ruff: venv ruff-format: venv venv/bin/ruff format . djlint: venv ## Format the templates - venv/bin/djlint --ignore=H030,H031,H006 --profile jinja --lint argos/server/templates/*html + venv/bin/djlint --ignore=H030,H031,H006 --profile jinja --lint argos_monitoring/server/templates/*html pylint: venv ## Runs pylint on the code - venv/bin/pylint argos + venv/bin/pylint argos_monitoring lint: djlint pylint ruff help: @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) diff --git a/argos/server/__init__.py b/argos/server/__init__.py deleted file mode 100644 index 64c3804..0000000 --- a/argos/server/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from argos.server.main import app # noqa: F401 diff --git a/argos/__init__.py b/argos_monitoring/__init__.py similarity index 100% rename from argos/__init__.py rename to argos_monitoring/__init__.py diff --git a/argos/agent.py b/argos_monitoring/agent.py similarity index 95% rename from argos/agent.py rename to argos_monitoring/agent.py index 7cc3209..e2dbbd3 100644 --- a/argos/agent.py +++ b/argos_monitoring/agent.py @@ -11,9 +11,9 @@ from typing import List import httpx from tenacity import retry, wait_random # type: ignore -from argos.checks import get_registered_check -from argos.logging import logger -from argos.schemas import AgentResult, SerializableException, Task +from argos_monitoring.checks import get_registered_check +from argos_monitoring.logging import logger +from argos_monitoring.schemas import AgentResult, SerializableException, Task def log_failure(retry_state): diff --git a/argos/checks/__init__.py b/argos_monitoring/checks/__init__.py similarity index 60% rename from argos/checks/__init__.py rename to argos_monitoring/checks/__init__.py index be78950..3ddb161 100644 --- a/argos/checks/__init__.py +++ b/argos_monitoring/checks/__init__.py @@ -1,10 +1,10 @@ -from argos.checks.base import ( # NOQA +from argos_monitoring.checks.base import ( # NOQA BaseCheck, CheckNotFound, get_registered_check, get_registered_checks, ) -from argos.checks.checks import ( # NOQA +from argos_monitoring.checks.checks import ( # NOQA HTTPBodyContains, HTTPStatus, SSLCertificateExpiration, diff --git a/argos/checks/base.py b/argos_monitoring/checks/base.py similarity index 98% rename from argos/checks/base.py rename to argos_monitoring/checks/base.py index 20521b9..c060a7d 100644 --- a/argos/checks/base.py +++ b/argos_monitoring/checks/base.py @@ -6,7 +6,7 @@ from typing import Type, Union import httpx from pydantic import BaseModel -from argos.schemas.models import Task +from argos_monitoring.schemas.models import Task class Status: diff --git a/argos/checks/checks.py b/argos_monitoring/checks/checks.py similarity index 98% rename from argos/checks/checks.py rename to argos_monitoring/checks/checks.py index 42a6848..106dd0e 100644 --- a/argos/checks/checks.py +++ b/argos_monitoring/checks/checks.py @@ -2,7 +2,7 @@ from datetime import datetime -from argos.checks.base import ( +from argos_monitoring.checks.base import ( BaseCheck, ExpectedIntValue, ExpectedStringValue, diff --git a/argos/commands.py b/argos_monitoring/commands.py similarity index 93% rename from argos/commands.py rename to argos_monitoring/commands.py index 0fc1491..f20d8b4 100644 --- a/argos/commands.py +++ b/argos_monitoring/commands.py @@ -10,13 +10,17 @@ import uvicorn from alembic import command from alembic.config import Config -from argos import logging -from argos import VERSION -from argos.agent import ArgosAgent +from argos_monitoring import logging +from argos_monitoring import VERSION +from argos_monitoring.agent import ArgosAgent async def get_db(): - from argos.server.main import connect_to_db, get_application, setup_database + from argos_monitoring.server.main import ( + connect_to_db, + get_application, + setup_database, + ) app = get_application() setup_database(app) @@ -96,7 +100,7 @@ def version(): def agent(server_url, auth, max_tasks, wait_time, log_level): """Get and run tasks for the provided server. Will wait for new tasks. - Usage: argos agent https://argos.example.org "auth-token-here" + Usage: argos-monitoring agent https://argos.example.org "auth-token-here" Alternatively, you can use the following environment variables to avoid passing arguments to the agent on the command line: @@ -106,7 +110,7 @@ def agent(server_url, auth, max_tasks, wait_time, log_level): ARGOS_AGENT_TOKEN=auth-token-here """ click.echo("Starting argos agent. Will retry forever.") - from argos.logging import logger + from argos_monitoring.logging import logger logger.setLevel(log_level) agent_ = ArgosAgent(server_url, auth, max_tasks, wait_time) @@ -133,7 +137,7 @@ def start(host, port, config, reload): for advices on how to start the server for production. """ os.environ["ARGOS_YAML_FILE"] = config - uvicorn.run("argos.server:app", host=host, port=port, reload=reload) + uvicorn.run("argos_monitoring.server:app", host=host, port=port, reload=reload) def validate_max_lock_seconds(ctx, param, value): @@ -186,7 +190,7 @@ async def cleandb(max_results, max_lock_seconds, config): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server import queries + from argos_monitoring.server import queries db = await get_db() removed = await queries.remove_old_results(db, max_results) @@ -222,7 +226,7 @@ async def watch_agents(time_without_agent, config): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server import queries + from argos_monitoring.server import queries db = await get_db() agents = await queries.get_recent_agents_count(db, time_without_agent) @@ -248,8 +252,8 @@ async def reload_config(config): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server import queries - from argos.server.main import read_config + from argos_monitoring.server import queries + from argos_monitoring.server.main import read_config _config = read_config(config) @@ -277,7 +281,7 @@ async def migrate(config): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server.settings import read_yaml_config + from argos_monitoring.server.settings import read_yaml_config settings = read_yaml_config(config) @@ -305,7 +309,7 @@ async def add(config, name, password): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server import queries + from argos_monitoring.server import queries from passlib.context import CryptContext db = await get_db() @@ -339,7 +343,7 @@ async def change_password(config, name, password): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server import queries + from argos_monitoring.server import queries from passlib.context import CryptContext db = await get_db() @@ -374,7 +378,7 @@ async def verify_password(config, name, password): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server import queries + from argos_monitoring.server import queries from passlib.context import CryptContext db = await get_db() @@ -408,7 +412,7 @@ async def disable(config, name): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server import queries + from argos_monitoring.server import queries db = await get_db() _user = await queries.get_user(db, name) @@ -442,7 +446,7 @@ async def enable(config, name): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server import queries + from argos_monitoring.server import queries db = await get_db() _user = await queries.get_user(db, name) @@ -476,7 +480,7 @@ async def delete(config, name): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server import queries + from argos_monitoring.server import queries db = await get_db() _user = await queries.get_user(db, name) @@ -506,7 +510,7 @@ async def show(config): os.environ["ARGOS_YAML_FILE"] = config # The imports are made here otherwise the agent will need server configuration files. - from argos.server import queries + from argos_monitoring.server import queries db = await get_db() users = await queries.list_users(db) @@ -541,7 +545,7 @@ async def generate_config(): \b Redirect the output to a file to save it: - argos server generate-config > /etc/argos/config.yaml + argos-monitoring server generate-config > /etc/argos/config.yaml """ config_example = Path(__file__).resolve().parent / "config-example.yaml" with config_example.open("r", encoding="utf-8") as f: diff --git a/argos/config-example.yaml b/argos_monitoring/config-example.yaml similarity index 96% rename from argos/config-example.yaml rename to argos_monitoring/config-example.yaml index 41f00d6..db31285 100644 --- a/argos/config-example.yaml +++ b/argos_monitoring/config-example.yaml @@ -52,7 +52,7 @@ general: service: secrets: - # Secrets can be generated using `argos server generate-token`. + # Secrets can be generated using `argos-monitoring server generate-token`. # You need at least one. Write them as a list, like: # - secret_token diff --git a/argos/logging.py b/argos_monitoring/logging.py similarity index 100% rename from argos/logging.py rename to argos_monitoring/logging.py diff --git a/argos/schemas/__init__.py b/argos_monitoring/schemas/__init__.py similarity index 100% rename from argos/schemas/__init__.py rename to argos_monitoring/schemas/__init__.py diff --git a/argos/schemas/config.py b/argos_monitoring/schemas/config.py similarity index 95% rename from argos/schemas/config.py rename to argos_monitoring/schemas/config.py index be90f7b..49e21eb 100644 --- a/argos/schemas/config.py +++ b/argos_monitoring/schemas/config.py @@ -1,6 +1,6 @@ """Pydantic schemas for configuration -For database models, see argos.server.models. +For database models, see argos_monitoring.server.models. """ from typing import Dict, List, Literal, Optional, Tuple @@ -19,7 +19,7 @@ from pydantic.networks import UrlConstraints from pydantic_core import Url from typing_extensions import Annotated -from argos.schemas.utils import string_to_duration +from argos_monitoring.schemas.utils import string_to_duration Severity = Literal["warning", "error", "critical", "unknown"] Environment = Literal["dev", "test", "production"] @@ -68,7 +68,7 @@ def parse_checks(value): """Check that checks are valid (i.e. registered) checks""" # To avoid circular imports - from argos.checks import get_registered_checks + from argos_monitoring.checks import get_registered_checks available_names = get_registered_checks().keys() diff --git a/argos/schemas/models.py b/argos_monitoring/schemas/models.py similarity index 95% rename from argos/schemas/models.py rename to argos_monitoring/schemas/models.py index a297acf..35c0292 100644 --- a/argos/schemas/models.py +++ b/argos_monitoring/schemas/models.py @@ -1,6 +1,6 @@ """Pydantic schemas for data -For database models, see argos.server.models. +For database models, see argos_monitoring.server.models. """ import traceback from datetime import datetime diff --git a/argos/schemas/utils.py b/argos_monitoring/schemas/utils.py similarity index 100% rename from argos/schemas/utils.py rename to argos_monitoring/schemas/utils.py diff --git a/argos_monitoring/server/__init__.py b/argos_monitoring/server/__init__.py new file mode 100644 index 0000000..1e80aba --- /dev/null +++ b/argos_monitoring/server/__init__.py @@ -0,0 +1 @@ +from argos_monitoring.server.main import app # noqa: F401 diff --git a/argos/server/alerting.py b/argos_monitoring/server/alerting.py similarity index 92% rename from argos/server/alerting.py rename to argos_monitoring/server/alerting.py index bb833a2..664704c 100644 --- a/argos/server/alerting.py +++ b/argos_monitoring/server/alerting.py @@ -6,12 +6,9 @@ from urllib.parse import urlparse import httpx -from argos.checks.base import Severity -from argos.logging import logger -from argos.schemas.config import Config, Mail, GotifyUrl - -# XXX Implement mail alerts https://framagit.org/framasoft/framaspace/argos/-/issues/15 -# XXX Implement gotify alerts https://framagit.org/framasoft/framaspace/argos/-/issues/16 +from argos_monitoring.checks.base import Severity +from argos_monitoring.logging import logger +from argos_monitoring.schemas.config import Config, Mail, GotifyUrl def handle_alert(config: Config, result, task, severity, old_severity, request): diff --git a/argos/server/exceptions.py b/argos_monitoring/server/exceptions.py similarity index 100% rename from argos/server/exceptions.py rename to argos_monitoring/server/exceptions.py diff --git a/argos/server/main.py b/argos_monitoring/server/main.py similarity index 91% rename from argos/server/main.py rename to argos_monitoring/server/main.py index 898b202..05263fd 100644 --- a/argos/server/main.py +++ b/argos_monitoring/server/main.py @@ -10,10 +10,13 @@ from pydantic import ValidationError from sqlalchemy import create_engine, event from sqlalchemy.orm import sessionmaker -from argos.logging import logger -from argos.server import models, routes, queries -from argos.server.exceptions import NotAuthenticatedException, auth_exception_handler -from argos.server.settings import read_yaml_config +from argos_monitoring.logging import logger +from argos_monitoring.server import models, routes, queries +from argos_monitoring.server.exceptions import ( + NotAuthenticatedException, + auth_exception_handler, +) +from argos_monitoring.server.settings import read_yaml_config def get_application() -> FastAPI: @@ -120,7 +123,7 @@ async def lifespan(appli): if tasks_count == 0: logger.warning( "There is no tasks in the database. " - 'Please launch the command "argos server reload-config"' + 'Please launch the command "argos-monitoring server reload-config"' ) yield diff --git a/argos/server/migrations/alembic.ini b/argos_monitoring/server/migrations/alembic.ini similarity index 100% rename from argos/server/migrations/alembic.ini rename to argos_monitoring/server/migrations/alembic.ini diff --git a/argos/server/migrations/env.py b/argos_monitoring/server/migrations/env.py similarity index 97% rename from argos/server/migrations/env.py rename to argos_monitoring/server/migrations/env.py index 2638877..08a019c 100644 --- a/argos/server/migrations/env.py +++ b/argos_monitoring/server/migrations/env.py @@ -1,7 +1,7 @@ from logging.config import fileConfig from alembic import context -from argos.server.models import Base +from argos_monitoring.server.models import Base from sqlalchemy import engine_from_config, pool config = context.config diff --git a/argos/server/migrations/script.py.mako b/argos_monitoring/server/migrations/script.py.mako similarity index 100% rename from argos/server/migrations/script.py.mako rename to argos_monitoring/server/migrations/script.py.mako diff --git a/argos/server/migrations/versions/1a3497f9f71b_adding_configcache_model.py b/argos_monitoring/server/migrations/versions/1a3497f9f71b_adding_configcache_model.py similarity index 100% rename from argos/server/migrations/versions/1a3497f9f71b_adding_configcache_model.py rename to argos_monitoring/server/migrations/versions/1a3497f9f71b_adding_configcache_model.py diff --git a/argos/server/migrations/versions/7d480e6f1112_initial_migrations.py b/argos_monitoring/server/migrations/versions/7d480e6f1112_initial_migrations.py similarity index 100% rename from argos/server/migrations/versions/7d480e6f1112_initial_migrations.py rename to argos_monitoring/server/migrations/versions/7d480e6f1112_initial_migrations.py diff --git a/argos/server/migrations/versions/c780864dc407_add_users_table.py b/argos_monitoring/server/migrations/versions/c780864dc407_add_users_table.py similarity index 100% rename from argos/server/migrations/versions/c780864dc407_add_users_table.py rename to argos_monitoring/server/migrations/versions/c780864dc407_add_users_table.py diff --git a/argos/server/migrations/versions/defda3f2952d_add_on_delete_cascade_to_results_task_id.py b/argos_monitoring/server/migrations/versions/defda3f2952d_add_on_delete_cascade_to_results_task_id.py similarity index 100% rename from argos/server/migrations/versions/defda3f2952d_add_on_delete_cascade_to_results_task_id.py rename to argos_monitoring/server/migrations/versions/defda3f2952d_add_on_delete_cascade_to_results_task_id.py diff --git a/argos/server/migrations/versions/e99bc35702c9_add_severity_to_task_and_add_severity_.py b/argos_monitoring/server/migrations/versions/e99bc35702c9_add_severity_to_task_and_add_severity_.py similarity index 100% rename from argos/server/migrations/versions/e99bc35702c9_add_severity_to_task_and_add_severity_.py rename to argos_monitoring/server/migrations/versions/e99bc35702c9_add_severity_to_task_and_add_severity_.py diff --git a/argos/server/models.py b/argos_monitoring/server/models.py similarity index 97% rename from argos/server/models.py rename to argos_monitoring/server/models.py index 5a03399..4cb0706 100644 --- a/argos/server/models.py +++ b/argos_monitoring/server/models.py @@ -10,8 +10,8 @@ from sqlalchemy import ( ) from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship -from argos.checks import BaseCheck, get_registered_check -from argos.schemas import WebsiteCheck +from argos_monitoring.checks import BaseCheck, get_registered_check +from argos_monitoring.schemas import WebsiteCheck class Base(DeclarativeBase): diff --git a/argos/server/queries.py b/argos_monitoring/server/queries.py similarity index 98% rename from argos/server/queries.py rename to argos_monitoring/server/queries.py index b0bf979..f4e2605 100644 --- a/argos/server/queries.py +++ b/argos_monitoring/server/queries.py @@ -7,9 +7,9 @@ from urllib.parse import urljoin from sqlalchemy import asc, desc, func from sqlalchemy.orm import Session -from argos import schemas -from argos.logging import logger -from argos.server.models import Result, Task, ConfigCache, User +from argos_monitoring import schemas +from argos_monitoring.logging import logger +from argos_monitoring.server.models import Result, Task, ConfigCache, User async def list_tasks(db: Session, agent_id: str, limit: int = 100): diff --git a/argos/server/routes/__init__.py b/argos_monitoring/server/routes/__init__.py similarity index 100% rename from argos/server/routes/__init__.py rename to argos_monitoring/server/routes/__init__.py diff --git a/argos/server/routes/api.py b/argos_monitoring/server/routes/api.py similarity index 92% rename from argos/server/routes/api.py rename to argos_monitoring/server/routes/api.py index 8e0e177..f7bf55e 100644 --- a/argos/server/routes/api.py +++ b/argos_monitoring/server/routes/api.py @@ -4,11 +4,11 @@ from typing import List, Union from fastapi import APIRouter, BackgroundTasks, Depends, Request from sqlalchemy.orm import Session -from argos.logging import logger -from argos.schemas import AgentResult, Config, Task -from argos.server import queries -from argos.server.alerting import handle_alert -from argos.server.routes.dependencies import get_config, get_db, verify_token +from argos_monitoring.logging import logger +from argos_monitoring.schemas import AgentResult, Config, Task +from argos_monitoring.server import queries +from argos_monitoring.server.alerting import handle_alert +from argos_monitoring.server.routes.dependencies import get_config, get_db, verify_token route = APIRouter() diff --git a/argos/server/routes/dependencies.py b/argos_monitoring/server/routes/dependencies.py similarity index 100% rename from argos/server/routes/dependencies.py rename to argos_monitoring/server/routes/dependencies.py diff --git a/argos/server/routes/views.py b/argos_monitoring/server/routes/views.py similarity index 97% rename from argos/server/routes/views.py rename to argos_monitoring/server/routes/views.py index ef7d4de..3d4c0fa 100644 --- a/argos/server/routes/views.py +++ b/argos_monitoring/server/routes/views.py @@ -14,10 +14,10 @@ from passlib.context import CryptContext from sqlalchemy import func from sqlalchemy.orm import Session -from argos.schemas import Config -from argos.server import queries -from argos.server.models import Result, Task, User -from argos.server.routes.dependencies import get_config, get_db, get_manager +from argos_monitoring.schemas import Config +from argos_monitoring.server import queries +from argos_monitoring.server.models import Result, Task, User +from argos_monitoring.server.routes.dependencies import get_config, get_db, get_manager route = APIRouter() diff --git a/argos/server/settings.py b/argos_monitoring/server/settings.py similarity index 91% rename from argos/server/settings.py rename to argos_monitoring/server/settings.py index 160e609..e59d2be 100644 --- a/argos/server/settings.py +++ b/argos_monitoring/server/settings.py @@ -4,7 +4,7 @@ from pathlib import Path import yaml from yamlinclude import YamlIncludeConstructor -from argos.schemas.config import Config +from argos_monitoring.schemas.config import Config def read_yaml_config(filename): diff --git a/argos/server/static/logo-64.png b/argos_monitoring/server/static/logo-64.png similarity index 100% rename from argos/server/static/logo-64.png rename to argos_monitoring/server/static/logo-64.png diff --git a/argos/server/static/logo.png b/argos_monitoring/server/static/logo.png similarity index 100% rename from argos/server/static/logo.png rename to argos_monitoring/server/static/logo.png diff --git a/argos/server/static/pico.min.css b/argos_monitoring/server/static/pico.min.css similarity index 100% rename from argos/server/static/pico.min.css rename to argos_monitoring/server/static/pico.min.css diff --git a/argos/server/static/styles.css b/argos_monitoring/server/static/styles.css similarity index 100% rename from argos/server/static/styles.css rename to argos_monitoring/server/static/styles.css diff --git a/argos/server/templates/agents.html b/argos_monitoring/server/templates/agents.html similarity index 100% rename from argos/server/templates/agents.html rename to argos_monitoring/server/templates/agents.html diff --git a/argos/server/templates/base.html b/argos_monitoring/server/templates/base.html similarity index 100% rename from argos/server/templates/base.html rename to argos_monitoring/server/templates/base.html diff --git a/argos/server/templates/domain.html b/argos_monitoring/server/templates/domain.html similarity index 100% rename from argos/server/templates/domain.html rename to argos_monitoring/server/templates/domain.html diff --git a/argos/server/templates/domains.html b/argos_monitoring/server/templates/domains.html similarity index 100% rename from argos/server/templates/domains.html rename to argos_monitoring/server/templates/domains.html diff --git a/argos/server/templates/index.html b/argos_monitoring/server/templates/index.html similarity index 100% rename from argos/server/templates/index.html rename to argos_monitoring/server/templates/index.html diff --git a/argos/server/templates/login.html b/argos_monitoring/server/templates/login.html similarity index 100% rename from argos/server/templates/login.html rename to argos_monitoring/server/templates/login.html diff --git a/argos/server/templates/result.html b/argos_monitoring/server/templates/result.html similarity index 100% rename from argos/server/templates/result.html rename to argos_monitoring/server/templates/result.html diff --git a/argos/server/templates/results.html b/argos_monitoring/server/templates/results.html similarity index 100% rename from argos/server/templates/results.html rename to argos_monitoring/server/templates/results.html diff --git a/conf/config-example.yaml b/conf/config-example.yaml index 52bab49..898ce2b 120000 --- a/conf/config-example.yaml +++ b/conf/config-example.yaml @@ -1 +1 @@ -../argos/config-example.yaml \ No newline at end of file +../argos_monitoring/config-example.yaml \ No newline at end of file diff --git a/conf/systemd-agent.service b/conf/systemd-agent.service index bb0700e..2fd6165 100644 --- a/conf/systemd-agent.service +++ b/conf/systemd-agent.service @@ -8,9 +8,9 @@ After=network.target User=argos EnvironmentFile=/etc/default/argos-agent WorkingDirectory=/opt/argos/ -ExecStart=/opt/argos/venv/bin/argos agent --max-tasks $ARGOS_AGENT_MAX_TASKS \ - --wait-time $ARGOS_AGENT_WAIT_TIME \ - --log-level $ARGOS_AGENT_LOGLEVEL +ExecStart=/opt/argos/venv/bin/argos-monitoring agent --max-tasks $ARGOS_AGENT_MAX_TASKS \ + --wait-time $ARGOS_AGENT_WAIT_TIME \ + --log-level $ARGOS_AGENT_LOGLEVEL SyslogIdentifier=argos-agent [Install] diff --git a/conf/systemd-server.service b/conf/systemd-server.service index 15e0c2d..23d795b 100644 --- a/conf/systemd-server.service +++ b/conf/systemd-server.service @@ -9,14 +9,14 @@ PartOf=postgresql.service User=argos WorkingDirectory=/opt/argos/ EnvironmentFile=/etc/default/argos-server -ExecStartPre=/opt/argos/venv/bin/argos server migrate -ExecStartPre=/opt/argos/venv/bin/argos server reload-config -ExecStart=/opt/argos/venv/bin/gunicorn "argos.server.main:get_application()" \ +ExecStartPre=/opt/argos/venv/bin/argos-monitoring server migrate +ExecStartPre=/opt/argos/venv/bin/argos-monitoring server reload-config +ExecStart=/opt/argos/venv/bin/gunicorn "argos_monitoring.server.main:get_application()" \ --workers $ARGOS_SERVER_WORKERS \ --worker-class uvicorn.workers.UvicornWorker \ --bind $ARGOS_SERVER_SOCKET \ --forwarded-allow-ips $ARGOS_SERVER_FORWARDED_ALLOW_IPS -ExecReload=/opt/argos/venv/bin/argos server reload-config +ExecReload=/opt/argos/venv/bin/argos-monitoring server reload-config SyslogIdentifier=argos-server [Install] diff --git a/docs/cli.md b/docs/cli.md index 83a98f3..b02f16f 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -1,13 +1,13 @@ # Command-line interface @@ -20,7 +20,7 @@ .. ]]] --> ```man -Usage: argos [OPTIONS] COMMAND [ARGS]... +Usage: argos-monitoring [OPTIONS] COMMAND [ARGS]... Options: --help Show this message and exit. @@ -41,11 +41,11 @@ Commands: .. ]]] --> ```man -Usage: argos agent [OPTIONS] SERVER_URL AUTH +Usage: argos-monitoring agent [OPTIONS] SERVER_URL AUTH Get and run tasks for the provided server. Will wait for new tasks. - Usage: argos agent https://argos.example.org "auth-token-here" + Usage: argos-monitoring agent https://argos.example.org "auth-token-here" Alternatively, you can use the following environment variables to avoid passing arguments to the agent on the command line: @@ -71,7 +71,7 @@ Options: .. ]]] --> ```man -Usage: argos server [OPTIONS] COMMAND [ARGS]... +Usage: argos-monitoring server [OPTIONS] COMMAND [ARGS]... Commands for managing server, server’s configuration and users @@ -99,7 +99,7 @@ Commands: .. ]]] --> ```man -Usage: argos server start [OPTIONS] +Usage: argos-monitoring server start [OPTIONS] Starts the server (use only for testing or development!) @@ -128,7 +128,7 @@ Options: .. ]]] --> ```man -Usage: argos server migrate [OPTIONS] +Usage: argos-monitoring server migrate [OPTIONS] Run database migrations @@ -150,7 +150,7 @@ Options: .. ]]] --> ```man -Usage: argos server cleandb [OPTIONS] +Usage: argos-monitoring server cleandb [OPTIONS] Clean the database (to run routinely) @@ -180,7 +180,7 @@ Options: .. ]]] --> ```man -Usage: argos server cleandb [OPTIONS] +Usage: argos-monitoring server cleandb [OPTIONS] Clean the database (to run routinely) @@ -210,7 +210,7 @@ Options: .. ]]] --> ```man -Usage: argos server reload-config [OPTIONS] +Usage: argos-monitoring server reload-config [OPTIONS] Read tasks’ configuration and add/delete tasks in database if needed @@ -232,12 +232,12 @@ Options: .. ]]] --> ```man -Usage: argos server generate-config [OPTIONS] +Usage: argos-monitoring server generate-config [OPTIONS] Output a self-documented example config file. Redirect the output to a file to save it: - argos server generate-config > /etc/argos/config.yaml + argos-monitoring server generate-config > /etc/argos/config.yaml Options: --help Show this message and exit. @@ -254,7 +254,7 @@ Options: .. ]]] --> ```man -Usage: argos server generate-token [OPTIONS] +Usage: argos-monitoring server generate-token [OPTIONS] Generate a token, which can be used as an agent’s authentication token. @@ -279,7 +279,7 @@ You can manage users only through CLI. .. ]]] --> ```man -Usage: argos server user [OPTIONS] COMMAND [ARGS]... +Usage: argos-monitoring server user [OPTIONS] COMMAND [ARGS]... User management @@ -307,7 +307,7 @@ Commands: .. ]]] --> ```man -Usage: argos server user add [OPTIONS] +Usage: argos-monitoring server user add [OPTIONS] Add new user @@ -330,7 +330,7 @@ Options: .. ]]] --> ```man -Usage: argos server user change-password [OPTIONS] +Usage: argos-monitoring server user change-password [OPTIONS] Change user’s password @@ -353,7 +353,7 @@ Options: .. ]]] --> ```man -Usage: argos server user delete [OPTIONS] +Usage: argos-monitoring server user delete [OPTIONS] Delete user @@ -377,7 +377,7 @@ Disabling a user prevents the user to login and access Argos’ web interface bu .. ]]] --> ```man -Usage: argos server user disable [OPTIONS] +Usage: argos-monitoring server user disable [OPTIONS] Disable user @@ -403,7 +403,7 @@ Obviously, the user needs to exists and to be disabled before using the command. .. ]]] --> ```man -Usage: argos server user enable [OPTIONS] +Usage: argos-monitoring server user enable [OPTIONS] Enable user @@ -427,7 +427,7 @@ Show all accounts, with their status (enabled or disabled). .. ]]] --> ```man -Usage: argos server user show [OPTIONS] +Usage: argos-monitoring server user show [OPTIONS] List all users @@ -450,7 +450,7 @@ You can verify that you have the right password for a user with the following co .. ]]] --> ```man -Usage: argos server user verify-password [OPTIONS] +Usage: argos-monitoring server user verify-password [OPTIONS] Test user’s password diff --git a/docs/conf.py b/docs/conf.py index b0a05bb..7209646 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,10 +8,10 @@ # pylint: disable-msg=invalid-name,redefined-builtin import argos -project = "Argos" +project = "Argos Panoptès" copyright = "2023, Alexis Métaireau, Framasoft" author = "Alexis Métaireau, Framasoft" -release = argos.VERSION +release = argos_monitoring.VERSION # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/docs/configuration.md b/docs/configuration.md index 576c55c..a0a0e80 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -2,7 +2,7 @@ Argos uses a simple YAML configuration file to define the server’s configuration, the websites to monitor and the checks to run on these websites. -Here is a simple self-documented configuration file, which you can get with [`argos server generate-config`](cli.md#server-generate-config): +Here is a simple self-documented configuration file, which you can get with [`argos-monitoring server generate-config`](cli.md#server-generate-config): ```{literalinclude} ../conf/config-example.yaml --- diff --git a/docs/developer/dependencies.md b/docs/developer/dependencies.md index b22ba95..f1c5461 100644 --- a/docs/developer/dependencies.md +++ b/docs/developer/dependencies.md @@ -4,6 +4,7 @@ - [Click](https://click.palletsprojects.com/) for the command-line interface; - [FastAPI](https://fastapi.tiangolo.com/) is the framework that allows us to expose the HTTP API; +- [FastAPI Login](https://fastapi-login.readthedocs.io), a convenient and simple way to use user authentication for FastAPI; - [HTTPX](https://www.python-httpx.org/) is used to issue asynchronous requests in the agents; - [Jinja](https://jinja.palletsprojects.com/) is handling the templating; - [Pydantic](https://pydantic.dev/) is useful to ensure the data matches our expectactions; diff --git a/docs/developer/migrations.md b/docs/developer/migrations.md index 72e75c8..018ec1e 100644 --- a/docs/developer/migrations.md +++ b/docs/developer/migrations.md @@ -7,7 +7,7 @@ First, do your changes in the code, change the model, add new tables, etc. Once you're done, you can create a new migration. ```bash -venv/bin/alembic -c argos/server/migrations/alembic.ini revision --autogenerate -m "migration reason" +venv/bin/alembic -c argos_monitoring/server/migrations/alembic.ini revision --autogenerate -m "migration reason" ``` Edit the created file to remove comments and adapt it to make sure the migration is complete (Alembic is not powerful enough to cover all the corner cases). diff --git a/docs/developer/models.md b/docs/developer/models.md index d7f8bfc..93f7e18 100644 --- a/docs/developer/models.md +++ b/docs/developer/models.md @@ -31,7 +31,7 @@ Result "*" o-- "1" Task : has many The `severity` attribute in `Task` is the severity of the last `Result` submitted by an agent. -```{literalinclude} ../../argos/server/models.py +```{literalinclude} ../../argos_monitoring/server/models.py --- caption: models.py --- diff --git a/docs/developer/new-check.md b/docs/developer/new-check.md index 586ec2c..86a042c 100644 --- a/docs/developer/new-check.md +++ b/docs/developer/new-check.md @@ -2,7 +2,7 @@ ## Creating a new check class -If you want to implement a new check, you need to create a new class that inherits from `argos.checks.BaseCheck`. +If you want to implement a new check, you need to create a new class that inherits from `argos_monitoring.checks.BaseCheck`. You need to implement two methods, and specify the type of the data you want to check. @@ -37,4 +37,4 @@ If that's your case, you can implement the `finalize` method, and return some ex async def finalize(cls, config, result, extra_arg): # You can use the extra_arg here to determine the severity return Status.SUCCESS, Severity.OK -``` \ No newline at end of file +``` diff --git a/docs/developer/new-notification-way.md b/docs/developer/new-notification-way.md index 3e193a8..0b8a7e6 100644 --- a/docs/developer/new-notification-way.md +++ b/docs/developer/new-notification-way.md @@ -15,7 +15,7 @@ gotify: Feel free to open an issue to discuss about your notification way or its configuration before coding! See [#50](https://framagit.org/framasoft/framaspace/argos/-/issues/50) for example. -Then, you’ll need to add the pydantic schema matching your config in [`argos/schemas/config.py`](https://framagit.org/framasoft/framaspace/argos/-/blob/main/argos/schemas/config.py). +Then, you’ll need to add the pydantic schema matching your config in [`argos_monitoring/schemas/config.py`](https://framagit.org/framasoft/framaspace/argos/-/blob/main/argos_monitoring/schemas/config.py). For gotify, it’s: ```python @@ -31,4 +31,4 @@ For gotify, we added this: gotify: Optional[List[GotifyUrl]] = None ``` -Finally, write a function which use your new notification way in [`argos/server/alerting.py`](https://framagit.org/framasoft/framaspace/argos/-/blob/main/argos/server/alerting.py) and use it in the `handle_alert` function of the same file. +Finally, write a function which use your new notification way in [`argos_monitoring/server/alerting.py`](https://framagit.org/framasoft/framaspace/argos/-/blob/main/argos_monitoring/server/alerting.py) and use it in the `handle_alert` function of the same file. diff --git a/docs/developer/release.md b/docs/developer/release.md index d93808e..a37df57 100644 --- a/docs/developer/release.md +++ b/docs/developer/release.md @@ -30,11 +30,11 @@ hatch version minor # or `hatch version major`, or `hatch version fix` editor CHANGELOG.md # Commit the change -git add argos/__init__.py CHANGELOG.md +git add argos_monitoring/__init__.py CHANGELOG.md git commit -m "🏷 — Bump version ($(hatch version))" # Create a tag on the git repository and push it -git tag "$(hatch version)" && git push +git tag "$(hatch version)" && git push --follow-tags # Build the project hatch build --clean @@ -50,7 +50,7 @@ Use CHANGELOG.md content for that. ## Bumping the version number -We follow semantic versionning conventions, and the version is specified in the `argos.__init__.py` file. +We follow semantic versionning conventions, and the version is specified in the `argos_monitoring.__init__.py` file. `hatch` provide commands to help with this: ```bash @@ -75,7 +75,7 @@ Once published, you can test it works properly, by using pip, ideally in a new v python -m venv /tmp/argos source /tmp/argos/bin/activate pip install argos-monitoring -argos version # should output the proper version +argos-monitoring version # should output the proper version ``` ## Using the test server diff --git a/docs/installation/getting-started.md b/docs/installation/getting-started.md index 65fae33..09db099 100644 --- a/docs/installation/getting-started.md +++ b/docs/installation/getting-started.md @@ -59,7 +59,7 @@ To install gunicorn, use `pip install -e ".[gunicorn]"` instead of `pip install The quickest way to get started is to generate the configuration file from argos and edit it: ```bash -argos server generate-config > argos-config.yaml +argos-monitoring server generate-config > argos-config.yaml ``` You can read more about the configuration in the [configuration section](../configuration.md). @@ -74,7 +74,7 @@ chmod 700 /etc/argos Then, as `argos`: ```bash -argos server generate-config > /etc/argos/config.yaml +argos-monitoring server generate-config > /etc/argos/config.yaml chmod 600 /etc/argos/config.yaml ``` @@ -85,7 +85,7 @@ Please note that the only supported database engines are SQLite for development Create the schema in the database with: ```bash -argos server migrate +argos-monitoring server migrate ``` ## Inject tasks into the database @@ -95,7 +95,7 @@ Argos keeps tasks’ configuration in database, taken from the config file. Populate the database with the tasks: ```bash -argos server reload-config +argos-monitoring server reload-config ``` ## Generating a token @@ -104,7 +104,7 @@ The agent needs an authentication token to be able to communicate with the serve You can generate an authentication token with the following command: ```bash -argos server generate-token +argos-monitoring server generate-token ``` Add the token in the configuration file, in the following setting: @@ -120,7 +120,7 @@ service: Then you can start the server: ```bash -argos server start +argos-monitoring server start ``` This way to start the server is not suitable for production, use it only for developing or testing. @@ -138,7 +138,7 @@ pip install "argos-monitoring[gunicorn]" To start the server: ```bash -gunicorn "argos.server.main:get_application()" -k uvicorn.workers.UvicornWorker +gunicorn "argos_monitoring.server.main:get_application()" -k uvicorn.workers.UvicornWorker ``` There is some gunicorn’s options that you should use: @@ -149,7 +149,8 @@ There is some gunicorn’s options that you should use: So, to start the server with 4 workers while listening to `127.0.0.1:8001`: ```bash -gunicorn "argos.server.main:get_application()" -k uvicorn.workers.UvicornWorker -w 4 -b 127.0.0.1:8001 +export ARGOS_YAML_FILE=/etc/argos/config.yaml +gunicorn "argos_monitoring.server.main:get_application()" -k uvicorn.workers.UvicornWorker -w 4 -b 127.0.0.1:8001 ``` Gunicorn has a lot of other options, have a look at `gunicorn --help`. @@ -165,29 +166,29 @@ You can run the agent on the same machine as the server, or on a different machi The only requirement is that the agent can reach the server through HTTP or HTTPS. ```bash -argos agent http://localhost:8000 "auth-token" +argos-monitoring agent http://localhost:8000 "auth-token" ``` ## Cleaning the database -You have to run cleaning task periodically. `argos server cleandb --help` will give you more information on how to do that. +You have to run cleaning task periodically. `argos-monitoring server cleandb --help` will give you more information on how to do that. Here is a crontab example, which will clean the db each hour: ```bash # Run the cleaning tasks every hour (at minute 7) # Keeps 10 results per task, and remove tasks’ locks older than 1 hour -7 * * * * argos server cleandb --max-results 10 --max-lock-seconds 3600 +7 * * * * argos-monitoring server cleandb --max-results 10 --max-lock-seconds 3600 ``` ## Watch the agents -In order to be sure that agents are up and communicate with the server, you can periodically run the `argos server watch-agents` command. +In order to be sure that agents are up and communicate with the server, you can periodically run the `argos-monitoring server watch-agents` command. Here is a crontab example, which will check the agents every 5 minutes: ```bash -*/5 * * * * argos server watch-agents --time-without-agent 10 +*/5 * * * * argos-monitoring server watch-agents --time-without-agent 10 ``` -Check the documentation of the command with `argos server watch-agents --help` +Check the documentation of the command with `argos-monitoring server watch-agents --help` diff --git a/docs/installation/tl-dr.md b/docs/installation/tl-dr.md index 26b35b6..7068fcf 100644 --- a/docs/installation/tl-dr.md +++ b/docs/installation/tl-dr.md @@ -13,11 +13,11 @@ cd /tmp/argos python3 -m venv venv source venv/bin/activate pip install argos-monitoring -argos server generate-config | +argos-monitoring server generate-config | sed -e "s@production@dev@" \ -e "s@url: .postgresql.*@url: \"sqlite:////tmp/argos.db\"@" > argos-config.yaml -argos server migrate -ARGOS_TOKEN=$(argos server generate-token) +argos-monitoring server migrate +ARGOS_TOKEN=$(argos-monitoring server generate-token) sed -e "s@# - secret_token@- $ARGOS_TOKEN@" -i argos-config.yaml echo "The agent token is $ARGOS_TOKEN" ``` @@ -28,8 +28,8 @@ Add some real web sites to test. Then: ``` -argos server reload-config -argos server start --host 0.0.0.0 --port 8000 +argos-monitoring server reload-config +argos-monitoring server start --host 0.0.0.0 --port 8000 ``` In another terminal: @@ -37,7 +37,7 @@ In another terminal: ``` cd /tmp/argos source venv/bin/activate -argos agent http://127.0.0.1:8000 the_generated_token +argos-monitoring agent http://127.0.0.1:8000 the_generated_token ``` Then go to `http://127.0.0.1:8000` or `http://the_IP_address_of_your_server:8000`. @@ -56,7 +56,7 @@ sudo -u argos python3 -m venv venv sudo -u argos bash -c 'source venv/bin/activate && pip install "argos-monitoring[gunicorn]"' mkdir /etc/argos -/opt/argos/venv/bin/argos server generate-config > /etc/argos/config.yaml +/opt/argos/venv/bin/argos-monitoring server generate-config > /etc/argos/config.yaml cat < /etc/default/argos-server ARGOS_YAML_FILE="/etc/argos/config.yaml" @@ -86,14 +86,14 @@ PartOf=postgresql.service User=argos WorkingDirectory=/opt/argos/ EnvironmentFile=/etc/default/argos-server -ExecStartPre=/opt/argos/venv/bin/argos server migrate -ExecStartPre=/opt/argos/venv/bin/argos server reload-config -ExecStart=/opt/argos/venv/bin/gunicorn "argos.server.main:get_application()" \\ +ExecStartPre=/opt/argos/venv/bin/argos-monitoring server migrate +ExecStartPre=/opt/argos/venv/bin/argos-monitoring server reload-config +ExecStart=/opt/argos/venv/bin/gunicorn "argos_monitoring.server.main:get_application()" \\ --workers \$ARGOS_SERVER_WORKERS \\ --worker-class uvicorn.workers.UvicornWorker \\ --bind \$ARGOS_SERVER_SOCKET \\ --forwarded-allow-ips \$ARGOS_SERVER_FORWARDED_ALLOW_IPS -ExecReload=/opt/argos/venv/bin/argos server reload-config +ExecReload=/opt/argos/venv/bin/argos-monitoring server reload-config SyslogIdentifier=argos-server [Install] @@ -111,7 +111,7 @@ After=network.target User=argos EnvironmentFile=/etc/default/argos-agent WorkingDirectory=/opt/argos/ -ExecStart=/opt/argos/venv/bin/argos agent --max-tasks \$ARGOS_AGENT_MAX_TASKS \\ +ExecStart=/opt/argos/venv/bin/argos-monitoring agent --max-tasks \$ARGOS_AGENT_MAX_TASKS \\ --wait-time \$ARGOS_AGENT_WAIT_TIME \\ --log-level \$ARGOS_AGENT_LOGLEVEL SyslogIdentifier=argos-agent @@ -132,7 +132,7 @@ Then, edit `/etc/argos/config.yaml` to put your database password in it and chan Create a token for your agent : ```bash -sudo -u argos /opt/argos/venv/bin/argos server generate-token +sudo -u argos /opt/argos/venv/bin/argos-monitoring server generate-token ``` Edit `/etc/default/argos-agent` to put the generated token in it and change the other settings to suit your needs. @@ -150,8 +150,8 @@ If all works well, you have to put some cron tasks in `argos` crontab: ```bash cat < Session: - from argos.server import models + from argos_monitoring.server import models app = _create_app() models.Base.metadata.create_all(bind=app.state.engine) @@ -21,7 +21,7 @@ def db() -> Session: @pytest.fixture def app() -> FastAPI: - from argos.server import models + from argos_monitoring.server import models app = _create_app() models.Base.metadata.create_all(bind=app.state.engine) @@ -38,7 +38,7 @@ def authorized_client(app): def _create_app() -> FastAPI: - from argos.server.main import ( # local import for testing purpose + from argos_monitoring.server.main import ( # local import for testing purpose get_application, setup_database, connect_to_db, diff --git a/tests/test_api.py b/tests/test_api.py index 21c87d1..e765090 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -3,9 +3,9 @@ import asyncio import pytest from fastapi.testclient import TestClient -from argos.schemas import AgentResult, SerializableException -from argos.server import models -from argos.server.queries import update_from_config +from argos_monitoring.schemas import AgentResult, SerializableException +from argos_monitoring.server import models +from argos_monitoring.server.queries import update_from_config def test_read_tasks_requires_auth(app): diff --git a/tests/test_checks.py b/tests/test_checks.py index fc660b5..eab2605 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -5,8 +5,8 @@ from unittest.mock import MagicMock import httpx import pytest -from argos.checks import SSLCertificateExpiration -from argos.schemas import Task +from argos_monitoring.checks import SSLCertificateExpiration +from argos_monitoring.schemas import Task @pytest.fixture diff --git a/tests/test_checks_base.py b/tests/test_checks_base.py index 6c1b9a4..31075b0 100644 --- a/tests/test_checks_base.py +++ b/tests/test_checks_base.py @@ -1,4 +1,4 @@ -from argos.checks.base import Response, Status +from argos_monitoring.checks.base import Response, Status def test_response_failure_with_context(): diff --git a/tests/test_cli.py b/tests/test_cli.py index 1225379..639dac1 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,7 +1,7 @@ import os from click.testing import CliRunner -from argos.commands import ( +from argos_monitoring.commands import ( add, verify_password, change_password, diff --git a/tests/test_queries.py b/tests/test_queries.py index c468362..ac32a94 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -2,9 +2,9 @@ from datetime import datetime, timedelta import pytest -from argos import schemas -from argos.server import queries -from argos.server.models import Result, Task, User +from argos_monitoring import schemas +from argos_monitoring.server import queries +from argos_monitoring.server.models import Result, Task, User @pytest.mark.asyncio diff --git a/tests/test_schemas_config.py b/tests/test_schemas_config.py index baff271..0d86742 100644 --- a/tests/test_schemas_config.py +++ b/tests/test_schemas_config.py @@ -1,6 +1,6 @@ import pytest -from argos.schemas.config import SSL, WebsitePath +from argos_monitoring.schemas.config import SSL, WebsitePath def test_ssl_duration_parsing(): diff --git a/tests/test_schemas_utils.py b/tests/test_schemas_utils.py index 53cd170..ff92944 100644 --- a/tests/test_schemas_utils.py +++ b/tests/test_schemas_utils.py @@ -1,6 +1,6 @@ import pytest -from argos.schemas.utils import string_to_duration +from argos_monitoring.schemas.utils import string_to_duration def test_string_to_duration_days():