I've been struggling with setting up zabbix 1.1 beta11 to listen for SNMP messages. Hopefully this will help some other users since the documentation does not very well cover this topic:
First make sure you've compiled your server with snmp support using --with-net-snmp. Create a configfile for snmptrapd:
echo "traphandle default /bin/bash /opt/zabbix/bin/snmptrap.sh" > /etc/snmptrapd.conf
snmptrapd does not have an init script on SuSE, I had to start it manually - if anyone provides an init.d script - I would appreciate...
snmptrapd -C -c /etc/snmptrapd.conf -Lf /var/log/net-snmptrapd.conf
The -C -c options start snmptrapd using no default config files but /etc/snmptrapd.conf.
Copy snmptrap.sh from zabbix source to /opt/zabbix/bin/snmptrap.sh or whereever you specified in /etc/snmptrapd.conf
Change these settings in snmptrap.sh:
ZABBIX_SERVER = "[Zabbix Server IP]"
ZABBIX_PORT = "[Port - see in your /etc/zabbix/zabbix_server.conf]"
KEY = "[element name - must match the zabbix element name]"
HOST = "[server name - must match the zabbix server name]"
There seems to be a bug in snmptrap.sh - at least the version I use here:
The last line should read:
echo $ZABBIX_SENDER $ZABBIX_SERVER $ZABBIX_PORT $HOST $KEY \'"$str"\'
Note that I removed the colon ( : ) between $HOST and $KEY - zabbix_sender does not expect it. Also, the backslashed single quotes prevent errors if $str contains double quotes.
Now login to zabbix and create a new server using the name you specified as HOST in snmptrap.sh - I don't give it an IP since I don't need no further checks for this server. Create an element of type "ZABBIX trapper" using the key you set up in snmptrap.sh KEY of type "alphanumeric".
That's it - zabbix now should be able to trap snmp messages!
If you have problems setting up SNMP trapping it might be useful to send snmp messages manually:
snmptrap -v1 -cpublic localhost .1.3.6.1.6.3.1.1.5.2 0 0 "" "" .1.3.6.1.4.1 s "hello"
would send an snmp message to localhost and should trigger snmptrap.sh.
Have fun!
First make sure you've compiled your server with snmp support using --with-net-snmp. Create a configfile for snmptrapd:
echo "traphandle default /bin/bash /opt/zabbix/bin/snmptrap.sh" > /etc/snmptrapd.conf
snmptrapd does not have an init script on SuSE, I had to start it manually - if anyone provides an init.d script - I would appreciate...
snmptrapd -C -c /etc/snmptrapd.conf -Lf /var/log/net-snmptrapd.conf
The -C -c options start snmptrapd using no default config files but /etc/snmptrapd.conf.
Copy snmptrap.sh from zabbix source to /opt/zabbix/bin/snmptrap.sh or whereever you specified in /etc/snmptrapd.conf
Change these settings in snmptrap.sh:
ZABBIX_SERVER = "[Zabbix Server IP]"
ZABBIX_PORT = "[Port - see in your /etc/zabbix/zabbix_server.conf]"
KEY = "[element name - must match the zabbix element name]"
HOST = "[server name - must match the zabbix server name]"
There seems to be a bug in snmptrap.sh - at least the version I use here:
The last line should read:
echo $ZABBIX_SENDER $ZABBIX_SERVER $ZABBIX_PORT $HOST $KEY \'"$str"\'
Note that I removed the colon ( : ) between $HOST and $KEY - zabbix_sender does not expect it. Also, the backslashed single quotes prevent errors if $str contains double quotes.
Now login to zabbix and create a new server using the name you specified as HOST in snmptrap.sh - I don't give it an IP since I don't need no further checks for this server. Create an element of type "ZABBIX trapper" using the key you set up in snmptrap.sh KEY of type "alphanumeric".
That's it - zabbix now should be able to trap snmp messages!
If you have problems setting up SNMP trapping it might be useful to send snmp messages manually:
snmptrap -v1 -cpublic localhost .1.3.6.1.6.3.1.1.5.2 0 0 "" "" .1.3.6.1.4.1 s "hello"
would send an snmp message to localhost and should trigger snmptrap.sh.
Have fun!

Comment