NetBox and Zabbix: Creating the Ultimate Source of Truth for Your IT Infrastructure
NetBox and Zabbix: Creating the Ultimate Source of Truth for Your IT Infrastructure
Good morning everyone! Dimitri Bellini here, and welcome back to Quadrata, my channel dedicated to the world of open source and all the IT that I, and hopefully you, find fascinating.
This week, we’re diving into a powerful solution that addresses a common and persistent challenge in IT management: the lack of a single, reliable source of information. In large infrastructures, it’s often difficult to know what objects exist, where they are, what their relationships are, and how to even begin monitoring them. Many turn to a Configuration Management Database (CMDB), but keeping it manually updated is a struggle. What if we could automate this process?
That’s where a fantastic open-source project called NetBox comes in. And thanks to our friends at Open Source ICT Solutions, there’s a brilliant integration that connects it directly to Zabbix. Let’s explore how to build a true “source of truth” for our network.
What is NetBox and Why Do You Need It?
For those who may not know it, NetBox is a well-established and solid open-source tool designed to be the central repository for your entire IT environment. It’s more than just a spreadsheet; it’s a structured database for everything from your network devices to your data center cabling. It’s designed to be the single source of truth.
NetBox helps you model and document your infrastructure with incredible detail. Its core functionalities include:
- IP Address Management (IPAM): A robust module for managing all your IP spaces, prefixes, and addresses.
- Data Center Infrastructure Management (DCIM): Model your physical infrastructure, including data center layouts, rack elevations, and the exact placement of devices within them.
- Cabling and Connections: Document and visualize every cable connection between your devices, allowing you to trace the entire path of a circuit.
- Automation and Integration: With a powerful REST API and support for custom scripts, NetBox is built for automation, allowing you to streamline processes and integrate with other tools—like Zabbix!
While maintaining this level of documentation might seem daunting, the benefits are immense, especially when you can automate parts of the workflow.
The NetBox-Zabbix Integration: How It Works
The concept behind this integration is simple yet crucial to understand. The flow of information is one-way: from NetBox to Zabbix.
This is fundamental. NetBox acts as the source of truth, the master record. When you add or update a device in NetBox, the plugin provisions that device in Zabbix. It creates the host, assigns templates, sets up interfaces, and applies tags. It is not Zabbix sending information back to NetBox. This ensures your documentation remains the authoritative source.
I got all my inspiration for this setup from a fantastic blog post on Zabbix.com by the team at Open Source ICT Solutions. They created this plugin and provided an excellent guide, so a huge thank you to them!
Getting Started: A Step-by-Step Guide
For my setup, I wanted to simplify things, so I used a non-official Docker repository designed for NetBox plugin development. It makes getting up and running much faster.
H3: Setting Up the Environment
Here are the commands I used to get the environment ready:
# 1. Clone the unofficial Docker repo for NetBox plugin development
> git clone https://github.com/dkraklan/netbox-plugin-development-env.git
> cd netbox-plugin-development-env
# 2. Clone the nbxsync plugin from OpensourceICTSolutions into the plugins directory
> cd plugins/
> git clone https://github.com/OpensourceICTSolutions/nbxsync.git
> cd ..
# 3. Add the plugin to the NetBox configuration
> vi configuration/configuration.py
# Add 'nbxsync' to the PLUGINS list:
PLUGINS = [
'nbxsync'
]
# 4. Build and launch the Docker containers
> docker-compose build
> docker-compose up -d
And just like that, you should have a running NetBox instance with the Zabbix plugin installed!
Configuring the Zabbix Plugin in NetBox
Once NetBox is up, the configuration is straightforward.
- Add Your Zabbix Server: In the NetBox UI, you’ll see a new “Zabbix” menu at the bottom. Navigate there and add your Zabbix server. You’ll need to provide a name, the server URL (just the base URL, e.g.,
http://zabbix.example.com), and an API token from a Zabbix user with sufficient permissions. - Sync Templates: After adding the server, you can click “Sync Templates.” The plugin will connect to your Zabbix instance and pull in all available templates, proxies, macros, and host groups. This is incredibly useful for later steps.
- Define Your Infrastructure: Before adding a device, you need to define some core components in NetBox. This is standard NetBox procedure:
- Create a Site (e.g., your main office or data center).
- Define a Manufacturer (e.g., Cisco).
- Create a Device Role (e.g., Core Switch).
- Create a Device Type, which is a specific model (e.gne., Cisco CBS350-24P). Here, you can go to the “Zabbix” tab and pre-assign a default Zabbix template for this device type, which is a huge time-saver!
Provisioning a New Device to Zabbix
Now for the magic. Let’s add a new switch and watch it appear in Zabbix.
- Create the Device: Create a new device in NetBox, assigning the Site, Device Role, and Device Type you created earlier.
- Add an IP Address: Go to the IPAM section and create an IP address that you will assign to the switch’s management interface.
- Configure the Zabbix Interface: Navigate back to your newly created device and click on the “Zabbix” tab.
- Add a Host Interface. Select your Zabbix server, the interface type (e.g., SNMP), and assign the IP address you just created.
- Add a Host Group. Assign the Zabbix host group where you want this device to appear.
- Add any Tags you want. I created a “netbox” tag for easy identification.
- Sync to Zabbix: With all the information in place, simply click the “Sync to Zabbix” button. A background job will be queued.
If you switch over to your Zabbix frontend, you’ll see the new host has been created automatically, complete with the correct IP address, assigned to the right host group, linked to the correct template, and with the tags we defined. It’s that simple!
Even better, the integration also pulls some data back for viewing. In the “Zabbix Operation” tab within NetBox, you can see the latest problems for that specific device directly from Zabbix, giving you a unified view without leaving the NetBox interface.
Final Thoughts
I have to say, this is a truly impressive product. Of course, it requires a disciplined workflow to maintain the data in NetBox, but the payoff in consistency, automation, and having a single, reliable source of truth is enormous. From one dashboard, you can control your entire documented infrastructure and its monitoring configuration.
This project is actively developed, and the community is already making requests on GitHub. If you have ideas for new features or find any bugs, I encourage you to contribute. This is a tool that can be incredibly useful for anyone managing a Zabbix instance, from a small lab to a large server farm.
That’s all for today! I hope you found this overview interesting. It’s a powerful combination that can really level up your infrastructure management game.
What do you think? Have you used NetBox before? Let me know your thoughts on this integration in the comments below. As always, if you enjoyed the video and this post, please give it a thumbs up and subscribe to the channel if you haven’t already. See you next week!
Follow my work and join the community:
- My YouTube Channel: Quadrata
- Italian Zabbix Community on Telegram: ZabbixItalia
