{"id":196,"date":"2017-03-05T21:25:44","date_gmt":"2017-03-05T20:25:44","guid":{"rendered":"https:\/\/jeremyverda.net\/?p=196"},"modified":"2019-02-05T22:27:40","modified_gmt":"2019-02-05T21:27:40","slug":"traceroute-with-zabbix-and-mtr","status":"publish","type":"post","link":"https:\/\/jeremyverda.net\/traceroute-with-zabbix-and-mtr\/","title":{"rendered":"Traceroute with Zabbix and MTR"},"content":{"rendered":"

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.<\/p>\n

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.<\/p>\n

To keep this history in Zabbix, we are using “MTR<\/a>” instead of the traditional “traceroute” command.<\/p>\n

Here is a small explanation of what MTR is, taken from the Github page of the project :<\/p>\n

mtr combines the functionality of the ‘traceroute’ and ‘ping’ programs <\/em>
\n in a single network diagnostic tool.<\/em><\/p>\n

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

Here is an example of the command output :<\/p>\n

\"\"<\/p>\n

MTR is installed on our Zabbix proxies and on the main server.<\/p>\n

Under Debian, the command to install MTR is :<\/p>\n

sudo aptitude install mtr<\/pre>\n

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.<\/p>\n

Here is the local script :<\/p>\n

#!\/usr\/bin\/env bash\nIP=$1\nmtr -r -c3 -w -b $IP\n<\/pre>\n

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

Once you have created the file, you have to allow Zabbix to execute it by using the following commands :<\/p>\n

chmod +x mtrtrace.sh\nchown zabbix:zabbix mtrtrace.sh\n<\/pre>\n

Then import the following template in Zabbix web interface and link it to a host :<\/p>\n