Receiving SNMP traps in Zabbix with snmptrapd for network and facility devices
Zabbix receives SNMP traps through snmptrapd, which writes each trap to a file that the Zabbix server then reads. A team whose switches, UPS units or storage arrays send traps about events that polling only notices minutes later, or misses entirely, such as a power supply failover, a battery test failure or a link flap, is the usual reason to set this up. Traps are worth the effort when the event is short-lived, when the device raises it once rather than holding a state you can poll, or when delay in seeing it matters. For steady state values such as interface counters, temperatures or input voltage, polling remains the simpler and more predictable option. The work sits in three places: the snmptrapd receiver and its configuration, the file path the server reads, and the item design that decides which traps become problems.
The receiver choice shapes the maintenance load. Zabbix documents Bash and Perl receivers, plus SNMPTT as an alternative, and recommends the embedded Perl receiver for better performance in production. Confirm which receiver your Zabbix version and packages support before you write the snmptrapd configuration, because the example scripts differ between releases. The trap file must be readable by the Zabbix server process, and on systemd hosts the PrivateTmp setting can make snmptrapd write to a private copy of /tmp that the server never sees. Place the trap file in a directory outside /tmp, and test with a manual snmptrap command from a device subnet before relying on it. Confirm the path and permissions on your own distribution with its packaged unit files.
How a trap travels from device to Zabbix item
A trap starts at the device, such as a switch, UPS or storage array, which sends it to snmptrapd on a Linux host. The receiver script writes each trap as a line to the trap file, and the Zabbix server or proxy reads that file. Zabbix then matches the trap's source address to a host's SNMP interface, and a snmptrap[regexp] item or the snmptrap.fallback item stores it. Check the trap file path and its permissions at the read step, because a PrivateTmp setting can hide it from Zabbix.
Path of one SNMP trap from the sending device to a Zabbix item.
Choosing the Bash, Perl or SNMPTT receiver
The Bash receiver is a small script that snmptrapd calls for each incoming trap. It writes the trap details to the trap file, which Zabbix then reads. Because every trap starts a new shell process, it is the simplest option to read and change, but it is also the slowest under heavy trap volume. It suits labs, small estates and sites where a handful of devices send only occasional traps.
- Simple to read: the logic is a short shell script that operations staff can audit without Perl knowledge.
- Process cost per trap: each trap launches a new process, so bursts from a failing UPS or a storm of link-state traps can build a backlog.
- Limited MIB handling: translating numeric OIDs into readable names depends on what the script and the installed MIBs provide, so vendor MIBs need careful loading.
- Easy to test by hand: you can send a test trap with snmptrap and inspect the trap file directly.
- Minimal dependencies: it needs only the shell and the snmptrapd setup, which keeps the change surface small.
Before choosing this option, confirm the expected trap rate per device and per site with the vendors and your own monitoring history, and check whether the Zabbix version you run still documents this receiver as the path you want.
The embedded Perl receiver runs inside the snmptrapd process, so it does not start a new process for each trap. Zabbix recommends it for better performance in production. It writes to the same trap file format that Zabbix reads, so the Zabbix side of the configuration is the same as for the other options. The trade-off is that the Perl code must be correct, and errors show up in the snmptrapd logs rather than in a simple script run.
- Production recommendation: Zabbix documents the embedded Perl receiver as the better choice for performance in production environments.
- Lower overhead: traps are handled inside the running daemon, which matters for switch fleets and large UPS or storage estates.
- Perl skills required: your team must maintain the Perl code, test changes and track it through upgrades.
- Configuration mismatch risk: Perl and daemon options must agree with the trap file path and the Zabbix server setup, so verify both ends after each change.
- Good match for standard traps: most common vendor traps are handled cleanly, while unusual enterprise MIBs may need extra work.
Before committing, check the Zabbix documentation for your version, confirm the Perl modules shipped with your distribution, and run a trap burst test against a non-production server.
SNMPTT, the SNMP Trap Translator, is a separate Perl program that reads vendor MIB files and translates trap OIDs into named events with descriptions, severities and variable bindings. It is often the best fit when a team must handle many vendor-specific traps and wants the translated text to be readable without hand-written parsing. The cost is an extra component to install, configure and keep current alongside Zabbix and snmptrapd.
- Vendor MIB handling: it loads MIB files and maps traps to named events, which helps with switches, UPS units and storage arrays that use enterprise MIBs.
- Configuration files: event definitions live in configuration files that reviewers can read and version in source control.
- Extra moving parts: SNMPTT adds its own install, update and troubleshooting path on top of snmptrapd and Zabbix.
- MIB maintenance: when vendors release new firmware with changed traps, someone must update MIB files and event definitions.
- Output format: confirm that the output format it writes matches what your Zabbix trap items expect, and test it with real samples from each device model.
Before choosing SNMPTT, inventory the MIBs your devices actually use, obtain them from each vendor's support channel, and confirm how your chosen version of SNMPTT is packaged and maintained on your platform.
Trap configuration options and when each fits
This table compares the trap handling options Zabbix offers for SNMP traps, from the snmptrapd receiver and trap file through item types and interface matching. Read each row as a decision: the option, what it does, and the situation where it is the right choice. The main takeaway is that a specific snmptrap[regexp] item per device family, backed by snmptrap.fallback for leftovers, usually gives clearer data than one broad catch-all item.
| Option | What it does | When it fits |
|---|---|---|
| snmptrapd with Perl receiver | Writes received traps to a trap file that Zabbix reads, using the embedded Perl receiver | Production trap intake where performance matters, as Zabbix recommends the embedded Perl receiver for production |
| Bash receiver | Passes each trap to a shell script that writes a line to the trap file | Small test setups or environments where Perl is not available, expect lower throughput |
| SNMPTT receiver | Hands traps to SNMP Trap Translator, which translates them into readable text before writing the trap file | Sites that already maintain SNMPTT configuration for device MIBs and want translated trap text |
| Trap file location | Path where snmptrapd writes trap lines and Zabbix reads them | Use a path outside /tmp, since systemd PrivateTmp can hide the file from Zabbix in /tmp |
| snmptrap[regexp] item | Catches traps from the host's SNMP interface whose text matches the regular expression | Separate traps by device family, such as UPS alarms or storage array events, each with its own item and triggers |
| snmptrap.fallback item | Catches traps from the host's SNMP interface that no other trap item on that interface matched | Keep a record of unexpected traps for review, with Log as the information type |
| Log information type | Stores each trap as a log entry so text can be searched and matched by triggers | Use for event-style traps where each message is a record, rather than a numeric value to graph |
| SNMP interface matching | Associates each trap with a host by comparing the sender address to the host's SNMP interface | Confirm each device's SNMP interface address matches the source address the device uses for traps, including NAT and multi-address devices |
Setup sequence for trap reception
This sequence takes a Zabbix server from no trap handling to a verified path where switches, UPS units and storage arrays send traps that land in items on the right host. Each step closes with a check, so a failure is found at the point it was introduced rather than at the end.
Install snmptrapd on the trap receiver
The team installs the net-snmp package on the host that will receive traps, which is usually the Zabbix server or a dedicated collector that can reach the monitored devices on UDP port 162. Confirm the exact package name and any receiver-specific packages for your distribution, since names differ between Linux families. The step is done when the snmptrapd binary runs and reports its version, and the service can be enabled without starting in an error state.
Configure the trap receiver and format
Set snmptrapd to pass each received trap to the Zabbix trap receiver, using the Perl receiver that Zabbix recommends for production performance, or the Bash receiver or SNMPTT if your environment requires them. Set the community or authentication settings that match your devices, and confirm the trap file path the receiver writes to. The step is done when snmptrapd starts cleanly, the configuration parses without warnings, and a test trap sent from localhost appears in the log output.
Create the trap file with correct permissions
Create the trap file in a directory that the Zabbix server process can read and that the snmptrapd process can write, and set ownership to the Zabbix service user. Avoid /tmp for this file. If snmptrapd runs under systemd with PrivateTmp enabled, a file in /tmp will be invisible to the Zabbix server, so choose a path such as a dedicated directory under /var/log or /var/lib and confirm the unit file does not isolate it. The step is done when the Zabbix user can read the file and a manual write from snmptrapd is visible to that user.
Confirm the SNMP interface on each host
In the Zabbix frontend, open each device host that will send traps and check that it has an SNMP interface whose IP address matches the address the device sends traps from. Zabbix matches each trap by source address to that interface, so a mismatch means traps are received but never assigned to a host. Where a device sends traps from a management address different from its polling address, record both and confirm which one the device uses. The step is done when every trap-sending host has an SNMP interface with the correct address and the address is recorded in your inventory.
Add snmptrap items and the fallback item
On each host, create snmptrap[regexp] items with Log as the type of information, using a regular expression that matches the trap content you want to capture, such as a UPS alarm OID or a storage array event text. Then create one snmptrap.fallback item on the same interface, also set to Log, so that traps no other item caught are stored for review. Set the key and type carefully, since the fallback item only sees traps that no other item on that interface matched. The step is done when each host shows the expected items in the item list and the items are enabled.
Test with a sample trap and verify the result
Send a sample trap from a test source using snmptrap with the same community or authentication settings and a trap OID that one of your items matches, then send a second trap that matches none. In the Zabbix frontend, check that the first trap appears as a new value on the matching item and that the second trap appears on the fallback item. Review the trap file and the Zabbix server log for entries that show no matching host or no matching item. The step is done when both test traps land where expected and the unmatched log records the expected trap.
Confirm unmatched trap logging and handover
Check that unmatched traps are logged and reviewed by the operations team, and confirm which team owns the fallback item and how often they review it. Document the receiver version, trap file path, service unit and interface mapping so that future device changes can be traced. Ask the vendor or your own environment team to confirm any device-specific trap OIDs before production use. The step is done when the handover record lists each trap-sending host, its interface address, its items and the owner of the unmatched trap review.
Why the systemd PrivateTmp setting breaks traps in /tmp
Zabbix warns that systemd's PrivateTmp setting can stop the trap file from working when that file sits in /tmp, so the trap file should live outside /tmp from the start. PrivateTmp gives a service its own private view of /tmp. When snmptrapd runs under a unit that enables this setting, it writes trap data into a private /tmp that the Zabbix server or proxy process never sees, and the server has nothing to read. The trap file path is set in the snmptrapd configuration and must match what the Zabbix side expects, so the decision belongs in the design stage, not after the first failed test.
The symptom is quiet. snmptrapd keeps running, traps from switches, UPS units or storage arrays arrive at the host, and no values appear on the Zabbix items. Check the snmptrapd unit with systemctl show snmptrapd -p PrivateTmp (confirm the unit name on your distribution), then compare the file the receiver writes with the file the server reads. If the receiver's file exists only when you look at it from inside the service's namespace, PrivateTmp is the likely cause. Confirm the behavior on your own build before you rely on it, because packaged unit files differ.
To fix it, move the trap file to a directory both services can reach, such as a dedicated directory under /var/lib or /var/log owned by the snmptrapd user with a group that grants the Zabbix server or proxy read access. Set the path in the receiver configuration and in the Zabbix trap configuration together, then restart the affected services. Keep PrivateTmp enabled if your hardening policy requires it, since moving the file is the narrower change. Record the chosen path, owner and permissions in your build notes so the next upgrade does not move it back into /tmp.
Security and operational considerations for trap intake
A trap receiver accepts unauthenticated UDP traffic from the network and writes it to disk, so its security and its disk footprint need planning alongside the Zabbix setup. The cards below cover credentials, source restriction, file handling, log growth and MIB ownership, which together decide whether the trap pipeline stays trustworthy and sustainable.
SNMP credentials on the receiver
Traps sent as SNMPv1 or SNMPv2c carry a community string in clear text, and snmptrapd only checks it if you configure an authorization rule. Decide early whether the receiver accepts SNMPv3 traps with authentication and encryption, which matches the approach you plan for polling. Confirm the community or v3 user configured on each switch, UPS and array matches what snmptrapd expects, and store those secrets in a file readable only by the service account.
Zabbix SNMP traps docsRestricting trap sources at the firewall
Zabbix matches each trap to a host by its source address, but that match happens after the packet has reached the receiver. Allow UDP 162 only from the management addresses of devices that should send traps, and drop everything else at the host firewall or network edge. Confirm that NAT, load balancers or a proxy in the path do not rewrite the source address, because a rewritten address will fail to match any host's SNMP interface.
File permissions on the trap file
The trap file is read by the Zabbix server or proxy and written by snmptrapd, so both processes need access, and no other local user should. Set ownership and mode on the file and its directory explicitly, and confirm the Zabbix service account can read the file after every package upgrade. Keep the file out of world-writable locations such as /tmp, where local users could inject fake trap lines.
Log growth and rotation
Every trap is written as a line, so a noisy switch or a flapping UPS can grow the file quickly and fill the partition. Measure the trap rate during a representative week, then set a rotation policy that the Zabbix reader can handle, including how it reopens a rotated file. Alert on the disk usage of the trap directory, and decide what happens to the old files, since they may contain device identifiers you must retain or purge under your policy.
Ownership of MIB files
Loading vendor MIBs into snmptrapd changes how traps are named and parsed, so a MIB update can silently change what your receiver matches. Assign one owner for the MIB directory, record the vendor and version of each file, and review changes before they reach production. Ask each device vendor which MIBs apply to the trap types you plan to receive, and document where the files came from.
Questions teams ask before receiving SNMP traps
How much does it cost to set up SNMP trap reception in Zabbix?
Cost is driven by how many device types, trap formats and MIBs you need to decode, and by how much of the work your own team does. The software itself has no license fee: Zabbix states its open source software has no license fee, no device limits and no feature gates. The recurring costs are your staff time, any paid Zabbix technical support subscription (Silver, Gold, Platinum, Enterprise or Global tiers), and maintenance when vendors change trap definitions. When you ask a partner for a quote, ask for the written scope to list device classes, the receiver choice, the number of trap OIDs to decode, the test plan and the handover of runbooks. DeployOpen does not publish a price list, so a quote follows from that scope.
How long does it take to receive the first SNMP trap in Zabbix?
The first trap can arrive quickly once the receiver, the trap file and the Zabbix items are in place, but the duration depends on your environment, not a fixed number. Time goes to confirming that the device sends traps to the right address, that the host has the correct SNMP interface, and that the firewall passes UDP traffic to the trap port. Ask your partner or team to name the test device, the trigger you expect and the way they will generate a test trap. No duration figure is supplied for this work, so confirm it against your own change window and device access.
What does my team need to provide before trap reception work starts?
You need access to the Zabbix server or proxy, administrative access to the hosts that will run snmptrapd, and a list of devices that will send traps: switches, UPS units and storage arrays. Your team should also provide the SNMP community or SNMPv3 details, the device vendor MIBs, and the name of the owner who can change trap destinations on each device. On the Zabbix side, the team needs to confirm which host has the SNMP interface that matches each sender's source address, because Zabbix matches each trap to a host by that address. Agree who handles change approval on production systems before work begins.
Can our in-house team set up SNMP trap reception without a partner?
Yes, a team with Linux and Zabbix experience can build this, and the work is well contained. The parts that usually take the most care are the receiver choice (Bash, Perl or SNMPTT), the trap file location, and the systemd service settings. Zabbix recommends the embedded Perl receiver for better performance in production, so most teams start there. A partner adds value when you need many device families decoded, a repeatable pattern across sites, or independent testing before a production change. Whichever route you take, make sure one person owns the trap item definitions and the unmatched trap logging after go-live.
Why does Zabbix show a trap in the log but not on a host item?
Zabbix matches each trap's source address to a host's SNMP interface, so a trap from an address that is not on any host's SNMP interface will not reach a host item. A trap that arrives from a known address but matches no snmptrap[regexp] item on that interface is caught only if you define snmptrap.fallback, which uses the Log type of information. Without a fallback item, unmatched traps can go unnoticed. Check the interface address first, then the regular expression, then whether the fallback item exists. Confirm the exact trap fields your device sends against your item expressions in a test before relying on them.
What is the systemd PrivateTmp problem with snmptrapd trap files?
When snmptrapd runs as a systemd service with PrivateTmp enabled, it writes to a private copy of /tmp, so Zabbix cannot read the trap file where you expect it. The symptom is that traps appear to be received by the service but no trap data reaches Zabbix items. Zabbix documents this pitfall and warns against using /tmp for the trap file in this setup. The fix is to place the trap file in a directory that both services can access and to check the unit file for PrivateTmp. Verify the fix by sending a test trap and confirming the item receives the value.
When should we use SNMP polling or SNMPv3 instead of traps?
Use polling when you need regular values such as interface counters, temperatures or power status, because traps only report events the device chooses to send. Traps are best for events that need immediate attention, such as a link state change or a power failure alarm. Use SNMPv3 when the device supports it and your security policy requires authenticated and encrypted management traffic, which is covered on its own page. Many production designs use both: polling for state and trends, and traps for fast event notice. Confirm with each vendor which traps and OIDs their devices send, and whether SNMPv3 is available on that model.
How DeployOpen scopes SNMP trap reception
DeployOpen scopes trap reception in writing before any configuration starts. The scope document lists the devices that will send traps, such as switches, UPS units and storage arrays, the receiver you have chosen (Bash, Perl or SNMPTT), the trap file location, and how each source address maps to a Zabbix host and its SNMP interface. Without that mapping, traps arrive at snmptrapd but never match a host, so the scope is where the matching logic is agreed rather than discovered during testing. Each device family also needs its own confirmed trap destination, SNMP version and community or credentials, which should be recorded alongside the host list.
The scope also fixes the operational boundary. It should state which items will be created, including the snmptrap[] items for each vendor's trap families, the snmptrap.fallback item for unmatched traps on each interface, and the Log-type handling for unmatched trap logging. It should name who owns the systemd unit for snmptrapd, who checks that the trap file is writable by the Zabbix server or proxy, and how the service is verified after a host reboot. Ask for each of these items to be written down with an owner, so that a later change to a device or a Zabbix upgrade does not silently break reception.
Delivery and support then follow the agreed scope. Changes to the device list, receiver or host mapping are handled as written change requests and priced or timed against that document, not absorbed informally. Before you sign, confirm with DeployOpen which vendor MIBs are in scope, which test traps will be sent from each device family during acceptance, and what evidence will show that unmatched traps are being logged. DeployOpen does not hold certifications or partner status for this work; ask for the scope, the acceptance tests and the support terms in writing.

