Update netbox_zabbix_sync.py

Zabbix 7.0.0 and higher changed the proxy.get api call, this commit fixes that api call by checking against the API version.
This commit is contained in:
Raymond Kuiper 2024-02-23 15:14:50 +01:00 committed by GitHub
parent e24351aea2
commit 1d98384629
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@
"""Netbox to Zabbix sync script.""" """Netbox to Zabbix sync script."""
from os import environ, path, sys from os import environ, path, sys
from packaging import version
import logging import logging
import argparse import argparse
from pynetbox import api from pynetbox import api
@ -88,7 +89,10 @@ def main(arguments):
netbox_journals = netbox.extras.journal_entries netbox_journals = netbox.extras.journal_entries
zabbix_groups = zabbix.hostgroup.get(output=['groupid', 'name']) zabbix_groups = zabbix.hostgroup.get(output=['groupid', 'name'])
zabbix_templates = zabbix.template.get(output=['templateid', 'name']) zabbix_templates = zabbix.template.get(output=['templateid', 'name'])
zabbix_proxys = zabbix.proxy.get(output=['proxyid', 'host']) if version.parse(zabbix.api_version()) < version.parse("7.0.0"):
zabbix_proxys = zabbix.proxy.get(output=['proxyid', 'host'])
else:
zabbix_proxys = zabbix.proxy.get(output=['proxyid', 'name'])
# Go through all Netbox devices # Go through all Netbox devices
for nb_device in netbox_devices: for nb_device in netbox_devices:
try: try: