Zabbix SNMP Monitoring for Network Devices: Setup Guide - 夜莺博客

Zabbix SNMP Monitoring for Network Devices: Setup Guide

Zabbix is one of the best open-source platforms for monitoring network devices, thanks to first-class SNMP support: scheduled OID polling, SNMP traps, automatic interface discovery via Low-Level Discovery (LLD), and threshold-based triggers. This setup guide walks through the complete flow — installing Zabbix 7.0 LTS, adding a switch as an SNMP host with community macros, applying the built-in network device templates, creating an interface-down trigger, and enabling SNMP trap reception — so you can go from zero to a monitored core router in under an hour.

Step 1: Install Zabbix Server

wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.0+ubuntu22.04_all.deb
sudo dpkg -i zabbix-release_latest_7.0+ubuntu22.04_all.deb
sudo apt-get update
sudo apt-get install -y mysql-server zabbix-server-mysql zabbix-frontend-php   zabbix-nginx-conf zabbix-sql-scripts zabbix-agent

Step 2: Add a Network Device Host

In the web UI (Data collection > Hosts > Create host): set the host name (e.g., core-router-01), add it to a group, add an SNMP interface (IP + port 161), and apply the Network Generic Device by SNMP template — or a vendor template such as Cisco IOS SNMP. Hosts can also be added via the Zabbix API using host.create with the interface details and macro references.

Step 3: Configure SNMP Macros

On the host's SNMP interface, reference a macro instead of hardcoding the community string:

{$SNMP_COMMUNITY} = Net0ps_M0n!t0r

For SNMPv3, set the interface version to SNMPv3 and define {$SNMP3_USER}, {$SNMP3_AUTHPASSPHRASE}, and {$SNMP3_PRIVPASSPHRASE} — always prefer SNMPv3 in production.

Step 4: Interface Discovery and Triggers

The built-in template uses SNMP LLD to discover interfaces from IF-MIB (ifDescr, ifOperStatus, ifInOctets/ifOutOctets) and creates triggers for state changes automatically. For a custom interface-down trigger:

last(/core-router-01/net.if.status[ifOperStatus.1])=2

This fires when ifOperStatus = 2 (down). Custom items, such as inbound bandwidth on an interface, can be added manually with the appropriate OID (1.3.6.1.2.1.31.1.1.1.6.1 for ifHCInOctets) and change-per-second preprocessing.

Step 5: Receive SNMP Traps

sudo apt-get install -y curl snmp snmptrapd
sudo mkdir -p /var/lib/zabbix/snmptraps
# enable StartSNMPTrapper and SNMPTrapperFile in /etc/zabbix/zabbix_server.conf
# install /usr/sbin/zabbix_trap_handler.sh and configure /etc/snmp/snmptrapd.conf:
#   authCommunity log,execute,net public
#   traphandle default /bin/bash /usr/sbin/zabbix_trap_handler.sh
sudo systemctl restart zabbix-server snmptrapd

Add a trap item to the host (type SNMP trap, key snmptrap.fallback). Verify polling in Monitoring > Latest data, and test from the Zabbix server with snmpget -v2c -c 'Net0ps_M0n!t0r' 192.168.1.1 SNMPv2-MIB::sysDescr.0. For the device-side SNMPv3 configuration, pair this with our Dell OS10 SNMPv3 configuration guide and the tcpdump BPF guide for when you need to verify traffic on the wire.

原文链接:https://oneuptime.com/blog/post/2026-03-20-snmp-monitoring-zabbix-network/view