💥 — Rename argos to argos-monitoring to fit the package name (fix #53)

Uninstall argos with `pip uninstall argos-monitoring` before installing this release!
This commit is contained in:
Luc Didry 2024-06-27 10:04:00 +02:00
parent 3b49594bef
commit 4880c65681
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C
69 changed files with 164 additions and 156 deletions

View file

@ -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 its been long since last viewing an agent (fix #49)

View file

@ -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)

View file

@ -1 +0,0 @@
from argos.server.main import app # noqa: F401

View file

@ -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):

View file

@ -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,

View file

@ -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:

View file

@ -2,7 +2,7 @@
from datetime import datetime
from argos.checks.base import (
from argos_monitoring.checks.base import (
BaseCheck,
ExpectedIntValue,
ExpectedStringValue,

View file

@ -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:

View file

@ -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

View file

@ -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()

View file

@ -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

View file

@ -0,0 +1 @@
from argos_monitoring.server.main import app # noqa: F401

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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):

View file

@ -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):

View file

@ -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()

View file

@ -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()

View file

@ -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):

View file

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View file

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

View file

@ -1 +1 @@
../argos/config-example.yaml
../argos_monitoring/config-example.yaml

View file

@ -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]

View file

@ -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]

View file

@ -1,13 +1,13 @@
# Command-line interface
<!-- [[[cog
from argos.commands import cli
from argos_monitoring.commands import cli
from click.testing import CliRunner
def help(args):
title = "argos " + " ".join(args)
title = "argos-monitoring " + " ".join(args)
cog.out("\n```man\n")
result = CliRunner().invoke(cli, args)
output = result.output.replace("Usage: cli ", "Usage: argos ")
output = result.output.replace("Usage: cli ", "Usage: argos-monitoring ")
cog.out(output)
cog.out("```\n\n")
]]] -->
@ -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, servers 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 agents 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 users 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 users password

View file

@ -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

View file

@ -2,7 +2,7 @@
Argos uses a simple YAML configuration file to define the servers 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
---

View file

@ -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;

View file

@ -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).

View file

@ -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
---

View file

@ -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.

View file

@ -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, youll 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, youll 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, its:
```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.

View file

@ -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

View file

@ -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 gunicorns options that you should use:
@ -149,7 +149,8 @@ There is some gunicorns 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`

View file

@ -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 <<EOF > /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 <<EOF | crontab -u argos -
*/10 * * * * /opt/argos/venv/bin/argos server cleandb --max-lock-seconds 120 --max-results 1200
*/10 * * * * /opt/argos/venv/bin/argos server watch-agents --time-without-agent 10
*/10 * * * * /opt/argos/venv/bin/argos-monitoring server cleandb --max-lock-seconds 120 --max-results 1200
*/10 * * * * /opt/argos/venv/bin/argos-monitoring server watch-agents --time-without-agent 10
EOF
```

View file

@ -76,27 +76,27 @@ repository = "https://framagit.org/framasoft/framaspace/argos"
[tool.hatch.build.targets.sdist]
include = [
"/argos",
"/argos_monitoring",
"/docs",
"/tests",
]
[tool.hatch.build.targets.wheel]
packages = ["argos"]
packages = ["argos_monitoring"]
[tool.hatch.version]
path = "argos/__init__.py"
path = "argos_monitoring/__init__.py"
[project.scripts]
argos = "argos.commands:cli"
argos-monitoring = "argos_monitoring.commands:cli"
[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
testpaths = [
"tests",
"argos"
"argos_monitoring"
]
pythonpath = "."
filterwarnings = [

View file

@ -11,7 +11,7 @@ os.environ["ARGOS_YAML_FILE"] = "tests/config.yaml"
@pytest.fixture
def db() -> 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,

View file

@ -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):

View file

@ -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

View file

@ -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():

View file

@ -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,

View file

@ -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

View file

@ -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():

View file

@ -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():