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.
config_file (str, optional) -- the path to the Icinga main configuration file.
-
property
command_file
¶ Getter for the command_file property.
- Returns
the path of the Icinga command file.
- Return type
- 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
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.
-
host_command
(command: str, hosts: Union[Sequence[str], ClusterShell.NodeSet.NodeSet], *args: str) → None[source]¶ Execute a host-specific Icinga command on the Icinga server for a set of hosts.
-
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.
-
exception
spicerack.icinga.
IcingaError
[source]¶ Bases:
spicerack.exceptions.SpicerackError
Custom exception class for errors of this module.