zabgrab.adapters.zabbix.api¶
Zabbix 7 JSON-RPC API client.
Classes
|
A client for one Zabbix server. |
- class zabgrab.adapters.zabbix.api.ZabbixAPI(transport)[source]¶
Bases:
objectA client for one Zabbix server.
Patterns passed to the search methods use the API’s wildcard search (
searchWildcardsEnabled): they match the whole value, ignoring case, and*matches any text.- Parameters:
transport (zabgrab.adapters.zabbix.transport.Transport) – Sends the requests (HTTP in normal use; a fake in tests).
- async call(method, params, *, auth=True)[source]¶
Call an API method and return its result.
- Parameters:
- Returns:
Any – The
resultof the response.- Raises:
AuthenticationFailed – If the server rejected the credentials.
ZabbixAPIError – For other API errors.
ConnectionFailed – If the server couldn’t be reached (raised by the transport).
- Return type:
- async check_version()[source]¶
Get the server’s version, checking zabgrab supports it.
- Returns:
str – The version, e.g.
"7.0.5".- Raises:
UnsupportedServer – If the server is older than
MIN_VERSION.- Return type:
- async login_token(token)[source]¶
Authenticate with an API token, checking it’s valid.
- Parameters:
token (str) – The API token.
- Raises:
AuthenticationFailed – If the server rejects the token.
- Return type:
None
- async login_password(username, password)[source]¶
Authenticate with a username and password.
The session is logged out again when the client is closed.
- Parameters:
- Raises:
AuthenticationFailed – If the server rejects them.
- Return type:
None
- async hosts(*, pattern=None, group=None, limit=None)[source]¶
Find hosts.
- Parameters:
- Returns:
list of Host – The hosts, sorted by visible name.
- Return type:
- async items(*, itemids=None, hostids=None, name=None, key=None, tag=None, limit=None)[source]¶
Find items on hosts (not templates) matching all of the given filters.
- Parameters:
itemids (sequence of int, optional) – Only these items, or items on these hosts. Empty matches nothing.
hostids (sequence of int, optional) – Only these items, or items on these hosts. Empty matches nothing.
name (str, optional) – Patterns for the item’s name and key.
key (str, optional) – Patterns for the item’s name and key.
tag (str, optional) –
"name"(the tag exists) or"name:value"(with exactly that value).limit (int, optional) – The most items to return.
- Returns:
list of Item – The items, sorted by name.
- Return type:
- async history(item, start, end)[source]¶
Get an item’s raw values.
- Parameters:
- Returns:
list of HistoryRow – The values, oldest first.
- Return type: