Control Package¶
Control Package¶
The Control module includes classes to control the Nagios service and the Command submodule wraps Nagios commands.
-
exception
pynag.Control.ControlError(message, errorcode=None, errorstring=None, *args, **kwargs)¶ Bases:
pynag.errors.PynagErrorBase class for all errors in this module.
-
class
pynag.Control.daemon(nagios_bin='/usr/bin/nagios', nagios_cfg='/etc/nagios/nagios.cfg', nagios_init=None, sudo=True, shell=None, service_name='nagios', nagios_config=None)¶ Bases:
objectControl the nagios daemon through python
>>> from pynag.Control import daemon >>> >>> d = daemon() >>> d.restart()
-
SYSTEMD= 3¶
-
SYSV_INIT_SCRIPT= 1¶
-
SYSV_INIT_SERVICE= 2¶
-
init_d_path= '/etc/init.d'¶
-
reload()¶ Reloads Nagios.
Returns: Return code of the reload command ran by pynag.Utils.runCommand() Return type: int
-
restart()¶ Restarts Nagios via it’s init script.
Returns: Return code of the restart command ran by pynag.Utils.runCommand() Return type: int
-
running()¶ Checks if the daemon is running
Returns: Whether or not the daemon is running Return type: bool
-
start()¶ Start the Nagios service.
Returns: Return code of the start command ran by pynag.Utils.runCommand() Return type: int
-
status()¶ Obtain the status of the Nagios service.
Returns: Return code of the status command ran by pynag.Utils.runCommand() Return type: int
-
stop()¶ Stop the Nagios service.
Returns: Return code of the stop command ran by pynag.Utils.runCommand() Return type: int
-
systemd_service_path= '/usr/lib/systemd/system'¶
-
verify_config()¶ Run nagios -v config_file to verify that the conf is working
Returns: True – if pynag.Utils.runCommand() returns 0, else None
-