Ad Widget

Collapse

SNMP-traps handling in zabbix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jsomoza
    Junior Member
    • Mar 2008
    • 27

    #1

    SNMP-traps handling in zabbix

    Hi all!
    I've been trying to configure my zabbix server to be able to receive snmptraps.

    By the moment, i've managed to receive the traps into my computer but zabbix still isn't able to handle them.
    Could anyone tell me how can i make my zabbix show me the traps, please???

    I'm going crazy!!
  • artesvida
    Junior Member
    • May 2007
    • 18

    #2
    SNMP-traps handling in zabbix

    Search the forums. There's a lot of good info in there, which is how I figured it out. The extra-short version, though, is:

    1. change your /etc/snmp/snmptrapd.conf file to include the lines:
    outputOption efnQs
    traphandle default /bin/bash /home/zabbix/bin/snmptrap.sh

    (assuming that snmptrap.sh is in /home/zabbix/bin). You may want other outputOptions, but those work for me. Use "man snmpcmd" and see the output options section.

    2. edit your snmptrap.sh script (specified in step one) as needed. The idea is that "chunks" of the trap are read into variables at the top of the script, then processed, then sent out using zabbix_sender. The hostname specified on the zabbix_sender command line is the host that will receive the trap. I spent a lot of time sending all my traps to a generic host, so that I could see what was coming through snmptrapd and zabbix_sender. Then, I started sending the traps to the correct hosts.

    3. add a "zabbix trapper" item to the host(s) that will receive the traps. I started with a generic host called "SNMP Trapper", and this is the host name that I specified for *all* traps in the snmptrap.sh script. Then, watch what comes through. Once you have a good feel for how the traps look, then add them to the appropriate hosts, and use those host names with zabbix_sender.

    Any specific questions I would be happy to answer. However, please search the forums and try working with SNMP. It's pretty straightforward, and there is good documentation already out there.

    Comment

    • jsomoza
      Junior Member
      • Mar 2008
      • 27

      #3
      First of all, tanks for replying.

      I'm a little bit confused with this so if you don't mind, i'll tell you what i've made and understood and i'd be grateful if you tell me wether i'm right or not.

      -Ok, i have a folder where i receive the traps i want to receive named traps.txt.

      -I've configured a perl folder in order to act like a handler, which i understand is the folder zabbix_sender will execute to send the traps to zabbix.

      -I have also configured the snmptrapd.conf folder in order to tell zabbix_sender which the perl folder will be.

      -Finally, i've created an special ZABBIX trapper item in zabbix and added it to the hosts i receive traps from.

      Am i right or do i have to add some other configuration?

      Tanks.
      Jordi.

      Comment

      • artesvida
        Junior Member
        • May 2007
        • 18

        #4
        SNMP-traps handling in zabbix

        -Ok, i have a folder where i receive the traps i want to receive named traps.txt.
        Where is this folder? Don't you mean a file? And don't you want the traps to end up triggering something in Zabbix?

        I've configured a perl folder in order to act like a handler, which i understand is the folder zabbix_sender will execute to send the traps to zabbix.
        Sounds like you have the handler, but what is the handler doing? Mine is reading the trap, breaking it into useful pieces, then using those pieces when executing zabbix_sender. Zabbix_sender is the program that sends the trap into to Zabbix.

        -I have also configured the snmptrapd.conf folder in order to tell zabbix_sender which the perl folder will be
        .
        Good, although now I'm convinced that when you say "folder" you really mean "file."

        -Finally, i've created an special ZABBIX trapper item in zabbix and added it to the hosts i receive traps from.
        Good. Make sure that this is the hostname you are specifiying on the command line when executing zabbix_sender in your trap handler script. When your server receives the trap, it will have the hostname (or IP address) of the host that generated the trap.

        Comment

        • jsomoza
          Junior Member
          • Mar 2008
          • 27

          #5
          Thanks for replying.

          First of all, you're right when you say i meant file when writing folder. It was a misunderstanding.

          Ok, in the traphandler, i create a string with the info read from the file where i keep the traps received and in the end of the traphandler, i execute a line with the info zabbix_sender needs such as zabbix IP or zabbix port, and in the command line variable "value" i put the string mentioned.

          I hope the text is understandable.
          Thanks.

          Comment

          • artesvida
            Junior Member
            • May 2007
            • 18

            #6
            SNMP-traps handling in zabbix

            When my script executes zabbix_sender, it has the following parameters:
            -z $ZABBIX_SERVER (in my case, localhost)
            -p $ZABBIX_PORT (10051)
            -s $hostname (this is the hostname that will receive the trap in zabbix. If you have a single host to receive all traps, make sure it's the same hostname here.)
            -k $oid (this is the OID of the trap. So you can distinguish one event from another. This is the value in the "Key" field of the Zabbix trapper item.)
            -o $payload (this is the value of the trap. Usually "on" (1) or "off" (0))

            Comment

            Working...