Skip to main content

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.

Example

Install Watchpost in your project:

pip install 'watchpost[cli]'

You can now write a basic Watchpost application like this:

import urllib.error
import urllib.request

from watchpost import EnvironmentRegistry, Watchpost, check, crit, ok

ENVIRONMENTS = EnvironmentRegistry()
PRODUCTION = ENVIRONMENTS.new("production")


@check(  # (1)
    name="example.com HTTP status",
    service_labels={},
    environments=[PRODUCTION],
    cache_for="5m",
)
async def example_com_http_status():
    try:
        with urllib.request.urlopen("https://www.example.com") as response:
            status_code = response.status
    except urllib.error.HTTPError as e:
        status_code = e.code

    if status_code != 200:
        return crit(  # (2)
            "example.com returned an error",
            details=f"Expected status: 200\nActual status: {status_code}\n",
        )

    return ok("example.com is up")  # (3)


app = Watchpost(
    checks=[
        example_com_http_status,  # (4)
    ],
    execution_environment=PRODUCTION,
)
  1. Use the @check decorator 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.
  2. If the check fails, return crit(...). The details will be shown in the Checkmk service to help troubleshooting.

  3. If everything is fine, return ok(...).

  4. 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
    • @check decorator, 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
  • 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

Documentation

See ./docs for more information.

License

Watchpost is licensed under the Apache License, Version 2.0, (see LICENSE or https://www.apache.org/licenses/LICENSE-2.0).

Watchpost internally makes use of various open-source projects. You can find a full list of these projects and their licenses in THIRD_PARTY_LICENSES.md.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Watchpost by you, as defined in the Apache-2.0 license, shall be licensed under the Apache License, Version 2.0, without any additional terms or conditions.

We make use of Lefthook for pre-commit and pre-push hooks that verify your code is valid. To set up the hooks, run uv run lefthook install.

Affiliation

This project has no official affiliation with Checkmk GmbH or any of its affiliates. "Checkmk" is a trademark of Checkmk GmbH.

History

This project is a fork of takkt-ag/watchpost.

Metadata

Release files for watchpost 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for watchpost 0.1.5
File Size Uploaded
watchpost-0.1.5.tar.gz 53.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for watchpost 0.1.5
File Interpreter ABI Platform
watchpost-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 120.3 kB

Release files / watchpost-0.1.5.tar.gz

Download URL watchpost-0.1.5.tar.gz
Size 53.4 kB
Tags Source
SHA-256 checksum
How to use checksums
45ef3f0b9b2770488d9fbefde2056e54e46a6f4ace789c8d9c79ed3aa4f46b37
BLAKE2b-256 checksum
How to use checksums
41f8dfd0102878ecb54e4487751ef6ecb43ac647aa9f59bf98066ee789715070
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 23, 2026.

Transparency log

Release files / watchpost-0.1.5-py3-none-any.whl

Download URL watchpost-0.1.5-py3-none-any.whl
Size 66.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7cfe4025c588fdbf44f8c25ba7418bcdefae317a8e87f3d2753508967e00d3b
BLAKE2b-256 checksum
How to use checksums
1be25f29a65ed68038cf049ccfbcfb0ddb0a81d5bcd5451fe591e44456e016a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page