4 Installation
Raymond Kuiper edited this page 2025-05-28 15:39:09 +02:00

Installation via Docker

To pull the latest stable version to your local cache, use the following docker pull command:

docker pull ghcr.io/thenetworkguy/netbox-zabbix-sync:main

Make sure to specify the needed environment variables for the script to work (see here) on the command line or use an env file.

docker run -d -t -i -e ZABBIX_HOST='https://zabbix.local' \ 
-e ZABBIX_TOKEN='othersecrettoken' \
-e NETBOX_HOST='https://netbox.local' \
-e NETBOX_TOKEN='secrettoken' \
--name netbox-zabbix-sync ghcr.io/thenetworkguy/netbox-zabbix-sync:main

This should run a one-time sync, you can check the sync with docker logs netbox-zabbix-sync.

The image uses the default config.py for it's configuration, you can use a volume mount in the docker run command to override with your own config file if needed (see config file):

docker run -d -t -i -v $(pwd)/config.py:/opt/netbox-zabbix/config.py ...

Installation from Source

Cloning the repository

git clone https://github.com/TheNetworkGuy/netbox-zabbix-sync.git

Packages

Make sure that you have a python environment with the following packages installed. You can also use the requirements.txt file for installation with pip.

# Packages:
pynetbox
pyzabbix

# Install them through requirements.txt from a venv:
virtualenv .venv
source .venv/bin/activate
.venv/bin/pip --require-virtualenv install -r requirements.txt

Config file

First time user? Copy the config.py.example file to config.py. This file is used for modifying filters and setting variables such as custom field names.

cp config.py.example config.py

Set environment variables

Set the following environment variables:

export ZABBIX_HOST="https://zabbix.local"
export ZABBIX_USER="username"
export ZABBIX_PASS="Password"
export NETBOX_HOST="https://netbox.local"
export NETBOX_TOKEN="secrettoken"

Or, you can use a Zabbix API token to login instead of using a username and password. In that case ZABBIX_USER and ZABBIX_PASS will be ignored.

export ZABBIX_TOKEN=othersecrettoken

If you are using custom SSL certificates for NetBox and/or Zabbix, you can set the following environment variable to the path of your CA bundle file:

export REQUESTS_CA_BUNDLE=/path/to/your/ca-bundle.crt

NetBox custom fields

Use the following custom fields in NetBox (if you are using config context for the template information then the zabbix_template field is not required):

* Type: Integer
* Name: zabbix_hostid
* Required: False
* Default: null
* Object: dcim > device
* Type: Text
* Name: zabbix_template
* Required: False
* Default: null
* Object: dcim > device_type

You can make the zabbix_hostid field hidden or read-only to prevent human intervention.

This is optional and there is a use case for leaving it read-write in the UI to manually change the ID. For example to re-run a sync.