You are not logged in.
I know how to get notified when some particular unit fails. But what if I need to monitor the status of the entire system? Putting OnFailure= into each and every unit file is not an option, of course. Yet, I didn't find anything about systemd that could trigger an action on the failuer of any unit. For sure, I can make up a script that checks systemctl status every minute or so, but doesn't systemd provide a cleaner solution similar to OnFailure for individual units?
Last edited by Galicarnax (2022-12-06 17:58:57)
Offline
Not tested: But you could group all desired services in a target and then monitor that target unit.
?לאן אתה רוצה ללכת היום
Offline
Not tested: But you could group all desired services in a target and then monitor that target unit.
As far as I understand, that still would require keeping the list of all desired services (and by the way, I'm interested not only in failed services but other units such as mounts as well).
E.g., if I add another unit, I would have to remeber to add it to the list. Not a big improvement over adding OnFailure= to all units
Offline
Depending on whether there are failed units or not, this returns a success or a failure status code:
systectl status --failed &>/dev/null
or
systemctl is-failed --quiet '*'
You may put that in a timer and produce notifications upon a positive detection.
Sometimes I seem a bit harsh — don’t get offended too easily!
Offline