Skip to content

systemd service over SSH (ssh_systemd) ​

Asks systemd, over SSH, for the state of one unit. A unit that is not active, or that has failed, is Down. For a unit that must be stopped, set expect_active to false and the reverse holds.

Channels ​

KeyNameUnitDefault limits
stateUnit statenonevalue map: 0 inactive, 1 active, 2 activating (warning), 3 deactivating (warning), 4 failed (down), 5 reloading, 6 other

Parameters ​

ParameterDefaultMeaning
unitrequiredThe unit, for example nginx.service or nginx. A name without a type is a service. Letters, digits and : _ . @ - \ only, at most 200 characters.
expect_activetrueTrue when the unit must be active. False when it must be stopped.
port22TCP port of the SSH server.

Suggested interval: 60 seconds. Credential: SSH.

A unit that does not exist is Down with the message <unit> does not exist on the target.

Discovery ​

On a Linux host that accepts the SSH credential, discovery lists the running services that are also enabled and proposes a sensor for each that is on a short list of well-known ones: SSH, web servers (nginx, Apache, Caddy, HAProxy), databases (PostgreSQL, MariaDB, MySQL, Redis, Valkey, MongoDB), Docker and containerd, DNS (named, bind9, Unbound, dnsmasq), time (chrony, ntpd), mail (Postfix, Dovecot), Samba, cron, snmpd, fail2ban and a few others, at most eight per host. The login manager, the journal and the dozens of other units on a host are left alone on purpose. Add any other service by hand.

On the target ​

The command run is env LC_ALL=C systemctl show --no-pager --property=LoadState,ActiveState,SubState -- '<unit>'. systemctl show only reads, and needs no privileges. The unit name is validated against the characters systemd allows and then single-quoted; -- ends the options so a name cannot be taken for one. See Linux over SSH.

Failures ​

MessageMeaning
systemctl is not installed on the target, so it does not run systemd ... (kind protocol)Alpine and other OpenRC or BusyBox systems have no systemctl. Use the process sensor.
systemctl printed no unit state (is the target a systemd host?), systemctl failed on the target (exit status N): ... (kind protocol)systemd is not running (a container without it), or no D-Bus for this account.
SSH errorsAs for ssh_disk.

AGPL-3.0-only