Systemd unit support

Issue #27 on hold
Wout Mertens created an issue

With just about every distribution out there starting to support systemd, it would be great if monit had support for monitoring units.

I would love to be able to tell monit to watch all/a subset of the enabled units and get metrics and control into m/monit. Systemd has support for getting metrics via the cgroup each service unit runs in, so that's great too...

Comments (7)

  1. Wout Mertens reporter

    M/Monit offers a nice unified view of all my hosts, including history and alerting.

    Systemd is good at keeping the system going and monit is good at monitoring service health.

  2. Sebastiaan Lokhorst

    Is there any update on this? It would be much appreciated. Something like check systemd apache with unit httpd.service would make it super easy to set up things, as virtually all Linux distributions come with systemd scripts for all services.

    I imagine it would be relatively easy to implement this: you can just wrap the systemctl {start,stop,is-active,is-failed} <unit> command.

  3. Tildeslash repo owner

    @lonaowna We're sorry we're currently busy with other features, the idea is interesting though and we may implement it in the future.

  4. Maksym Tiurin

    It would be great to have native systemd support in monit.

    There are few reasons why it’s needed and why standard pid/procmatch don’t help:

    1. Daemons managed by systemd rarely use PID files
    2. Most daemons use systemd “notify” type and notify systemd when daemon is up and running (just the existence of a running process is not enough)
    3. Systemd supports template unit files and using one template unit you can run multiple processes (like workers) with exactly the same command line. Monit procmatch finds first process and can monitor only one process.

  5. windware

    I agree monit needs systemd unit support.

    As I have been bugging several developers of other daemons on how to effectively create PID files, it’s increasingly getting harder to have PID file generated for like rspamd and caddy.

    Add `--pidfile` to the systemd unit file in the official package (caddy)

    PID file no longer gets created (rspamd)

    It’s mainly because the units start with unprivileged user and thus cannot write to /var/run or PIDFile= option in the unit file doesn’t seem to work for other than Type=forking or that PrivateTmp is enabled in the unit file and monit cannot reliably find where the PID file is under randomly generated directory by systemd in /tmp.

    If monit can support finding the PID through systemd by specifying the unit name in the config, it would greatly improve the usability against several daemons with something along the line of CHECK PROCESS caddy UNIT caddy.service.

    From systemd, you can take the PID of the process without a PID file with systemctl show --property MainPID caddy.service.

  6. Log in to comment