Ad Widget

Collapse

Receiving SNMP with zabbix - how I did on SuSE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gadget
    Junior Member
    • Jan 2006
    • 14

    #1

    Receiving SNMP with zabbix - how I did on SuSE

    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!
  • shadowk
    Junior Member
    • Jun 2006
    • 23

    #2
    Thanks for the info. Funny that you should post it yesterday while I was going through the exact same (poorly documented) process. I had searched for info on this exact topic a few hours before you posted it.

    I did get everything working as you outlined (before reading your post) and I even posted a small patch to correct the colon issue here (also before seeing your post):



    Today I'm trying to setup a trigger based on the snmp data. I thought the following trigger would work but so far the status has never changed from unknown, even when I generate a trap that matches the string.

    {hostname:key.str(somestring)}=0

    I am of course substituting my actual hostname, key and string to match. The trap does show up under latest data>history for the item and it does contain the string I am trying to match. Any idea why the trigger status does not change from UNKNOWN to TRUE or FALSE?

    Comment

    • gadget
      Junior Member
      • Jan 2006
      • 14

      #3
      Originally posted by shadowk
      Today I'm trying to setup a trigger based on the snmp data. I thought the following trigger would work but so far the status has never changed from unknown, even when I generate a trap that matches the string.

      {hostname:key.str(somestring)}=0

      I am of course substituting my actual hostname, key and string to match. The trap does show up under latest data>history for the item and it does contain the string I am trying to match. Any idea why the trigger status does not change from UNKNOWN to TRUE or FALSE?
      Well, what version are you using currently? If beta11, you might have missed this: http://www.zabbix.com/forum/showthread.php?t=2897 (see known issue no 2). I did not set up any triggers for snmp messages yet - currently I'm just using it as a "log file"... :-)

      Comment

      • shadowk
        Junior Member
        • Jun 2006
        • 23

        #4
        Sorry, I should have included that I am running 1.1Beta12 on FreeBSD. I'm actually using 1.0 in production but just installed Beta12 to play with new features.

        Comment

        • shadowk
          Junior Member
          • Jun 2006
          • 23

          #5
          I finally got this working thanks to help posted on this thread. The main thing was that I had to set the item type to character instead of string. I also changed the trigger to compare to 1 instead of 0 and everything is working as expected now.

          Comment

          • richlv
            Senior Member
            Zabbix Certified Trainer
            Zabbix Certified SpecialistZabbix Certified Professional
            • Oct 2005
            • 3112

            #6
            for the init script you could look at /usr/share/doc/packages/net-snmp/rc.snmptrapd (it's there at least in sles 10)
            Zabbix 3.0 Network Monitoring book

            Comment

            Working...