From 90666d10eb34f2a9b3cab1f5ed48befb82fb9f22 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 26 Oct 2014 19:50:37 +0000 Subject: [PATCH] polypath-interface-monitor-linux: Debugging output Signed-off-by: Ian Jackson --- polypath-interface-monitor-linux | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/polypath-interface-monitor-linux b/polypath-interface-monitor-linux index 1b02bfa..bce8436 100755 --- a/polypath-interface-monitor-linux +++ b/polypath-interface-monitor-linux @@ -5,6 +5,13 @@ use IO::Handle; my $us = $0; $us =~ s{.*/}{}; +open DEBUG, ">/dev/null" or die $!; + +if (@ARGV && $ARGV[0] eq '-D') { + shift @ARGV; + open DEBUG, ">&STDERR" or die $!; +} + die "$us: no arguments permitted\n" if @ARGV; our ($monh,$monchild); @@ -44,12 +51,15 @@ for (;;) { die "monitor failed\n" unless $got; } $_='r' foreach values %reported; + print DEBUG "#########################################\n"; foreach my $ip (qw(4 6)) { + print DEBUG "###### $ip:\n"; my $addrh = new IO::File; open $addrh, "-|", qw(ip -o), "-$ip", qw(addr show) or die "spawn addr $ip show: $!\n"; my $afstr = $ip==4 ? 'inet' : $ip==6 ? 'inet6' : die; while (<$addrh>) { + print DEBUG "#$_"; if (m{^\d+\:\s*(\S+)\s+$afstr\s+([0-9a-z.:]+)(?:/\d+)?\s}) { my $outline = "$ip $1 $2"; $reported{$outline} .= "y"; -- 2.30.2