zabgrab.adapters.zabbix¶
Zabbix JSON-RPC API client.
- class zabgrab.adapters.zabbix.HttpTransport(url, *, verify_ssl=True, timeout=30.0)[source]¶
Bases:
objectTransport over HTTP(S) using aiohttp.
Network problems are raised as
ConnectionFailedwith a hint.- Parameters:
- async post(body, headers)[source]¶
Send a request body and return the decoded response.
- Parameters:
- Returns:
Any – The decoded JSON response.
- Raises:
Redirected – If the endpoint redirects elsewhere.
ConnectionFailed – If the server can’t be reached or doesn’t respond like Zabbix.
- Return type:
- class zabgrab.adapters.zabbix.Transport(*args, **kwargs)[source]¶
Bases:
ProtocolSends JSON-RPC request bodies and returns decoded responses.
- class zabgrab.adapters.zabbix.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:
Modules
Zabbix 7 JSON-RPC API client. |
|
HTTP transport for the Zabbix JSON-RPC API. |