mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
♻💥 — 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:
parent
3b49594bef
commit
4880c65681
69 changed files with 164 additions and 156 deletions
|
@ -3,6 +3,8 @@
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
- 🩹 — Fix release documentation
|
- 🩹 — 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
|
## 0.2.2
|
||||||
|
|
||||||
|
@ -22,7 +24,7 @@ Date: 2024-06-24
|
||||||
|
|
||||||
- 💄📯 — Improve notifications and result(s) pages
|
- 💄📯 — Improve notifications and result(s) pages
|
||||||
- 🔊 — Add level of log before the log message
|
- 🔊 — 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)
|
- ✨ — Add command to generate example configuration (fix #38)
|
||||||
- 📝 — Improve documentation
|
- 📝 — Improve documentation
|
||||||
- ✨ — Add command to warn if it’s been long since last viewing an agent (fix #49)
|
- ✨ — Add command to warn if it’s been long since last viewing an agent (fix #49)
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -25,9 +25,9 @@ ruff: venv
|
||||||
ruff-format: venv
|
ruff-format: venv
|
||||||
venv/bin/ruff format .
|
venv/bin/ruff format .
|
||||||
djlint: venv ## Format the templates
|
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
|
pylint: venv ## Runs pylint on the code
|
||||||
venv/bin/pylint argos
|
venv/bin/pylint argos_monitoring
|
||||||
lint: djlint pylint ruff
|
lint: djlint pylint ruff
|
||||||
help:
|
help:
|
||||||
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
|
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
from argos.server.main import app # noqa: F401
|
|
|
@ -11,9 +11,9 @@ from typing import List
|
||||||
import httpx
|
import httpx
|
||||||
from tenacity import retry, wait_random # type: ignore
|
from tenacity import retry, wait_random # type: ignore
|
||||||
|
|
||||||
from argos.checks import get_registered_check
|
from argos_monitoring.checks import get_registered_check
|
||||||
from argos.logging import logger
|
from argos_monitoring.logging import logger
|
||||||
from argos.schemas import AgentResult, SerializableException, Task
|
from argos_monitoring.schemas import AgentResult, SerializableException, Task
|
||||||
|
|
||||||
|
|
||||||
def log_failure(retry_state):
|
def log_failure(retry_state):
|
|
@ -1,10 +1,10 @@
|
||||||
from argos.checks.base import ( # NOQA
|
from argos_monitoring.checks.base import ( # NOQA
|
||||||
BaseCheck,
|
BaseCheck,
|
||||||
CheckNotFound,
|
CheckNotFound,
|
||||||
get_registered_check,
|
get_registered_check,
|
||||||
get_registered_checks,
|
get_registered_checks,
|
||||||
)
|
)
|
||||||
from argos.checks.checks import ( # NOQA
|
from argos_monitoring.checks.checks import ( # NOQA
|
||||||
HTTPBodyContains,
|
HTTPBodyContains,
|
||||||
HTTPStatus,
|
HTTPStatus,
|
||||||
SSLCertificateExpiration,
|
SSLCertificateExpiration,
|
|
@ -6,7 +6,7 @@ from typing import Type, Union
|
||||||
import httpx
|
import httpx
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from argos.schemas.models import Task
|
from argos_monitoring.schemas.models import Task
|
||||||
|
|
||||||
|
|
||||||
class Status:
|
class Status:
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from argos.checks.base import (
|
from argos_monitoring.checks.base import (
|
||||||
BaseCheck,
|
BaseCheck,
|
||||||
ExpectedIntValue,
|
ExpectedIntValue,
|
||||||
ExpectedStringValue,
|
ExpectedStringValue,
|
|
@ -10,13 +10,17 @@ import uvicorn
|
||||||
from alembic import command
|
from alembic import command
|
||||||
from alembic.config import Config
|
from alembic.config import Config
|
||||||
|
|
||||||
from argos import logging
|
from argos_monitoring import logging
|
||||||
from argos import VERSION
|
from argos_monitoring import VERSION
|
||||||
from argos.agent import ArgosAgent
|
from argos_monitoring.agent import ArgosAgent
|
||||||
|
|
||||||
|
|
||||||
async def get_db():
|
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()
|
app = get_application()
|
||||||
setup_database(app)
|
setup_database(app)
|
||||||
|
@ -96,7 +100,7 @@ def version():
|
||||||
def agent(server_url, auth, max_tasks, wait_time, log_level):
|
def agent(server_url, auth, max_tasks, wait_time, log_level):
|
||||||
"""Get and run tasks for the provided server. Will wait for new tasks.
|
"""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
|
Alternatively, you can use the following environment variables to avoid passing
|
||||||
arguments to the agent on the command line:
|
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
|
ARGOS_AGENT_TOKEN=auth-token-here
|
||||||
"""
|
"""
|
||||||
click.echo("Starting argos agent. Will retry forever.")
|
click.echo("Starting argos agent. Will retry forever.")
|
||||||
from argos.logging import logger
|
from argos_monitoring.logging import logger
|
||||||
|
|
||||||
logger.setLevel(log_level)
|
logger.setLevel(log_level)
|
||||||
agent_ = ArgosAgent(server_url, auth, max_tasks, wait_time)
|
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.
|
for advices on how to start the server for production.
|
||||||
"""
|
"""
|
||||||
os.environ["ARGOS_YAML_FILE"] = config
|
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):
|
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
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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()
|
db = await get_db()
|
||||||
removed = await queries.remove_old_results(db, max_results)
|
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
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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()
|
db = await get_db()
|
||||||
agents = await queries.get_recent_agents_count(db, time_without_agent)
|
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
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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 argos.server.main import read_config
|
from argos_monitoring.server.main import read_config
|
||||||
|
|
||||||
_config = read_config(config)
|
_config = read_config(config)
|
||||||
|
|
||||||
|
@ -277,7 +281,7 @@ async def migrate(config):
|
||||||
os.environ["ARGOS_YAML_FILE"] = config
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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)
|
settings = read_yaml_config(config)
|
||||||
|
|
||||||
|
@ -305,7 +309,7 @@ async def add(config, name, password):
|
||||||
os.environ["ARGOS_YAML_FILE"] = config
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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
|
from passlib.context import CryptContext
|
||||||
|
|
||||||
db = await get_db()
|
db = await get_db()
|
||||||
|
@ -339,7 +343,7 @@ async def change_password(config, name, password):
|
||||||
os.environ["ARGOS_YAML_FILE"] = config
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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
|
from passlib.context import CryptContext
|
||||||
|
|
||||||
db = await get_db()
|
db = await get_db()
|
||||||
|
@ -374,7 +378,7 @@ async def verify_password(config, name, password):
|
||||||
os.environ["ARGOS_YAML_FILE"] = config
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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
|
from passlib.context import CryptContext
|
||||||
|
|
||||||
db = await get_db()
|
db = await get_db()
|
||||||
|
@ -408,7 +412,7 @@ async def disable(config, name):
|
||||||
os.environ["ARGOS_YAML_FILE"] = config
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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()
|
db = await get_db()
|
||||||
_user = await queries.get_user(db, name)
|
_user = await queries.get_user(db, name)
|
||||||
|
@ -442,7 +446,7 @@ async def enable(config, name):
|
||||||
os.environ["ARGOS_YAML_FILE"] = config
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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()
|
db = await get_db()
|
||||||
_user = await queries.get_user(db, name)
|
_user = await queries.get_user(db, name)
|
||||||
|
@ -476,7 +480,7 @@ async def delete(config, name):
|
||||||
os.environ["ARGOS_YAML_FILE"] = config
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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()
|
db = await get_db()
|
||||||
_user = await queries.get_user(db, name)
|
_user = await queries.get_user(db, name)
|
||||||
|
@ -506,7 +510,7 @@ async def show(config):
|
||||||
os.environ["ARGOS_YAML_FILE"] = config
|
os.environ["ARGOS_YAML_FILE"] = config
|
||||||
|
|
||||||
# The imports are made here otherwise the agent will need server configuration files.
|
# 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()
|
db = await get_db()
|
||||||
users = await queries.list_users(db)
|
users = await queries.list_users(db)
|
||||||
|
@ -541,7 +545,7 @@ async def generate_config():
|
||||||
|
|
||||||
\b
|
\b
|
||||||
Redirect the output to a file to save it:
|
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"
|
config_example = Path(__file__).resolve().parent / "config-example.yaml"
|
||||||
with config_example.open("r", encoding="utf-8") as f:
|
with config_example.open("r", encoding="utf-8") as f:
|
|
@ -52,7 +52,7 @@ general:
|
||||||
|
|
||||||
service:
|
service:
|
||||||
secrets:
|
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:
|
# You need at least one. Write them as a list, like:
|
||||||
# - secret_token
|
# - secret_token
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Pydantic schemas for configuration
|
"""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
|
from typing import Dict, List, Literal, Optional, Tuple
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ from pydantic.networks import UrlConstraints
|
||||||
from pydantic_core import Url
|
from pydantic_core import Url
|
||||||
from typing_extensions import Annotated
|
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"]
|
Severity = Literal["warning", "error", "critical", "unknown"]
|
||||||
Environment = Literal["dev", "test", "production"]
|
Environment = Literal["dev", "test", "production"]
|
||||||
|
@ -68,7 +68,7 @@ def parse_checks(value):
|
||||||
"""Check that checks are valid (i.e. registered) checks"""
|
"""Check that checks are valid (i.e. registered) checks"""
|
||||||
|
|
||||||
# To avoid circular imports
|
# 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()
|
available_names = get_registered_checks().keys()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"""Pydantic schemas for data
|
"""Pydantic schemas for data
|
||||||
|
|
||||||
For database models, see argos.server.models.
|
For database models, see argos_monitoring.server.models.
|
||||||
"""
|
"""
|
||||||
import traceback
|
import traceback
|
||||||
from datetime import datetime
|
from datetime import datetime
|
1
argos_monitoring/server/__init__.py
Normal file
1
argos_monitoring/server/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
from argos_monitoring.server.main import app # noqa: F401
|
|
@ -6,12 +6,9 @@ from urllib.parse import urlparse
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
from argos.checks.base import Severity
|
from argos_monitoring.checks.base import Severity
|
||||||
from argos.logging import logger
|
from argos_monitoring.logging import logger
|
||||||
from argos.schemas.config import Config, Mail, GotifyUrl
|
from argos_monitoring.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
|
|
||||||
|
|
||||||
|
|
||||||
def handle_alert(config: Config, result, task, severity, old_severity, request):
|
def handle_alert(config: Config, result, task, severity, old_severity, request):
|
|
@ -10,10 +10,13 @@ from pydantic import ValidationError
|
||||||
from sqlalchemy import create_engine, event
|
from sqlalchemy import create_engine, event
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
|
||||||
from argos.logging import logger
|
from argos_monitoring.logging import logger
|
||||||
from argos.server import models, routes, queries
|
from argos_monitoring.server import models, routes, queries
|
||||||
from argos.server.exceptions import NotAuthenticatedException, auth_exception_handler
|
from argos_monitoring.server.exceptions import (
|
||||||
from argos.server.settings import read_yaml_config
|
NotAuthenticatedException,
|
||||||
|
auth_exception_handler,
|
||||||
|
)
|
||||||
|
from argos_monitoring.server.settings import read_yaml_config
|
||||||
|
|
||||||
|
|
||||||
def get_application() -> FastAPI:
|
def get_application() -> FastAPI:
|
||||||
|
@ -120,7 +123,7 @@ async def lifespan(appli):
|
||||||
if tasks_count == 0:
|
if tasks_count == 0:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"There is no tasks in the database. "
|
"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
|
yield
|
|
@ -1,7 +1,7 @@
|
||||||
from logging.config import fileConfig
|
from logging.config import fileConfig
|
||||||
|
|
||||||
from alembic import context
|
from alembic import context
|
||||||
from argos.server.models import Base
|
from argos_monitoring.server.models import Base
|
||||||
from sqlalchemy import engine_from_config, pool
|
from sqlalchemy import engine_from_config, pool
|
||||||
|
|
||||||
config = context.config
|
config = context.config
|
|
@ -10,8 +10,8 @@ from sqlalchemy import (
|
||||||
)
|
)
|
||||||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
|
||||||
|
|
||||||
from argos.checks import BaseCheck, get_registered_check
|
from argos_monitoring.checks import BaseCheck, get_registered_check
|
||||||
from argos.schemas import WebsiteCheck
|
from argos_monitoring.schemas import WebsiteCheck
|
||||||
|
|
||||||
|
|
||||||
class Base(DeclarativeBase):
|
class Base(DeclarativeBase):
|
|
@ -7,9 +7,9 @@ from urllib.parse import urljoin
|
||||||
from sqlalchemy import asc, desc, func
|
from sqlalchemy import asc, desc, func
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from argos import schemas
|
from argos_monitoring import schemas
|
||||||
from argos.logging import logger
|
from argos_monitoring.logging import logger
|
||||||
from argos.server.models import Result, Task, ConfigCache, User
|
from argos_monitoring.server.models import Result, Task, ConfigCache, User
|
||||||
|
|
||||||
|
|
||||||
async def list_tasks(db: Session, agent_id: str, limit: int = 100):
|
async def list_tasks(db: Session, agent_id: str, limit: int = 100):
|
|
@ -4,11 +4,11 @@ from typing import List, Union
|
||||||
from fastapi import APIRouter, BackgroundTasks, Depends, Request
|
from fastapi import APIRouter, BackgroundTasks, Depends, Request
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from argos.logging import logger
|
from argos_monitoring.logging import logger
|
||||||
from argos.schemas import AgentResult, Config, Task
|
from argos_monitoring.schemas import AgentResult, Config, Task
|
||||||
from argos.server import queries
|
from argos_monitoring.server import queries
|
||||||
from argos.server.alerting import handle_alert
|
from argos_monitoring.server.alerting import handle_alert
|
||||||
from argos.server.routes.dependencies import get_config, get_db, verify_token
|
from argos_monitoring.server.routes.dependencies import get_config, get_db, verify_token
|
||||||
|
|
||||||
route = APIRouter()
|
route = APIRouter()
|
||||||
|
|
|
@ -14,10 +14,10 @@ from passlib.context import CryptContext
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from argos.schemas import Config
|
from argos_monitoring.schemas import Config
|
||||||
from argos.server import queries
|
from argos_monitoring.server import queries
|
||||||
from argos.server.models import Result, Task, User
|
from argos_monitoring.server.models import Result, Task, User
|
||||||
from argos.server.routes.dependencies import get_config, get_db, get_manager
|
from argos_monitoring.server.routes.dependencies import get_config, get_db, get_manager
|
||||||
|
|
||||||
route = APIRouter()
|
route = APIRouter()
|
||||||
|
|
|
@ -4,7 +4,7 @@ from pathlib import Path
|
||||||
import yaml
|
import yaml
|
||||||
from yamlinclude import YamlIncludeConstructor
|
from yamlinclude import YamlIncludeConstructor
|
||||||
|
|
||||||
from argos.schemas.config import Config
|
from argos_monitoring.schemas.config import Config
|
||||||
|
|
||||||
|
|
||||||
def read_yaml_config(filename):
|
def read_yaml_config(filename):
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 160 KiB |
|
@ -1 +1 @@
|
||||||
../argos/config-example.yaml
|
../argos_monitoring/config-example.yaml
|
|
@ -8,9 +8,9 @@ After=network.target
|
||||||
User=argos
|
User=argos
|
||||||
EnvironmentFile=/etc/default/argos-agent
|
EnvironmentFile=/etc/default/argos-agent
|
||||||
WorkingDirectory=/opt/argos/
|
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 \
|
--wait-time $ARGOS_AGENT_WAIT_TIME \
|
||||||
--log-level $ARGOS_AGENT_LOGLEVEL
|
--log-level $ARGOS_AGENT_LOGLEVEL
|
||||||
SyslogIdentifier=argos-agent
|
SyslogIdentifier=argos-agent
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|
|
@ -9,14 +9,14 @@ PartOf=postgresql.service
|
||||||
User=argos
|
User=argos
|
||||||
WorkingDirectory=/opt/argos/
|
WorkingDirectory=/opt/argos/
|
||||||
EnvironmentFile=/etc/default/argos-server
|
EnvironmentFile=/etc/default/argos-server
|
||||||
ExecStartPre=/opt/argos/venv/bin/argos server migrate
|
ExecStartPre=/opt/argos/venv/bin/argos-monitoring server migrate
|
||||||
ExecStartPre=/opt/argos/venv/bin/argos server reload-config
|
ExecStartPre=/opt/argos/venv/bin/argos-monitoring server reload-config
|
||||||
ExecStart=/opt/argos/venv/bin/gunicorn "argos.server.main:get_application()" \
|
ExecStart=/opt/argos/venv/bin/gunicorn "argos_monitoring.server.main:get_application()" \
|
||||||
--workers $ARGOS_SERVER_WORKERS \
|
--workers $ARGOS_SERVER_WORKERS \
|
||||||
--worker-class uvicorn.workers.UvicornWorker \
|
--worker-class uvicorn.workers.UvicornWorker \
|
||||||
--bind $ARGOS_SERVER_SOCKET \
|
--bind $ARGOS_SERVER_SOCKET \
|
||||||
--forwarded-allow-ips $ARGOS_SERVER_FORWARDED_ALLOW_IPS
|
--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
|
SyslogIdentifier=argos-server
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|
46
docs/cli.md
46
docs/cli.md
|
@ -1,13 +1,13 @@
|
||||||
# Command-line interface
|
# Command-line interface
|
||||||
|
|
||||||
<!-- [[[cog
|
<!-- [[[cog
|
||||||
from argos.commands import cli
|
from argos_monitoring.commands import cli
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
def help(args):
|
def help(args):
|
||||||
title = "argos " + " ".join(args)
|
title = "argos-monitoring " + " ".join(args)
|
||||||
cog.out("\n```man\n")
|
cog.out("\n```man\n")
|
||||||
result = CliRunner().invoke(cli, args)
|
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(output)
|
||||||
cog.out("```\n\n")
|
cog.out("```\n\n")
|
||||||
]]] -->
|
]]] -->
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos [OPTIONS] COMMAND [ARGS]...
|
Usage: argos-monitoring [OPTIONS] COMMAND [ARGS]...
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help Show this message and exit.
|
--help Show this message and exit.
|
||||||
|
@ -41,11 +41,11 @@ Commands:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```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.
|
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
|
Alternatively, you can use the following environment variables to avoid
|
||||||
passing arguments to the agent on the command line:
|
passing arguments to the agent on the command line:
|
||||||
|
@ -71,7 +71,7 @@ Options:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server [OPTIONS] COMMAND [ARGS]...
|
Usage: argos-monitoring server [OPTIONS] COMMAND [ARGS]...
|
||||||
|
|
||||||
Commands for managing server, server’s configuration and users
|
Commands for managing server, server’s configuration and users
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ Commands:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server start [OPTIONS]
|
Usage: argos-monitoring server start [OPTIONS]
|
||||||
|
|
||||||
Starts the server (use only for testing or development!)
|
Starts the server (use only for testing or development!)
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ Options:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server migrate [OPTIONS]
|
Usage: argos-monitoring server migrate [OPTIONS]
|
||||||
|
|
||||||
Run database migrations
|
Run database migrations
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ Options:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server cleandb [OPTIONS]
|
Usage: argos-monitoring server cleandb [OPTIONS]
|
||||||
|
|
||||||
Clean the database (to run routinely)
|
Clean the database (to run routinely)
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ Options:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server cleandb [OPTIONS]
|
Usage: argos-monitoring server cleandb [OPTIONS]
|
||||||
|
|
||||||
Clean the database (to run routinely)
|
Clean the database (to run routinely)
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ Options:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```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
|
Read tasks’ configuration and add/delete tasks in database if needed
|
||||||
|
|
||||||
|
@ -232,12 +232,12 @@ Options:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server generate-config [OPTIONS]
|
Usage: argos-monitoring server generate-config [OPTIONS]
|
||||||
|
|
||||||
Output a self-documented example config file.
|
Output a self-documented example config file.
|
||||||
|
|
||||||
Redirect the output to a file to save it:
|
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:
|
Options:
|
||||||
--help Show this message and exit.
|
--help Show this message and exit.
|
||||||
|
@ -254,7 +254,7 @@ Options:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```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.
|
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
|
```man
|
||||||
Usage: argos server user [OPTIONS] COMMAND [ARGS]...
|
Usage: argos-monitoring server user [OPTIONS] COMMAND [ARGS]...
|
||||||
|
|
||||||
User management
|
User management
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ Commands:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server user add [OPTIONS]
|
Usage: argos-monitoring server user add [OPTIONS]
|
||||||
|
|
||||||
Add new user
|
Add new user
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ Options:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server user change-password [OPTIONS]
|
Usage: argos-monitoring server user change-password [OPTIONS]
|
||||||
|
|
||||||
Change user’s password
|
Change user’s password
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ Options:
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server user delete [OPTIONS]
|
Usage: argos-monitoring server user delete [OPTIONS]
|
||||||
|
|
||||||
Delete user
|
Delete user
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ Disabling a user prevents the user to login and access Argos’ web interface bu
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server user disable [OPTIONS]
|
Usage: argos-monitoring server user disable [OPTIONS]
|
||||||
|
|
||||||
Disable user
|
Disable user
|
||||||
|
|
||||||
|
@ -403,7 +403,7 @@ Obviously, the user needs to exists and to be disabled before using the command.
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server user enable [OPTIONS]
|
Usage: argos-monitoring server user enable [OPTIONS]
|
||||||
|
|
||||||
Enable user
|
Enable user
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@ Show all accounts, with their status (enabled or disabled).
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server user show [OPTIONS]
|
Usage: argos-monitoring server user show [OPTIONS]
|
||||||
|
|
||||||
List all users
|
List all users
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ You can verify that you have the right password for a user with the following co
|
||||||
.. ]]] -->
|
.. ]]] -->
|
||||||
|
|
||||||
```man
|
```man
|
||||||
Usage: argos server user verify-password [OPTIONS]
|
Usage: argos-monitoring server user verify-password [OPTIONS]
|
||||||
|
|
||||||
Test user’s password
|
Test user’s password
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
# pylint: disable-msg=invalid-name,redefined-builtin
|
# pylint: disable-msg=invalid-name,redefined-builtin
|
||||||
import argos
|
import argos
|
||||||
|
|
||||||
project = "Argos"
|
project = "Argos Panoptès"
|
||||||
copyright = "2023, Alexis Métaireau, Framasoft"
|
copyright = "2023, Alexis Métaireau, Framasoft"
|
||||||
author = "Alexis Métaireau, Framasoft"
|
author = "Alexis Métaireau, Framasoft"
|
||||||
release = argos.VERSION
|
release = argos_monitoring.VERSION
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
||||||
|
|
|
@ -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.
|
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
|
```{literalinclude} ../conf/config-example.yaml
|
||||||
---
|
---
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
- [Click](https://click.palletsprojects.com/) for the command-line interface;
|
- [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](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;
|
- [HTTPX](https://www.python-httpx.org/) is used to issue asynchronous requests in the agents;
|
||||||
- [Jinja](https://jinja.palletsprojects.com/) is handling the templating;
|
- [Jinja](https://jinja.palletsprojects.com/) is handling the templating;
|
||||||
- [Pydantic](https://pydantic.dev/) is useful to ensure the data matches our expectactions;
|
- [Pydantic](https://pydantic.dev/) is useful to ensure the data matches our expectactions;
|
||||||
|
|
|
@ -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.
|
you're done, you can create a new migration.
|
||||||
|
|
||||||
```bash
|
```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).
|
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).
|
||||||
|
|
|
@ -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.
|
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
|
caption: models.py
|
||||||
---
|
---
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## Creating a new check class
|
## 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.
|
You need to implement two methods, and specify the type of the data you want to check.
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ gotify:
|
||||||
Feel free to open an issue to discuss about your notification way or its configuration before coding!
|
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.
|
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:
|
For gotify, it’s:
|
||||||
```python
|
```python
|
||||||
|
@ -31,4 +31,4 @@ For gotify, we added this:
|
||||||
gotify: Optional[List[GotifyUrl]] = None
|
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.
|
||||||
|
|
|
@ -30,11 +30,11 @@ hatch version minor # or `hatch version major`, or `hatch version fix`
|
||||||
editor CHANGELOG.md
|
editor CHANGELOG.md
|
||||||
|
|
||||||
# Commit the change
|
# 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))"
|
git commit -m "🏷 — Bump version ($(hatch version))"
|
||||||
|
|
||||||
# Create a tag on the git repository and push it
|
# 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
|
# Build the project
|
||||||
hatch build --clean
|
hatch build --clean
|
||||||
|
@ -50,7 +50,7 @@ Use CHANGELOG.md content for that.
|
||||||
|
|
||||||
## Bumping the version number
|
## 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:
|
`hatch` provide commands to help with this:
|
||||||
|
|
||||||
```bash
|
```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
|
python -m venv /tmp/argos
|
||||||
source /tmp/argos/bin/activate
|
source /tmp/argos/bin/activate
|
||||||
pip install argos-monitoring
|
pip install argos-monitoring
|
||||||
argos version # should output the proper version
|
argos-monitoring version # should output the proper version
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using the test server
|
## Using the test server
|
||||||
|
|
|
@ -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:
|
The quickest way to get started is to generate the configuration file from argos and edit it:
|
||||||
|
|
||||||
```bash
|
```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).
|
You can read more about the configuration in the [configuration section](../configuration.md).
|
||||||
|
@ -74,7 +74,7 @@ chmod 700 /etc/argos
|
||||||
|
|
||||||
Then, as `argos`:
|
Then, as `argos`:
|
||||||
```bash
|
```bash
|
||||||
argos server generate-config > /etc/argos/config.yaml
|
argos-monitoring server generate-config > /etc/argos/config.yaml
|
||||||
chmod 600 /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:
|
Create the schema in the database with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
argos server migrate
|
argos-monitoring server migrate
|
||||||
```
|
```
|
||||||
|
|
||||||
## Inject tasks into the database
|
## 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:
|
Populate the database with the tasks:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
argos server reload-config
|
argos-monitoring server reload-config
|
||||||
```
|
```
|
||||||
|
|
||||||
## Generating a token
|
## 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:
|
You can generate an authentication token with the following command:
|
||||||
```bash
|
```bash
|
||||||
argos server generate-token
|
argos-monitoring server generate-token
|
||||||
```
|
```
|
||||||
|
|
||||||
Add the token in the configuration file, in the following setting:
|
Add the token in the configuration file, in the following setting:
|
||||||
|
@ -120,7 +120,7 @@ service:
|
||||||
Then you can start the server:
|
Then you can start the server:
|
||||||
|
|
||||||
```bash
|
```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.
|
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:
|
To start the server:
|
||||||
|
|
||||||
```bash
|
```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:
|
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`:
|
So, to start the server with 4 workers while listening to `127.0.0.1:8001`:
|
||||||
|
|
||||||
```bash
|
```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`.
|
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.
|
The only requirement is that the agent can reach the server through HTTP or HTTPS.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
argos agent http://localhost:8000 "auth-token"
|
argos-monitoring agent http://localhost:8000 "auth-token"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Cleaning the database
|
## 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:
|
Here is a crontab example, which will clean the db each hour:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Run the cleaning tasks every hour (at minute 7)
|
# Run the cleaning tasks every hour (at minute 7)
|
||||||
# Keeps 10 results per task, and remove tasks’ locks older than 1 hour
|
# 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
|
## 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:
|
Here is a crontab example, which will check the agents every 5 minutes:
|
||||||
|
|
||||||
```bash
|
```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`
|
||||||
|
|
|
@ -13,11 +13,11 @@ cd /tmp/argos
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
source venv/bin/activate
|
source venv/bin/activate
|
||||||
pip install argos-monitoring
|
pip install argos-monitoring
|
||||||
argos server generate-config |
|
argos-monitoring server generate-config |
|
||||||
sed -e "s@production@dev@" \
|
sed -e "s@production@dev@" \
|
||||||
-e "s@url: .postgresql.*@url: \"sqlite:////tmp/argos.db\"@" > argos-config.yaml
|
-e "s@url: .postgresql.*@url: \"sqlite:////tmp/argos.db\"@" > argos-config.yaml
|
||||||
argos server migrate
|
argos-monitoring server migrate
|
||||||
ARGOS_TOKEN=$(argos server generate-token)
|
ARGOS_TOKEN=$(argos-monitoring server generate-token)
|
||||||
sed -e "s@# - secret_token@- $ARGOS_TOKEN@" -i argos-config.yaml
|
sed -e "s@# - secret_token@- $ARGOS_TOKEN@" -i argos-config.yaml
|
||||||
echo "The agent token is $ARGOS_TOKEN"
|
echo "The agent token is $ARGOS_TOKEN"
|
||||||
```
|
```
|
||||||
|
@ -28,8 +28,8 @@ Add some real web sites to test.
|
||||||
Then:
|
Then:
|
||||||
|
|
||||||
```
|
```
|
||||||
argos server reload-config
|
argos-monitoring server reload-config
|
||||||
argos server start --host 0.0.0.0 --port 8000
|
argos-monitoring server start --host 0.0.0.0 --port 8000
|
||||||
```
|
```
|
||||||
|
|
||||||
In another terminal:
|
In another terminal:
|
||||||
|
@ -37,7 +37,7 @@ In another terminal:
|
||||||
```
|
```
|
||||||
cd /tmp/argos
|
cd /tmp/argos
|
||||||
source venv/bin/activate
|
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`.
|
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]"'
|
sudo -u argos bash -c 'source venv/bin/activate && pip install "argos-monitoring[gunicorn]"'
|
||||||
|
|
||||||
mkdir /etc/argos
|
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
|
cat <<EOF > /etc/default/argos-server
|
||||||
ARGOS_YAML_FILE="/etc/argos/config.yaml"
|
ARGOS_YAML_FILE="/etc/argos/config.yaml"
|
||||||
|
@ -86,14 +86,14 @@ PartOf=postgresql.service
|
||||||
User=argos
|
User=argos
|
||||||
WorkingDirectory=/opt/argos/
|
WorkingDirectory=/opt/argos/
|
||||||
EnvironmentFile=/etc/default/argos-server
|
EnvironmentFile=/etc/default/argos-server
|
||||||
ExecStartPre=/opt/argos/venv/bin/argos server migrate
|
ExecStartPre=/opt/argos/venv/bin/argos-monitoring server migrate
|
||||||
ExecStartPre=/opt/argos/venv/bin/argos server reload-config
|
ExecStartPre=/opt/argos/venv/bin/argos-monitoring server reload-config
|
||||||
ExecStart=/opt/argos/venv/bin/gunicorn "argos.server.main:get_application()" \\
|
ExecStart=/opt/argos/venv/bin/gunicorn "argos_monitoring.server.main:get_application()" \\
|
||||||
--workers \$ARGOS_SERVER_WORKERS \\
|
--workers \$ARGOS_SERVER_WORKERS \\
|
||||||
--worker-class uvicorn.workers.UvicornWorker \\
|
--worker-class uvicorn.workers.UvicornWorker \\
|
||||||
--bind \$ARGOS_SERVER_SOCKET \\
|
--bind \$ARGOS_SERVER_SOCKET \\
|
||||||
--forwarded-allow-ips \$ARGOS_SERVER_FORWARDED_ALLOW_IPS
|
--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
|
SyslogIdentifier=argos-server
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
@ -111,7 +111,7 @@ After=network.target
|
||||||
User=argos
|
User=argos
|
||||||
EnvironmentFile=/etc/default/argos-agent
|
EnvironmentFile=/etc/default/argos-agent
|
||||||
WorkingDirectory=/opt/argos/
|
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 \\
|
--wait-time \$ARGOS_AGENT_WAIT_TIME \\
|
||||||
--log-level \$ARGOS_AGENT_LOGLEVEL
|
--log-level \$ARGOS_AGENT_LOGLEVEL
|
||||||
SyslogIdentifier=argos-agent
|
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 :
|
Create a token for your agent :
|
||||||
|
|
||||||
```bash
|
```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.
|
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
|
```bash
|
||||||
cat <<EOF | crontab -u argos -
|
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-monitoring 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 watch-agents --time-without-agent 10
|
||||||
EOF
|
EOF
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -76,27 +76,27 @@ repository = "https://framagit.org/framasoft/framaspace/argos"
|
||||||
|
|
||||||
[tool.hatch.build.targets.sdist]
|
[tool.hatch.build.targets.sdist]
|
||||||
include = [
|
include = [
|
||||||
"/argos",
|
"/argos_monitoring",
|
||||||
"/docs",
|
"/docs",
|
||||||
"/tests",
|
"/tests",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.hatch.build.targets.wheel]
|
[tool.hatch.build.targets.wheel]
|
||||||
packages = ["argos"]
|
packages = ["argos_monitoring"]
|
||||||
|
|
||||||
[tool.hatch.version]
|
[tool.hatch.version]
|
||||||
path = "argos/__init__.py"
|
path = "argos_monitoring/__init__.py"
|
||||||
|
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
argos = "argos.commands:cli"
|
argos-monitoring = "argos_monitoring.commands:cli"
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
minversion = "6.0"
|
minversion = "6.0"
|
||||||
addopts = "-ra -q"
|
addopts = "-ra -q"
|
||||||
testpaths = [
|
testpaths = [
|
||||||
"tests",
|
"tests",
|
||||||
"argos"
|
"argos_monitoring"
|
||||||
]
|
]
|
||||||
pythonpath = "."
|
pythonpath = "."
|
||||||
filterwarnings = [
|
filterwarnings = [
|
||||||
|
|
|
@ -11,7 +11,7 @@ os.environ["ARGOS_YAML_FILE"] = "tests/config.yaml"
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def db() -> Session:
|
def db() -> Session:
|
||||||
from argos.server import models
|
from argos_monitoring.server import models
|
||||||
|
|
||||||
app = _create_app()
|
app = _create_app()
|
||||||
models.Base.metadata.create_all(bind=app.state.engine)
|
models.Base.metadata.create_all(bind=app.state.engine)
|
||||||
|
@ -21,7 +21,7 @@ def db() -> Session:
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def app() -> FastAPI:
|
def app() -> FastAPI:
|
||||||
from argos.server import models
|
from argos_monitoring.server import models
|
||||||
|
|
||||||
app = _create_app()
|
app = _create_app()
|
||||||
models.Base.metadata.create_all(bind=app.state.engine)
|
models.Base.metadata.create_all(bind=app.state.engine)
|
||||||
|
@ -38,7 +38,7 @@ def authorized_client(app):
|
||||||
|
|
||||||
|
|
||||||
def _create_app() -> FastAPI:
|
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,
|
get_application,
|
||||||
setup_database,
|
setup_database,
|
||||||
connect_to_db,
|
connect_to_db,
|
||||||
|
|
|
@ -3,9 +3,9 @@ import asyncio
|
||||||
import pytest
|
import pytest
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
|
||||||
from argos.schemas import AgentResult, SerializableException
|
from argos_monitoring.schemas import AgentResult, SerializableException
|
||||||
from argos.server import models
|
from argos_monitoring.server import models
|
||||||
from argos.server.queries import update_from_config
|
from argos_monitoring.server.queries import update_from_config
|
||||||
|
|
||||||
|
|
||||||
def test_read_tasks_requires_auth(app):
|
def test_read_tasks_requires_auth(app):
|
||||||
|
|
|
@ -5,8 +5,8 @@ from unittest.mock import MagicMock
|
||||||
import httpx
|
import httpx
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from argos.checks import SSLCertificateExpiration
|
from argos_monitoring.checks import SSLCertificateExpiration
|
||||||
from argos.schemas import Task
|
from argos_monitoring.schemas import Task
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
|
@ -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():
|
def test_response_failure_with_context():
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from click.testing import CliRunner
|
from click.testing import CliRunner
|
||||||
from argos.commands import (
|
from argos_monitoring.commands import (
|
||||||
add,
|
add,
|
||||||
verify_password,
|
verify_password,
|
||||||
change_password,
|
change_password,
|
||||||
|
|
|
@ -2,9 +2,9 @@ from datetime import datetime, timedelta
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from argos import schemas
|
from argos_monitoring import schemas
|
||||||
from argos.server import queries
|
from argos_monitoring.server import queries
|
||||||
from argos.server.models import Result, Task, User
|
from argos_monitoring.server.models import Result, Task, User
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from argos.schemas.config import SSL, WebsitePath
|
from argos_monitoring.schemas.config import SSL, WebsitePath
|
||||||
|
|
||||||
|
|
||||||
def test_ssl_duration_parsing():
|
def test_ssl_duration_parsing():
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import pytest
|
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():
|
def test_string_to_duration_days():
|
||||||
|
|
Loading…
Reference in a new issue