None
SERVICE_STATUS => contains a mapping of OK, WARNING, 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
- servicename
- hostname
Example:
from icinga2 import Icinga2API
hostname = "test.localdomain"
servicename = "pingv4"
data = {
"templates": [ "generic-service" ],
"attrs": {
"check_command": "ping4",
"check_interval": 10,
"retry_interval": 30
}
}
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.add(servicename=servicename, hostname=hostname, data)
It returns a dictionary with the HTTP Returncode and other data that icinga2 provides.
Parameters:
- name
Example:
from icinga2 import Icinga2API
hostname = "test.localdomain"
servicename = "pingv4"
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.delete(hostname, servicename)
It returns a dictionary with the HTTP Returncode and other data that icinga2 provides.
Parameters:
- name
Example:
from icinga2 import Icinga2API
hostname = "test.localdomain"
servicename = "pingv4"
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.list()
Returns a list of all services
api.services.list(servicename=servicename)
Returns a dictionary of with a list of all services by that name, key is their hostname
api.services.list(hostname=hostname)
returns a list of all services for this hostname
Parameters:
- name
Example:
from icinga2 import Icinga2API
name = "test.localdomain"
servicename = "pingv4"
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.exists(servicename=servicename)
Returns true or false depending on the service existing
api.hosts.exists(hostname=hostname, servicename=servicename)
Returns true or false depending on the service existing for that host
Parameters:
- attrs
- _filter
- joins
Example:
from icinga2 import Icinga2API
attrs = ['name', 'state', 'last_check']
_filter = ['host.name == test.localdomain', 'service.name == ping4']
joins = ['host.name']
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.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.services.unhandled_list()
Returns a list of all unhandled service problems
Parameters:
- None
Example:
from icinga2 import Icinga2API
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.problem_count()
Returns the count of all services, 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.services.problem_count()
Returns the count of all services, that have a problem and are either acknowledged nor in a downtime.
Parameters:
- None
Example:
from icinga2 import Icinga2API
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.warning_count()
Returns the count of all services, that are in status warning
Parameters:
- None
Example:
from icinga2 import Icinga2API
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.warning_handled_count()
Returns the count of all services, that are in state warning and either acknowledged or in a downtime
Parameters:
- None
Example:
from icinga2 import Icinga2API
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.critical_count()
Returns the count of all services, that are in status critical
Parameters:
- None
Example:
from icinga2 import Icinga2API
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.critical_handled_count()
Returns the count of all services, that are in state critical and either acknowledged or in a downtime
Parameters:
- None
Example:
from icinga2 import Icinga2API
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.unknown_count()
Returns the count of all services, that are in state unknown
Parameters:
- None
Example:
from icinga2 import Icinga2API
api = Icinga2API(username="root", password="icinga2", url="https://localhost:5665")
api.services.unknown_handled_count()
Returns the count of all services, that are in state unknown and either acknowledged or in a downtime