API Reference¶
Core Library¶
Domain Model¶
Domain Models¶
Domain models for checks, results, and services.
- class nyxmon.domain.models.Check(*, check_id: int, service_id: int, name: str = '', check_type: str, url: str, check_interval: int = 300, next_check_time: int = 0, processing_started_at: int = 0, status: Literal['idle', 'processing'] = 'idle', disabled: bool = False, data: dict)[source]¶
Bases:
object
- class nyxmon.domain.models.CheckResult(check: Check, result: Result)[source]¶
Bases:
object- property passed: bool¶
- property should_notify: bool¶
- class nyxmon.domain.models.CheckStatus[source]¶
Bases:
object- IDLE: Literal['idle'] = 'idle'¶
- PROCESSING: Literal['processing'] = 'processing'¶
- class nyxmon.domain.models.CheckType[source]¶
Bases:
object- DNS: Literal['dns'] = 'dns'¶
- HTTP: Literal['http'] = 'http'¶
- IMAP: Literal['imap'] = 'imap'¶
- JSON_HTTP: Literal['json-http'] = 'json-http'¶
- JSON_METRICS: Literal['json-metrics'] = 'json-metrics'¶
- PING: Literal['ping'] = 'ping'¶
- SMTP: Literal['smtp'] = 'smtp'¶
- TCP: Literal['tcp'] = 'tcp'¶
- class nyxmon.domain.models.Result(*, result_id: int | None = None, check_id: int, status: Literal['ok', 'warning', 'error'], data: dict)[source]¶
Bases:
object
- class nyxmon.domain.models.ResultStatus[source]¶
Bases:
object- ERROR: Literal['error'] = 'error'¶
- OK: Literal['ok'] = 'ok'¶
- WARNING: Literal['warning'] = 'warning'¶
Message Bus¶
Central event dispatcher for commands and events.
- class nyxmon.service_layer.message_bus.MessageBus(uow: UnitOfWork, event_handlers: dict[type[Event], list[Callable]], command_handlers: dict[type[Command], Callable])[source]¶
Bases:
objectThis is a simple implementation of a message bus that can handle messages of type Event and Command using event_handlers and command_handlers. It uses a UnitOfWork to collect new events.
Check Executors¶
HTTP Check Executor¶
HTTP check executor implementation.
- class nyxmon.adapters.runner.executors.http_executor.HttpCheckExecutor(client: AsyncClient | None = None)[source]¶
Bases:
objectExecutor for HTTP checks.
Performs HTTP requests and validates responses. Can accept an external client or create its own.
DNS Check Executor¶
DNS check executor implementation.
- class nyxmon.adapters.runner.executors.dns_executor.DnsCheckExecutor(resolver: DnsResolver | None = None)[source]¶
Bases:
objectExecutor for DNS checks.
Performs DNS queries and validates results against expected IPs.
- class nyxmon.adapters.runner.executors.dns_executor.DnsResolver(*args, **kwargs)[source]¶
Bases:
ProtocolProtocol describing the resolver interface expected by the executor.
- async query(domain: str, config: DnsCheckConfig) DnsResolverResult[source]¶
Resolve
domainaccording toconfigand return structured data.
- class nyxmon.adapters.runner.executors.dns_executor.DnsResolverResult(records: List[str], metadata: dict[str, Any])[source]¶
Bases:
objectStructured result returned by DNS resolvers.
- metadata: dict[str, Any]¶
- records: List[str]¶
- class nyxmon.adapters.runner.executors.dns_executor.DnspythonResolver[source]¶
Bases:
objectResolver implementation backed by dnspython.
- async query(domain: str, config: DnsCheckConfig) DnsResolverResult[source]¶
Repository Interfaces¶
- class nyxmon.adapters.repositories.interface.CheckRepository(*args, **kwargs)[source]¶
Bases:
ProtocolA repository interface for storing and retrieving checks.
- seen: set¶
- class nyxmon.adapters.repositories.interface.RepositoryStore(*args, **kwargs)[source]¶
Bases:
ProtocolA protocol for a collection of repositories.
- checks: CheckRepository¶
- list() List[ResultRepository | CheckRepository | ServiceRepository][source]¶
Get a list of all repositories.
- results: ResultRepository¶
- services: ServiceRepository¶
- class nyxmon.adapters.repositories.interface.ResultRepository(*args, **kwargs)[source]¶
Bases:
ProtocolA repository interface for storing and retrieving results.
Runner¶
Async Check Runner¶
Notifications¶
- class nyxmon.adapters.notification.AsyncTelegramNotifier(token: str | None = None, chat_id: str | None = None)[source]¶
Bases:
Notifier- async async_notify_check_failed(check: Check, result: Result) None[source]¶
Notify about a failed check asynchronously.
- async async_notify_service_status_changed(service: Service, status: str) None[source]¶
Notify about a service status change asynchronously.
- async async_send(text: str, high_priority: bool = False) None[source]¶
Send a message via Telegram asynchronously.
- static escape_markdown_v2(text: str) str[source]¶
Escape special characters for Telegram’s MarkdownV2 format.
- class nyxmon.adapters.notification.LoggingNotifier(*args, **kwargs)[source]¶
Bases:
NotifierA simple notifier that logs messages to the console.