Ad Widget

Collapse

SNMP Traps

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ckesey
    Junior Member
    • Jul 2011
    • 2

    #1

    SNMP Traps

    I'm completely new to Zabbix as of 30 mins ago.

    I have a server that sends traps when conditions warrant.

    I'm a little overwhelmed as to the setup of everything but want to start with the SNMP Trap messages. How can I setup alerting me (via email) if a trap is received.....furthermore can I filter these traps so that only certain ones trigger an email??
  • zwar
    Junior Member
    • Apr 2010
    • 12

    #2
    First you'll need to have snmp support compiled into zabbix (using --with-net-snmp). I'll suppose you have net-snmp installed and running on your zabbix server. If you use another snmp handling application, then some things may be different. I'll also suppose your snmp trap community's name is public.

    1. Create a new host for your traps. You don't have to specify the DNS or IP for it. Simply give it a name and eventually add it to a group.
    2. Create an item for this new host. It's type should be Zabbix trapper. You have to specify a key (in case of zabbix trapper the key has a function of an item identifier). Set the Type of information to character. Leave the status Active and save the config.

    Now the fun part begins

    3. In Zabbix snmp traps are recieved by snmptrapd. This is a daemon comming with net-snmp. When a trap is received you have to pass it to zabbix somehow. Zabbix provides a sample script which does exactly that and it's named snmptrap.sh (it's included in the zabbix's tarball). Edit the script first and configure the parameters. Pay attention to the ZABBIX_SENDER var, where you have to have a valid path to the zabbix_sender (invoke whereis zabbix_sender to check the path). VERY IMPORTANT is that the parameters KEY and HOST are specified exactly the same as in steps 1 and 2, where you created the host and the item. Set HOST to whatever hostname you specified in step 1 and set KEY to the same key name you specified in step 2. Do not forget to check the ZABBIX_SERVER parameter and ZABBIX_PORT parameter as well. ZABBIX_SERVER must be the address of your zabbix server and ZABBIX_PORT the zabbix server's port.
    It's also a good idea to alter the last line in the file and surround vars $HOST, $KEY and $str with quotes (if they aren't allready added). This way you will allow those vars having spaces.
    I probably don't have to meniton that the script needs execute rights, but anyway :P (chmod +x snmptrap.sh).

    4. Now, you'll have to configure the snmptrapd daemon. Find your snmptrapd.conf file (most probably in /etc/snmp) and edit it to look like this (make a backup copy of the previous version - just in case):
    Code:
    authCommunity execute public
    authCommunity execute PUBLIC
    traphandle default /bin/bash /path/to/your/snmptrap.sh
    
    disableAuthorization yes
    The last line is needed if you're using net-snmp v5.3 or greater. For other options please see snmptrapd.conf man page. If your snmp community name is not public, replace the strings public and PUBLIC in the above code section with your snmp community name.

    5. That's it. That should work now. Test it with the following command (run it from your zabbix server):
    Code:
    snmptrap -Ci -v 2c -c public localhost "" "NET-SNMP-MIB::netSnmpExperimental" NET-SNMP-MIB:netSnmpExperimental s "test"
    In zabbix GUI go to Monitoring->Latest Data, where you should see a new entry at the zabbix trapper item. If you don't try checking the logs, try to run zabbix_sender manually, double check the configuration ...
    Last edited by zwar; 22-07-2011, 11:14. Reason: typos ...

    Comment

    • hoyt
      Member
      • Aug 2007
      • 31

      #3
      The Zabbix wiki has a couple of articles on this topic:

      But for me the best solution was using SNMPTT as the trap handler:

      SNMPTT allows you to map a SNMP trap to any Zabbix item.
      A short example:

      EVENT MSA_WARN_SA01_A .1.3.6.1.4.1.11.2.51.0.3002 "ZABBIX" Okay
      FORMAT $A ($aA): $3
      Match $aA: 172.18.0.237
      EXEC /usr/local/sbin/zbx_snmptrap sa01-a msa.snmptrap.warn "$3"
      zbx_snmptrap is a small wrapper around zabbix_sender.

      Comment

      • Ckesey
        Junior Member
        • Jul 2011
        • 2

        #4
        Thanks for all this good into.

        I'm going to do a bit more research and attempt these.

        One follow-up question to the comments....If I download and install Zabbix and a trapper program with apt-get (not compiling it myself)...is that ok???

        I noticed when compiling it myself that the "--with-net-snmp" and wanted to make sure these two can sill function together.

        Comment

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

          #5
          note that --with-net-snmp is not needed if you only want to receive traps. if you also want to poll snmp, then it is required.

          2.0 will also have a more integrated solution for receiving traps - but that's some time away still
          Zabbix 3.0 Network Monitoring book

          Comment

          • mastraze
            Member
            • Jul 2011
            • 30

            #6
            Working with snmp items in ZAbbix

            Hi,

            Thanks for your all responses and things are being more clear. But problem steel exsiting:
            After adding a new Host in the zabbix Frontend with key and activationg snmpAgent as you have recommended. In addition, i downloaded a mib called PowerNet-Mib which is free you can download from here http://http://www.oidview.com/mibs/3...erNet-MIB.html
            I made also all the configurations as was said above.

            The new mib is located under the /usr/share/snmp/mibs. The directory mib didn't exist default so I create it and save this mib file under it.

            But by running this command
            snmptrap -Ci -v 2c -c public localhost "" "NET-SNMP-MIB::netSnmpExperimental" NET-SNMP-MIB:netSnmpExperimental s "test"



            Code:
            NET-SNMP-MIB::netSnmpExperimental: Unknown Object Identifier
            Even i tried with other oid existing in this mib as sysDescr.0 which return the license Number but the same result :

            its noticed that the oid doesnt exist. Even I tried with some existing in the mib but in vain; As the file like not be seen to look for the oid as

            Code:
            Did not find 'enterprises' in module #-1 (/usr/share/mibs/netsnmp/NET-SNMP-MIB)
            Unlinked OID in NET-SNMP-MIB: netSnmp ::= { enterprises 8072 }
            Undefined identifier: enterprises near line 10 of /usr/share/mibs/netsnmp/NET-SNMP-MIB
            NET-SNMP-MIB::SNMPv2-MIB::sysDescr.0.: Unknown Object Identifier


            Any Suggestions..

            Thx in advance
            Last edited by mastraze; 25-07-2011, 03:27.

            Comment

            • kofeyh
              Junior Member
              • Jun 2010
              • 17

              #7
              A couple of quick notes:

              Firstly, you say "created a directory called 'mib'". You should keep all mibs in the same directory if possible, eg "/usr/share/snmp/mibs". Not sure if that is actually what you meant.

              Also, depending on the OS choice, you may need to make sure you instruct the SNMP service to load all the MIBs. Each MIB file may rely on one or more other MIBs, hence why having all mibs in one place makes resolving dependancies and issue easier.

              I have found that simply dumping a bunch of MIBs into the directory and expecting the SNMP service to cope with that, often ends in endless large cups of coffee whilst I work out the inter-dependancies. Cisco is notorious for referencing a large number of MIBs with various versions and interdependancies. And not telling you which ones are required.

              Best to add small groups and check they don't have issues. Using 'snmptranslate' or performing a walk against a known device via 'snmpwalk' usually helps resolve whichever MIB is causing me pain.


              Lastly, I can't recommend using the bundled snmptraps.sh script, at all, it's a horrible hack (thank you though, to whomever wrote it, it was a decent attempt); it doesn't cope well with SNMP traps with multiple text fields, such as that generated by VMware.

              I have used the 'SNMP Traps - a new solution' from the wiki with pretty good success (modified to handle sqlite on our proxies) - the perl based script seems to be pretty reliable.

              Hope at least some of the waffle above, helps.

              Comment

              • zwar
                Junior Member
                • Apr 2010
                • 12

                #8
                mastraze,

                for mib's to work edit /etc/snmp/snmp.conf and comment out the line
                Code:
                mibs :
                you can eventually add mibs references (the name is the actual mib name, not the filename) to the config:
                Code:
                mibs +Mib-Name
                mibs +ALL

                Comment

                • mastraze
                  Member
                  • Jul 2011
                  • 30

                  #9
                  SNMP and ZAbbix

                  Hi,

                  Am blowing up with snmp inside zabbix.
                  The same error appears, no mib detected. I followed the instructions as above as editing /etc/snmp/snmp.conf by commenting out mib: and adding the reference of the mib as following:

                  mibs :
                  mibs +PowerNet-MIB
                  mibs +ALL

                  but still the same problem. Again
                  NET-SNMP-MIB::netSnmpExperimental: Unknown Object Identifier

                  It will be so nice if there is another solution. Even, adding a new host in the zabbix frontend without a mib seen by snmpd daemon or snmptrapd daemon could not load the host in the latest data section. That's why, this configuration is so important to test the snmp queries and therefor the snmp trapper.

                  Thx for any response .

                  Comment

                  • NicoZanferrari
                    Junior Member
                    • Jun 2011
                    • 23

                    #10
                    Hi, I've appreciated a lot the help by zwar. So I've copied his suggestions on a new page in the wiki:
                    http://www.zabbix.com/wiki/howto/mon...p_trap_handler

                    I hope this will help someone else

                    Nico

                    Comment

                    Working...