icinga

Icinga module.

class spicerack.icinga.Icinga(icinga_host: spicerack.remote.RemoteHosts, *, config_file: str = '/etc/icinga/icinga.cfg')[source]

Bases: object

Class to interact with the Icinga server.

Initialize the instance.

Parameters

icinga_host (spicerack.remote.RemoteHosts) -- the RemoteHosts instance for the Icinga server.

property command_file

Getter for the command_file property.

Returns

the path of the Icinga command file.

Return type

str

Raises

spicerack.icinga.IcingaError -- if unable to get the command file path.

downtime_hosts(hosts: Union[Sequence[str], ClusterShell.NodeSet.NodeSet], reason: spicerack.administrative.Reason, *, duration: datetime.timedelta = datetime.timedelta(0, 14400)) → None[source]

Downtime hosts on the Icinga server for the given time with a message.

Parameters
host_command(command: str, hosts: Union[Sequence[str], ClusterShell.NodeSet.NodeSet], *args) → None[source]

Execute a host-specific Icinga command on the Icinga server for a set of hosts.

Parameters
  • command (str) -- the Icinga command to execute.

  • hosts (list, cumin.NodeSet) -- an iterable with the list of hostnames to iterate the command for.

  • *args (str) -- optional positional arguments to pass to the command.

hosts_downtimed(hosts: Sequence[Union[str, ClusterShell.NodeSet.NodeSet]], reason: spicerack.administrative.Reason, *, duration: datetime.timedelta = datetime.timedelta(0, 14400), remove_on_error: bool = False) → Iterator[None][source]

Context manager to perform actions while the hosts are downtimed on Icinga.

Parameters
  • hosts (list, cumin.NodeSet) -- an iterable with the list of hostnames to downtime.

  • reason (spicerack.administrative.Reason) -- the reason to set for the downtime on the Icinga server.

  • duration (datetime.timedelta, optional) -- the length of the downtime period.

  • remove_on_error -- should the downtime be removed even if an exception was raised.

Yields

None -- it just yields control to the caller once Icinga has been downtimed and deletes the downtime once getting back the control.

recheck_all_services(hosts: Union[Sequence[str], ClusterShell.NodeSet.NodeSet]) → None[source]

Force recheck of all services associated with a set of hosts

Parameters

hosts (list, cumin.NodeSet) -- an iterable with the list of hostnames to iterate the command for.

remove_downtime(hosts: Union[Sequence[str], ClusterShell.NodeSet.NodeSet]) → None[source]

Remove a downtime from a set of hosts.

Parameters

hosts (list, cumin.NodeSet) -- an iterable with the list of hostnames to iterate the command for.

exception spicerack.icinga.IcingaError[source]

Bases: spicerack.exceptions.SpicerackError

Custom exception class for errors of this module.