Ad Widget

Collapse

How I got host specific snmp traps & triggers working using modified snmptrap.sh

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • husse
    Junior Member
    • Jan 2008
    • 15

    #16
    I restarted the snmptrapd with only -c flag. And also restarted zabbix_server and zabbix_agentd.. (I don't know if it is necessary to restart everything actually, but I did anyway..)

    And I've sent one V1 and one V2 traps..

    Here is the content of sending.log:
    /usr/local/sbin/zabbix_sender zabbix 10001 <UNKNOWN> snmptraps <UNKNOWN> 192.168.28.212 public SNMPv2-SMI::enterprises.42 SNMPv2-MIB::coldStart
    /usr/local/sbin/zabbix_sender zabbix 10001 <UNKNOWN> snmptraps <UNKNOWN> 192.168.28.212 public SNMPv2-SMI::enterprises.42 SNMPv2-MIB::coldStart
    /usr/local/sbin/zabbix_sender zabbix 10001 <UNKNOWN> snmptraps <UNKNOWN>
    /usr/local/sbin/zabbix_sender zabbix 10001 <UNKNOWN> snmptraps <UNKNOWN>


    Any comments on this info? It doesn't tell me so much..

    Thanks & Regards

    Comment

    • shadowk
      Junior Member
      • Jun 2006
      • 23

      #17
      It actually looks like the first ones could work. Now try running that command directly from the prompt:

      /usr/local/sbin/zabbix_sender zabbix 10001 <UNKNOWN> snmptraps "<UNKNOWN> 192.168.28.212 public SNMPv2-SMI::enterprises.42"

      It probably won't work, but then try the following (which the script should also try next):

      /usr/local/sbin/zabbix_sender zabbix 10001 Default_Trapper snmptraps "<UNKNOWN> 192.168.28.212 public SNMPv2-SMI::enterprises.42"

      (Quotes added)

      Andrew

      Comment

      • husse
        Junior Member
        • Jan 2008
        • 15

        #18
        I tried.. Here is the result:

        [root@soul zabbix]# /usr/local/sbin/zabbix_sender zabbix 10001 <UNKNOWN> snmptraps "<UNKNOWN> 192.168.28.212 public SNMPv2-SMI::enterprises.42"
        -bash: UNKNOWN: No such file or directory
        [root@soul zabbix]#
        [root@soul zabbix]#
        [root@soul zabbix]# /usr/local/sbin/zabbix_sender zabbix 10001 Default_Trapper snmptraps "<UNKNOWN> 192.168.28.212 public SNMPv2-SMI::enterprises.42"
        sent: 0; failed: 1; total: 1


        Would you have any comments on this? I ma not able to come to sth from this result..


        One anecdote.. $hostname parameter in the snmptrap.sh is not assigned to any value actually..

        .......
        .......
        oid=`echo $oid|cut -f2 -d' '`
        address=`echo $address|cut -f2 -d' '`
        community=`echo $community|cut -f2 -d' '`
        enterprise=`echo $enterprise|cut -f2 -d' '`

        oid=`echo $oid|cut -f11 -d'.'`
        community=`echo $community|cut -f2 -d'"'`

        str="$hostname $address $community $enterprise $oid"
        .......
        .......


        Can it create a problem..?

        Thanks & Regards,

        hs

        Comment

        • shadowk
          Junior Member
          • Jun 2006
          • 23

          #19
          There should a line further up like this:

          read hostname

          This is supposed to get the hostname but it doesn't seem to be working on yours. At any rate, it should revert to the default hostname defined at the beginning if it can't pick up a valid one from the trap.

          I think you are using a newer version of zabbix_sender than I am. It looks like you are at least running the command, but for some reason nothing is getting sent to zabbix_server.

          Does this command work: ping zabbix

          If not, you may need to change to the following:

          /usr/local/sbin/zabbix_sender localhost 10001 Default_Trapper snmptraps "<UNKNOWN> 192.168.28.212 public SNMPv2-SMI::enterprises.42"

          Basically you need to get zabbix_sender working from the command line, then you can modify your snmptrap.sh to send what works.

          Also double check the hostname from the web interface to make sure it is Default_Trapper and make sure the key under the item is set to snmptraps.

          For testing you should be able to use something as simple as this:

          /usr/local/sbin/zabbix_sender localhost 10001 Default_Trapper snmptraps "hello world"

          Another thing to check is the port that zabbix_server is configured to listen on. In my case I think it's actually 10051 instead of 10001 which would mean this command might work:

          /usr/local/sbin/zabbix_sender localhost 10051 Default_Trapper snmptraps "hello world"

          Good luck!

          Andrew

          Comment

          • husse
            Junior Member
            • Jan 2008
            • 15

            #20
            Hello,

            I checked the /etc/zabbix/zabbix_server.conf file and saw the following:
            ----------
            # Listen port for trapper. Default port number is 10051. This parameter
            # must be between 1024 and 32767

            #ListenPort=10051

            ----------

            It is commented but it should still work from the port 10051 as I understand..

            I tried all your recommendations.. None of them worked.. But the main thing I guess was that "ping zabbix" did not work.. But as an anecdote ping localhost is working..


            > ping localhost
            PING soul.mycompany.com (127.0.0.1) 56(84) bytes of data.
            64 bytes from soul.mycompany.com (127.0.0.1): icmp_seq=1 ttl=64 time=0.201 ms
            64 bytes from soul.mycompany.com (127.0.0.1): icmp_seq=2 ttl=64 time=0.052 ms
            64 bytes from soul.mycompany.com (127.0.0.1): icmp_seq=3 ttl=64 time=0.025 ms



            > ping zabbix
            PING thetotalperspectivevortex.mycompany.com (192.168.2.17) 56(84) bytes of data.
            From 192.168.2.31 icmp_seq=2 Destination Host Unreachable
            From 192.168.2.31 icmp_seq=3 Destination Host Unreachable
            From 192.168.2.31 icmp_seq=4 Destination Host Unreachable




            /etc/zabbix/zabbix_server.conf file, which tells (as I understand) that zabbix is actually -by default- listenning at 127.0.0.1 (localhost).

            # Listen interface for trapper. Trapper will listen all network interfaces
            # if this parameter is missing.

            #ListenIP=127.0.0.1


            I even tried to remove the comment and used it specifying directly "ListenIP=127.0.0.1" but it still did not work.

            What do I do wrong here? zabbix refers to the zabbix_server and it listens at 127.0.0.1:10051 but nothing works there..

            Would you have any comments on this? What do I misunderstand here?

            Many Thanks & Regards


            hs
            Last edited by husse; 21-01-2008, 11:15.

            Comment

            • husse
              Junior Member
              • Jan 2008
              • 15

              #21
              Can it be a firewall problem by the way? Zabbix_server is listenning at the port 10051 (not 10001. It is my fault that I wrote it wrong before..). Is there any specific setting that I need to change in firewall settings?

              I use Fedora Core 7.

              Thanks & Regards,

              hs

              Comment

              • shadowk
                Junior Member
                • Jun 2006
                • 23

                #22
                What result exactly do you get from the following command?

                /usr/local/sbin/zabbix_sender localhost 10051 Default_Trapper snmptraps "hello world"

                Comment

                • husse
                  Junior Member
                  • Jan 2008
                  • 15

                  #23
                  > /usr/local/sbin/zabbix_sender localhost 10051 Default_Trapper snmptraps "hello world"
                  sent: 0; failed: 1; total: 1


                  It doesn't say so much... Any recommendation..?

                  Comment

                  • Alexei
                    Founder, CEO
                    Zabbix Certified Trainer
                    Zabbix Certified SpecialistZabbix Certified Professional
                    • Sep 2004
                    • 5654

                    #24
                    ./zabbix_sender --help
                    ...
                    -v --verbose Verbose mode, -vv for more details
                    Alexei Vladishev
                    Creator of Zabbix, Product manager
                    New York | Tokyo | Riga
                    My Twitter

                    Comment

                    • husse
                      Junior Member
                      • Jan 2008
                      • 15

                      #25
                      HOBBAAAAA.... It worked...

                      # ./zabbix_sender -vv -z 192.168.2.31 -p 10051 -s Default_Trapper -k snmptraps -o "hello world 3"
                      zabbix_sender [27192]: DEBUG: Send to: '192.168.2.31:10051' As: 'Default_Trapper' Key: 'snmptraps' Value: 'hello world 3'
                      zabbix_sender [27192]: DEBUG: Send data: '<req><host>RGVmYXVsdF9UcmFwcGVy</host><key>c25tcHRyYXBz</key><data>aGVsbG8gd29ybGQgMw==</data></req>'
                      sent: 1; failed: 0; total: 1


                      I needed to specify every flag for every parameter. Otherwise it doesn't work out.

                      I guess I can continue from this point by myself.

                      Many thanks to Andrew and Alexei!!!

                      Best,

                      hs

                      Comment

                      • Alexei
                        Founder, CEO
                        Zabbix Certified Trainer
                        Zabbix Certified SpecialistZabbix Certified Professional
                        • Sep 2004
                        • 5654

                        #26
                        Originally posted by husse
                        I needed to specify every flag for every parameter. Otherwise it doesn't work out.
                        This is not required. You may specify path to a configuration file of ZABBIX agent, so the sender will parse it and get info about local host name and ZABBIX server to send the data to.
                        Alexei Vladishev
                        Creator of Zabbix, Product manager
                        New York | Tokyo | Riga
                        My Twitter

                        Comment

                        • shadowk
                          Junior Member
                          • Jun 2006
                          • 23

                          #27
                          Originally posted by husse
                          HOBBAAAAA.... It worked...
                          Cool, I'm running an older version of the sender here. Looks like some great improvements have been implemented!

                          Andrew

                          Comment

                          Working...