[systemd-devel] Monitoring whether all dependencies of a target are active

Reto Kaiser reto at cargomedia.ch
Fri Aug 26 12:12:49 UTC 2016


Yes I was thinking to use "OnFailure".
But I want to also detect stopped units, in case a program or a person
stops a unit and forgets about it. That metric should tell me if all
my "important units" are active or not.

I can live with iterating over the output of "list-dependencies". But
since its output is not meant to be read by machines, I thought maybe
there's a more machine-readable API.

Regards,
 Reto


> Message: 1
> Date: Thu, 25 Aug 2016 21:31:15 -0400
> From: Chris Morin <chris.morin2 at gmail.com>
> To: systemd-devel at lists.freedesktop.org
> Subject: Re: [systemd-devel] Monitoring whether all dependencies of a
>         target  are active
> Message-ID:
>         <CABPcQ3YVN2XOTYFtL1TQ8j-y6N0pCR5MS9UTBDpB2or3sx7neA at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> >
> > We just migrated to Systemd and we love it!
> >
> > Now I'm looking for a way to monitor if all the "important units" of my
> > system are running or not.
> > My plan is to create a target that "wants" all those important units.
> > Then I'll just need to check that the dependencies of those units
> > are active. If there are non-active units for 5 minutes or more
> > I'll trigger an alert.
> >
> > Do you think that's a good way to check the healthiness of my units, or is
> > there a better way?
>
> You might want to use the OnFailure option in the unit files you want
> to monitor instead instead of using a target and wants.
> https://www.freedesktop.org/software/systemd/man/systemd.unit.html#OnFailure=
>
> Whatever action would have been taken by your polling script could
> just be done in the service specified in the OnFailure option.


More information about the systemd-devel mailing list