pynag/pynag — pull request #132 by tomas-edwardsson (2014-04-06 22:05:18+00:00)
Title: Systemd support and nagios_init deprecation

Systemd based systems now function correctly and daemon assumes use of
service_name instead of nagios_init. The main rationale for the change is
how to query if the nagios service is running. "service nagios status" is pretty
expensive so what daemon does is lookup pid file if nagios_init or
service is used but "systemctl is-active nagios" on systemd based
systems.

Added a bunch of tests for the new and old functionality.

Switch was also made from internal subprocess.Popen calls to use the
pynag.Utils.runCommand which is easier to mock from a testing
standpoint.

sudo use in nagios_init is also deprecated and is a flag now, sudo=True
when creating a new daemon() instance.

All calls now populate self.stderr and self.stdout which calling
programs can utilize to determine why something broke.

New methods, start and stop.

The prefered way to use daemon after this change is
```
>>> from pynag.Control import daemon

>>> d = daemon(
... service_name="icinga",
... nagios_bin="/usr/sbin/nagios",
... nagios_cfg="/etc/nagios/nagios.cfg")

>>> d.verify_config()
True
>>> d.stdout
'Output from command'
```