diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-11-18 11:58:51 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-11-18 11:58:51 -0800 |
commit | b2b801e3d570ead66c6b29c8311292de43eab12c (patch) | |
tree | eff84ff2ace1f960199f007ac090ed8be41bd287 | |
parent | 78e536837b07fd4d92259e6d6b7682d18fbd9aeb (diff) | |
download | ohai-b2b801e3d570ead66c6b29c8311292de43eab12c.tar.gz |
Avoid running the regex for each line
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/aix/network.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/ohai/plugins/aix/network.rb b/lib/ohai/plugins/aix/network.rb index 2c4006b6..cb40e09a 100644 --- a/lib/ohai/plugins/aix/network.rb +++ b/lib/ohai/plugins/aix/network.rb @@ -105,12 +105,10 @@ Ohai.plugin(:Network) do end # Query macaddress - e_so = shell_out("entstat -d #{int_name}") - e_so.stdout.each_line do |l| - if l =~ /Hardware Address: (\S+)/ - ifaces[int_name][:addresses][$1.upcase] = { "family" => "lladdr" } - macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0 - end + shell_out("entstat -d #{int_name}").stdout =~ /Hardware Address: (\S+)/ + if $1 + ifaces[int_name][:addresses][$1.upcase] = { "family" => "lladdr" } + macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0 end end # ifconfig stdout |