Watchpost – code-driven monitoring checks for Checkmk
Watchpost is a small framework for writing monitoring checks as Python code and integrating them with Checkmk. It helps you configure checks through a simple function decorator, handles running checks across and against multiple environments, and supports you in gathering data from external systems.
Affiliation: This project has no official affiliation with Checkmk GmbH or any of its affiliates. "Checkmk" is a trademark of Checkmk GmbH.
Example
Install Watchpost in your project:
You can now write a basic Watchpost application like this:
-
Use the
@checkdecorator to define your check:- A human-friendly name that will appear as the service name in Checkmk.
- Optional service labels to attach to the Checkmk service.
- The environments this check targets.
- A cache duration that controls how long a result is kept before the check runs again.
-
If the check fails, return
crit(...). The details will be shown in the Checkmk service to help troubleshooting. - If everything is fine, return
ok(...). - Register the check with the application.
Assuming this is saved as example.py, you can run it locally as such using the watchpost CLI:
$ watchpost --app example:app run-checks
Check Execution Results
┏━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓
┃ State ┃ Environment ┃ Service Name ┃ Summary ┃
┡━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩
│ OK │ production │ example.com HTTP status │ example.com is up │
└───────┴─────────────┴─────────────────────────┴───────────────────┘
The Checkmk integration makes use of HTTP to retrieve the check results from the Watchpost application. To support this, Watchpost is a valid ASGI web application which you can run with any ASGI server, for example uvicorn:
$ pip install uvicorn
$ uvicorn example:app
INFO: Started server process [12345]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Capabilities at a glance
- Checks and results
@checkdecorator, multiple result modes (single, multiple, yielded, builder)- Result helpers:
ok,warn,crit,unknown, metrics, thresholds
- Environments and scheduling
- Target vs. execution environments, pluggable scheduling strategies with validation
- Datasources
- Simple base class (
Datasource) and factory pattern to share configuration
- Simple base class (
- Execution and streaming
- Key‑aware executor, error aggregation, Checkmk output generation
- Caching
- In‑memory, disk, and optional Redis backends; memoization helper
- ASGI / HTTP
- Starlette app; routes:
/,/healthcheck,/executor/statistics,/executor/errored
- Starlette app; routes:
Next steps
- Try the quickstart guide.
- See the full API reference.