1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
"""
Set connect and read timeout for ZabbixAPI requests
"""
from pyzabbix import ZabbixAPI
# The hostname at which the Zabbix web interface is available
ZABBIX_SERVER = "https://zabbix.example.com"
# Timeout (float) in seconds
# By default this timeout affects both the "connect" and "read", but
# if you are using Requests library > v2.4.0 you can specify the timeout as a tuple (connect, read)
# to set individual timeouts.
TIMEOUT = 3.5
# You can define the timeout while creating the ZabbixAPI object:
zapi = ZabbixAPI(ZABBIX_SERVER, timeout=TIMEOUT)
# Login to the Zabbix API
zapi.login("api_username", "api_password")
# Or you can re-define it after
zapi.timeout = TIMEOUT
|