From d11d5aafb31041b23d94b2065fe973116a65a185 Mon Sep 17 00:00:00 2001 From: Jeffrey Clark Date: Wed, 26 Feb 2020 22:44:30 +0000 Subject: [PATCH] iproute support --- bin/purge_relay_logs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/purge_relay_logs b/bin/purge_relay_logs index 9f5714c..1094da5 100755 --- a/bin/purge_relay_logs +++ b/bin/purge_relay_logs @@ -139,10 +139,17 @@ sub check_local { return if ( $opt{host} eq $my_host ); my $target_addr = MHA::NodeUtil::get_ip( $opt{host} ); - my @ifconfig_result = `/sbin/ifconfig -a`; my %addrs; - for (@ifconfig_result) { - if (/\s*inet addr:([\d.]+)/) { + my @result; + + if (-e '/sbin/ip' && -x _) { + @result = `/sbin/ip -o addr` + } else { + @result = `/sbin/ifconfig -a`; + } + + for (@result) { + if (/\s*inet6? (?:addr:)?([^\/\s]+)/) { $addrs{$1} = 1; } }