diff options
-rw-r--r-- | lib/ohai/plugins/aix/network.rb | 14 | ||||
-rw-r--r-- | spec/unit/plugins/aix/network_spec.rb | 14 |
2 files changed, 20 insertions, 8 deletions
diff --git a/lib/ohai/plugins/aix/network.rb b/lib/ohai/plugins/aix/network.rb index 02d064e7..f36c3dd8 100644 --- a/lib/ohai/plugins/aix/network.rb +++ b/lib/ohai/plugins/aix/network.rb @@ -44,16 +44,16 @@ Ohai.plugin(:Network) do # We unfortunately have to do things a bit different here, if ohai is running # within a WPAR. For instance, the WPAR isn't aware of some of its own networking - # minutia such as default gateway/route. + # minutia such as default gateway/route. lpars return 0 here. wpars return > 0 unless shell_out("uname -W").stdout.to_i > 0 # :default_interface, :default_gateway - route -n get 0 - so = shell_out("netstat -rn |grep default") - so.stdout.lines.each do |line| + netstat_so = shell_out("netstat -rn").stdout + netstat_so.each_line do |line| + next unless line.start_with?('default') items = line.split(" ") - if items[0] == "default" - network[:default_gateway] = items[1] - network[:default_interface] = items[5] - end + network[:default_gateway] = items[1] + network[:default_interface] = items[5] + return end end diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb index 85c4c73f..dcc94a90 100644 --- a/spec/unit/plugins/aix/network_spec.rb +++ b/spec/unit/plugins/aix/network_spec.rb @@ -21,7 +21,19 @@ require "spec_helper" describe Ohai::System, "AIX network plugin" do before do @netstat_rn_grep_default = <<~NETSTAT_RN_GREP_DEFAULT - default 172.31.8.1 UG 2 121789 en0 - - + Destination Gateway Flags Refcnt Use Interface + Destination Gateway Flags Refs Use If Exp Groups + Only the root user can specify the Z flag + (Internet): + default 172.31.0.1 UG 2 1652046 en0 - - => + 127/8 127.0.0.1 U 5 2455591 lo0 - - => + 172.31.0.0 172.31.10.23 UHSb 0 0 en0 - - => + 172.31/20 172.31.10.23 U 1 1015674 en0 - - => + 172.31.10.23 127.0.0.1 UGHS 0 1 lo0 - - + 172.31.15.255 172.31.10.23 UHSb 0 1 en0 - - => + Only the root user can specify the Z flag + (Internet v6): + ::1%1 ::1%1 UH 1 677032 lo0 - - => NETSTAT_RN_GREP_DEFAULT @ifconfig = <<~IFCONFIG |