Installation
- Copy the script file mtr.sh to the ExternalScripts folder on your Zabbix Server or Proxy.
- Make the script executable:
chmod +x mtr.sh
- Import the Template to your Zabbix Server.
- Link the template to the target host. From there on Zabbix Server or Proxy will discover and monitor the hops between itself and the target’s HOST IP using the {HOST.IP} macro.
Notes
These files and templates were tested and created on Zabbix 4.4 & 5.0 and Debian Linux 9 & 10 amd64 with the package mtr-tiny.
The XML file provided is exported from Zabbix 5.0.3.
This template creates a Master item, which executes the script and receives the MTR JSON output. From there on we have a Low-Level-Discovery rule, that discovery three item prototypes:
- Name of each Hop
- Average RTT(ms) of each Hop
- ICMP Loss% of each Hop
There are no Trigger or Graph prototypes in this template at the moment.
Parts of this Template are directly related to a reddit discussion, which gave me a very good starting point.
Example / Screenshot
Changelog
- 01 October 2020: initial commit.
Just 1 question
Copy the script file mtr.sh to the ExternalScripts folder on your Zabbix Server or Proxy.
Make the script executable: chmod +x mtr.sh
How and where to this in docker ?
Hi, I have no idea about Zabbix running in Docker. I would suggest to first check the official documentation, where this is described in detail as far as I know: https://www.zabbix.com/documentation/current/manual/installation/containers
And if this doesn’t help, politely ask in the Zabbix Telegram Community: https://t.me/ZabbixTech
I thank you for the beautiful work, but I do not understand how to add the IP where I want to use the MTR.
In the tutorial the point that I have difficulties is .4
Link the model to the target host. From there, the Zabbix Server or Proxy will discover and monitor the hops between themselves and the target’s host IP using {HOST. IP} macro.
In Zabbix, when you create a host, you have to create an interface, which contains an IP or DNS name. https://www.zabbix.com/documentation/current/manual/config/hosts/host
Most of the time, the interface will be of type “Agent” configured with an IP address.
This IP address, can be referenced in items, via the MACRO {HOST.IP}. https://www.zabbix.com/documentation/current/manual/appendix/macros/supported_by_location
So if you want to use this template, create a new host, give it an interface with the IP you want to monitor, and the template will pick that address automatically.
An alternative would be, to modify the templates master item, which is called “MTR Trace Master” and has an item key called “mtr.sh[{HOST.IP}]”, which you might change into: mtr.sh[1.2.3.4]
Let me know if this helps.
Hi Marco,
Thanks for this. Does this work against windows OS agents? I am repeatedly getting “Failed to execute command “/usr/lib/zabbix/externalscripts/mtr.sh ‘1.2.3.4’”: Timeout while executing a shell script.” Even though it runs fine on the proxy
Hi, i used this template and scripts,the following error occurred,how do i resolv this problem?
cannot extract value from json by path “$.report.hubs”: cannot parse as a valid JSON object: invalid object format, expected opening character ‘{‘ or ‘[‘ at: ‘sh: 1: /usr/lib/zabbix/externalscripts/mtr.sh: not found’
Hi Macro,
so as yang’s problem.. please help to check
zabbix 5.0 + centos7
cannot extract value from json by path “$.report.hubs”: cannot parse as a valid JSON object: invalid object format, expected opening character ‘{‘ or ‘[‘ at: ‘sh: 1: /usr/lib/zabbix/externalscripts/mtr.sh: not found’
How did you solve this issue?
Hey! Love this script. However one idea to improve it! Remove the {HOST} from the prototype! IE prototype example: MTR Hop {#HOP_ID}: – Average RTT(ms) vs MTR Hop {#HOP_ID}: {HOST} – Average RTT(ms)
That way when you create a dashboard, say referencing multiple internet connections from multiple ISP’s, the columns and/or cells will not be blank because 1 hop differs from another. 🙂
Thanks!
getting this error “Timeout while executing a shell script”