Traceroute with Zabbix and MTR

At the company I work for, we are using Zabbix to monitor our infrastructure and in some case we are using “traceroute” to keep an eye on our network from different locations.

By keeping a traceroute history, it can help you to understand some networking problem by example when you are facing packet loss from some location.

To keep this history in Zabbix, we are using “MTR” instead of the traditional “traceroute” command.

Here is a small explanation of what MTR is, taken from the Github page of the project :

mtr combines the functionality of the ‘traceroute’ and ‘ping’ programs
in a single network diagnostic tool.

As mtr starts, it investigates the network connection between the host
mtr runs on and a user-specified destination host. After it
determines the address of each network hop between the machines,
it sends a sequence of ICMP ECHO requests to each one to determine the
quality of the link to each machine. As it does this, it prints
running statistics about each machine. 

Here is an example of the command output :

MTR is installed on our Zabbix proxies and on the main server.

Under Debian, the command to install MTR is :

sudo aptitude install mtr

As we are using proxies and active agents, the remote commands are not supported. So we have deployed a local script on the server and proxies.

Here is the local script :

#!/usr/bin/env bash
mtr -r -c3 -w -b $IP

This local script is named “” and is saved under the “externalscripts” directory of Zabbix. The path can be found in the proxy or server configuration file under the following configuration key : “ExternalScripts“. Under Debian it’s “/usr/lib/zabbix/externalscripts“.

Once you have created the file, you have to allow Zabbix to execute it by using the following commands :

chmod +x
chown zabbix:zabbix

Then import the following template in Zabbix web interface and link it to a host : MTR History (exported from Zabbix 3.2.x)

If you prefer to add it in an existing template, here are the settings :

It will use the first ” IP address” in the “Agent interfaces” part of the host configuration.

You will find the history of data under the application “Traceroute” and in the item ” MTR Trace” on the “Latest data” tab of the configured host.

Here is an example of data from this tab :

Please note that, it’s recommended to increase the “Timeout” value in the Zabbix Server and Proxies configuration files to use this script. On my side it takes 10 seconds in average to be completely executed.

7 thoughts on “Traceroute with Zabbix and MTR”

  1. I liked your zabbix and mtr article. Very helpful!

    With the version of mtr that comes with CentOS 6.x, I found that I needed to alter the script parameters slightly:

    #!/usr/bin/env bash
    mtr -r -c3 -w -showips $IP

    (The “-b” switch you used doesn’t work with this particular version of MTR.)

    I found you’ll also need to make some permission changes on the mtr binary:

    chmod 4755 /usr/sbin/mtr
    chown root:zabbix

    1. Hi,

      Thanks for your feedback.
      As I work with Debian I did not make the test with CentOS.
      I will try to check with the 7.x if there is the same problem.


  2. Hi,I test it with CentOS7,but error happened:
    9599:20170808:120012.616 item “[{HOST.IP}]” became not supported: Timeout while executing a shell script.

  3. Hello kkxue,

    I’m glad you solved this problem.
    I will move the warning about that because, the end of the post, it’s not the best place to be put it.

    I hope that this template will help you.

  4. Hi,

    I’ve accepted your PR.
    Thanks for your work. It’s a strange problem because it was exported from Zabbix 3.2 directly and not modified after.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.