icinga

Icinga module.

class spicerack.icinga.Icinga(icinga_host, *, config_file='/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.
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, reason, *, duration=datetime.timedelta(0, 14400))[source]

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

Parameters:
host_command(command, hosts, *args)[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, ClusterShell.NodeSet.NodeSet) -- an iterable with the list of hostnames to iterate the command for.
  • *args -- optional positional arguments to pass to the command.
hosts_downtimed(hosts, reason, *, duration=datetime.timedelta(0, 14400), remove_on_error=False)[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.
remove_downtime(hosts)[source]

Remove a downtime from a set of hosts.

Parameters:hosts (list, ClusterShell.NodeSet.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.