-
Notifications
You must be signed in to change notification settings - Fork 2
Systemd Monitor
Linux only. On any other OS, passing
--systemdprints a warning and the flag is ignored.
When enabled with --systemd, Knightwatch polls systemd over D-Bus every second and exposes unit state via the /systemd family of endpoints. It also emits unit change events to the Telegram bot and webhook dispatcher.
knightwatch --pid <PID> --systemd| Endpoint | Description |
|---|---|
GET /api/systemd |
Full snapshot — all units with counts |
GET /api/unit/<unit_name> |
Single unit by name (e.g. nginx.service), or 404
|
GET /api/units/<unit_state> |
All units matching an active state (active, failed, etc.) |
GET /api/failed_units |
Shorthand for all units in the failed state |
When the server is started with --allow-systemd-commands, the following write endpoints become available.
Authentication required. All systemd command endpoints always require authentication, regardless of whether
--enable-authis set.
knightwatch --systemd --allow-systemd-commands| Endpoint | Description |
|---|---|
POST /api/systemd/poll/pause |
Pause the polling loop |
POST /api/systemd/poll/resume |
Resume the polling loop |
POST /api/systemd/poll/interval |
Change the polling interval |
Pause snapshot collection (the tracker still responds to queries):
POST /api/systemd/poll/pauseResume at the current interval:
POST /api/systemd/poll/resumeChange the polling interval (takes effect immediately):
POST /api/systemd/poll/interval
Content-Type: application/json
{ "interval_ms": 2000 }| Event | Description | Key data fields |
|---|---|---|
systemd.initial_snapshot |
First unit snapshot after startup |
timestamp, unit_count, failed_count, active_count, inactive_count
|
systemd.tick |
Periodic unit snapshot |
timestamp, unit_count, failed_count, active_count, inactive_count
|
systemd.unit_failed |
A unit transitioned to failed
|
unit_name, previous_state
|
systemd.unit_recovered |
A previously failed unit recovered | unit_name |
systemd.unit_appeared |
A new unit became visible |
unit_name, active_state, sub_state, description
|
systemd.unit_disappeared |
A unit is no longer present | unit_name |
When both --systemd and --telegram are enabled, the bot sends alerts for:
- 🔴 Unit failed — a unit transitioned to
failed - 🟢 Unit recovered — a previously failed unit is active again
- 🆕 Unit appeared — a new unit became visible to systemd
- 💨 Unit disappeared — a tracked unit is no longer present