Ad Widget

Collapse

How to return traceroute hops

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • balrog
    Junior Member
    • Nov 2010
    • 3

    #1

    How to return traceroute hops

    Hello everyone,

    I would like to poll a parallel wireless redundant link with Zabbix. The idea here is that if one of the wireless links go down, then the device on the other end for the failed link may still be reachable through the second link in a roundabout way.

    I believe the best approach would be to run a traceroute on both links, and if the total hops exceed "2" for either link, then Zabbix would have a trigger to alert.

    *How can I use a traceroute command and return the number of hops to Zabbix as a value (a value of 2 in this case).

    Thank you.
  • danrog
    Senior Member
    • Sep 2009
    • 164

    #2
    It's not all that hard

    Create a user parameter on the agents you want to test from that runs a trace route piped through awk, sed or tail to strip out the header and do a wc -l to count the number of hops returned. Then you can create an item and a tigger for that user parameter

    Something like

    UserParameter=traceroute[*],traceroute -n $1 | tail -2 | wc -l

    I'm not in front of a shell to test this and I forget the tail syntax to remember if that's right but it should get you started. You might also want to add logic that returns 0 if there are a bunch of failed paths (denoted by trace route using *'s)

    Comment

    • balrog
      Junior Member
      • Nov 2010
      • 3

      #3
      Danrog,

      Thanks for your reply. Your instructions indicate creating a user parameter on the agent. Would that be the host in Zabbix, or the agent running on a remote computer? The devices that I would like to poll are network devices, specifically wireless bridges that would not have the Zabbix agent installed.

      Thanks.

      Comment

      • danrog
        Senior Member
        • Sep 2009
        • 164

        #4
        Ahh...I see now. So its still the same but in reverse. You'd create this parameter in the zabbix server's agent config file or any host that has an agent installed. Then you just need to calculate the number of hops the from the agent to the wireless bridge device and alarm if that changes. Unfortunately unless this wireless bridge has some sort of scripting capabilities, IP SLA or some other SNMP exposed traceroute feature you would have to run the traceroute from a zabbix agent

        Here is what I would use:
        Code:
        UserParameter=traceroute[*],traceroute -I -w 1 -m 6 $1 | awk -v host=$1 'END { if ($2$3 ~ host) print $1; else print 0 }'
        This looks for the host/ip in the last line of the traceroute output and prints the hop number. If its not found, it prints 0.

        Comment

        • qix
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Oct 2006
          • 423

          #5
          You might run into routing problems if you try to reach the same host on the other end via different paths from the same host machine. (Only one entry in your routing table is normally used, or it is setup to load balance traffic which can make results unreliable in this case.)

          I haven't looked in to it yet, but perhaps the SSH/telnet 'agent' could be of use here? Anybody have any experience on using that type of item for polling remote devices?
          With kind regards,

          Raymond

          Comment

          • balrog
            Junior Member
            • Nov 2010
            • 3

            #6
            Danrog,

            Ok, let's assume for a moment that we use a Zabbix agent, would there be a way to return specific values from the traceroute, like the highest individual value of all the hops, or an average of all the hops?

            Thank you for your help.

            Comment

            • danrog
              Senior Member
              • Sep 2009
              • 164

              #7
              This would be a little bit more difficult to setup properly using traceroute and script. But could be done. You will just have to create a script that does this. If you are looking for specific host latencies, then I would just setup a icmpsec monitor to the invidual hosts.

              Comment

              Working...