Commit 58639c2e authored by PhiBo's avatar PhiBo 🚀

src - Option to resolve the hostnames of the hops

parent 7fc694ae
...@@ -97,6 +97,11 @@ $mp->add_arg( ...@@ -97,6 +97,11 @@ $mp->add_arg(
default => 4, default => 4,
); );
$mp->add_arg(
spec => 'dns',
help => 'Try to resolve the hostnames of the hops.',
);
$mp->getopts; $mp->getopts;
check(); check();
...@@ -108,8 +113,13 @@ sub check ...@@ -108,8 +113,13 @@ sub check
{ {
my @cmd; my @cmd;
push(@cmd, 'mtr'); push(@cmd, 'mtr');
push(@cmd, ('-n', '--report', '--report-wide')); push(@cmd, ('--report', '--report-wide'));
push(@cmd, ('--report-cycles', $mp->opts->cycles)); push(@cmd, ('--report-cycles', $mp->opts->cycles));
if ($mp->opts->dns) {
push(@cmd, '--show-ip');
} else {
push(@cmd, '--no-dns');
}
if ($mp->opts->tcp && $mp->opts->udp) { if ($mp->opts->tcp && $mp->opts->udp) {
wrap_exit(UNKNOWN, 'TCP and UDP mode can not be used in combination'); wrap_exit(UNKNOWN, 'TCP and UDP mode can not be used in combination');
} elsif ($mp->opts->tcp) { } elsif ($mp->opts->tcp) {
...@@ -136,10 +146,10 @@ sub check ...@@ -136,10 +146,10 @@ sub check
my $hop_reachable = 1; my $hop_reachable = 1;
foreach my $line (@output) { foreach my $line (@output) {
my $status = OK; my $status = OK;
if ($line =~ /^\s*(\d+).\s*[|-]+?\s+([0-9a-f.:\?]+)\s+(\d+.\d+)%?\s+(\d+)\s+(\d+.\d+)\s+(\d+.\d+)\s+(.*?)\s.*?$/) { if ($line =~ /^\s*(\d+).\s*[|-]+?\s+(([0-9a-f.:\?]+)|(\S+)\s+\(([0-9a-f.:\?]+)\))\s+(\d+.\d+)%?\s+(\d+)\s+(\d+.\d+)\s+(\d+.\d+)\s+(.*?)\s.*?$/) {
my $host_address = $2; my $host_address = $2;
my $latency_value = $6; my $latency_value = $9;
my $packet_loss_value = $3; my $packet_loss_value = $6;
my $latency_status = OK; my $latency_status = OK;
my $packet_loss_status = OK; my $packet_loss_status = OK;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment