joonty / systemd_mon

Monitor for systemd to alert failed services
MIT License
106 stars 28 forks source link

Support oneshot type services #3

Closed tylerjl closed 8 years ago

tylerjl commented 9 years ago

This permits the monitor to correctly watch Type=oneshot .service units that run on a schedule (using timer units) much like a cron job. Normal execution of a oneshot job sends an "info" message, failures are captured, and recoveries are detected the same way as persistent services are.

Note that because of the way that systemd thinks about "loaded" units, oneshot services are not loaded (and thus not able to be queried with GetUnit()) unless systemd has a reason to load them, for example, as a dependency for a timer. As long as the unit is "loaded" by systemd, the daemon can properly bootstrap the DBusUnit objects that it looks for as a result of their presence in the config file.

This also includes a few little to_s additions and fixes a small bug in == in the StateValue class.

Fixes #2

joonty commented 9 years ago

Hi @tylerjl, sorry it's been a while with this open - I've been meaning to test it properly but need to set up an environment to do so. I'm going to create a Vagrantfile for development, and as soon as I do I'll test your code and merge it in.

Thanks a lot for your great contribution!

joonty commented 8 years ago

Thanks a lot!