Control Package — pynag 0.8.5 documentation

### Navigation

- index
- modules |
- next |
- previous |
- pynag 0.8.5 documentation »
- The pynag module »

# Control Package

## `Control` Package

The Control module includes classes to control the Nagios service and the Command submodule wraps Nagios commands.

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: `object`

  Control the nagios daemon through python

      >>> from pynag.Control import daemon
      >>>
      >>> d = daemon()
      >>> d.restart()

  `SYSTEMD` = 3
  `SYSV_INIT_SCRIPT` = 1
  `SYSV_INIT_SERVICE` = 2
  `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

## Subpackages

- Command Package
  - `Command` Package
  - `autogenerated_commands` Module
  - `generate_external_command` Module

### Navigation

- index
- modules |
- next |
- previous |
- pynag 0.8.5 documentation »
- The pynag module »