MRTG/Routers2: Counting Traceroute Hops

I was interested in generating graphs within the MRTG/Routers2 monitoring system that display the number of hops for an IP connection through the Internet. In my opinion its interesting to see the different routing run times/hop counts e.g. for remote offices that are connected via dynamic ISP connections such as DSL. Therefore, I wrote a small script that executes a traceroute command which can be called from MRTG.

Traceroute Script

Here comes my script “traceroute2mrtg” which needs the destination host as a parameter: traceroute2mrtg www.webernetz.net . It calls the “traceroute” command with a few options and stores the hop count in a variable. If the destination was not reachable for traceroute, the maximum hop count of “30” is change to a “0” to have the MRTG graphs to show *nothing* instead of *30* in this case.

I have moved this script to “/usr/local/bin” and, of course, made it executable: sudo chmod u+x traceroute2mrtg .

Note that the reported values are NOT the actual hop count to the destination since the last line in a traceroute reveals the final destination. That is, the real hop count would be the reported value decremented by one. However, I am not changing this value by “-1” because I do not want to confuse myself when comparing the MRTG graphs with some other traceroute tests.

Here is an example of my script:

 

MRTG/Routers2 Config

Following is my MRTG/Routers2 configuration part for the hop count. It mainly calls my script with the destination host “domain.name”.

Note that I specified the “maximum” option. That is, the weekly, monthly, and yearly graphs will show the maximum hop count for its ranges and NOT the averages with a maximum line above them. This is more useful if certain destinations are down for a longer time and MRTG stores “0”. If the maximum option would not be specified, the average values for a week would be much lower than realistic ones if the destination was not reachable for a few days, for example.

Also note that the average calculations on the graphs (the middle column with text) are NOT realistic if a destination is not reachable for a certain amount of time. It is only meaningful if the destination was reachable all the time. This behaviour cannot be changed here since there is no option to tell MRTG/Routers2 to “not display the Avg values if the values return a zero”.

Sample Graphs

Here are a few examples from my monitoring system. The first one reveals that the hop count to the destination changes incessantly between 15 and 16 hops. Here, the calculated average value of 15 makes sense:

nuern.cfg-nuern_traceroute-d-l2

The second one presents the hop count to a dynamic ISP connection which restarts every night. The hop count switches between 13 and 15 hops:

fdorf.cfg-fdorf_traceroute-w-l2

The last one shows the hop counts to one of the domains of the NTP Pool Project, in this case 0.de.pool.ntp.org . This DNS name changes its IP addresses by round robin every 150 seconds. Since my MRTG installations runs every 5 minutes, I am getting a new IP address on every run. Of course all destinations have different hop counts, mainly between 10 and 14 hops. However, some of these nodes do not reply to the ping requests, which results in values of “0” in the graphs. That is, the calculated average values do NOT make sense here.

WeiterePings.cfg-WeiterePings_tr_0.de.pool.ntp.org-d-l2

Leave a Reply

Your email address will not be published. Required fields are marked *