None
HOST_STATUS => contains a mapping of DOWN, CRITICAL, UNKNOWN to their numerical representations
The constructor sets the client object, as well as a logger for debugging and a filter for determining which URI the client should use.
Parameters:
- data
Example:
from icinga2 import Icinga2API
data = {
"name": "test.localdomain"
"template": [ "generic-host" ],
"attrs": {
"name": "testserver1",
"address": "127.0.0.1",
"check_command": "hostalive"
}
}
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.hosts.add(data)
It returns a dictionary with the HTTP Returncode and other data that icinga2 provides.
Parameters:
- name
Example:
from icinga2 import Icinga2API
name = "test.localdomain"
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.hosts.delete(name)
It returns a dictionary with the HTTP Returncode and other data that icinga2 provides.
Parameters:
- name
Example:
from icinga2 import Icinga2API
name = "test.localdomain"
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.hosts.list()
Returns a list of all hostnames
api.hosts.list(name)
returns a list of all hostnames that match the name
Parameters:
- name
Example:
from icinga2 import Icinga2API
name = "test.localdomain"
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.hosts.exists(name)
Returns true or false depending on the hosts existence
Parameters:
- attrs
- _filter
- joins
Example:
from icinga2 import Icinga2API
attrs = ['name', 'state', 'last_check']
_filter = ['host.name == test.localdomain', 'service.name == ping4']
joins = ['service.name']
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.hosts.objects(attrs=attrs, _filter=_filter, joins=joins)
Returns a list of all object, with their attributes, matching the _filter, with addition of the field defined in joins
Parameters:
- None
Example:
from icinga2 import Icinga2API
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.hosts.problem_count()
Returns the count of all Hosts, that have a problem and are neither acknowledged nor in a downtime.
Parameters:
- None
Example:
from icinga2 import Icinga2API
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.hosts.problem_list()
Returns a dictionary where the hostnames are keys and contain their severity as a value
WARNING: Internal method, do not use
This method is used by problem_list to accurately calculate the severity. Calculation is derived from Origin
Parameters:
- attrs
Example:
host_problems[host['name']] = self.host_severity(host['attrs'])