summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ohai/plugins/linux/hostnamectl.rb3
-rw-r--r--lib/ohai/plugins/linux/lsb.rb3
-rw-r--r--lib/ohai/plugins/linux/lspci.rb3
-rw-r--r--lib/ohai/plugins/netbsd/network.rb12
-rw-r--r--lib/ohai/plugins/openbsd/network.rb12
-rw-r--r--lib/ohai/plugins/solaris2/dmi.rb3
-rw-r--r--lib/ohai/plugins/solaris2/memory.rb3
-rw-r--r--lib/ohai/plugins/solaris2/network.rb4
-rw-r--r--lib/ohai/plugins/solaris2/virtualization.rb7
9 files changed, 16 insertions, 34 deletions
diff --git a/lib/ohai/plugins/linux/hostnamectl.rb b/lib/ohai/plugins/linux/hostnamectl.rb
index 960b7c42..10a7ec99 100644
--- a/lib/ohai/plugins/linux/hostnamectl.rb
+++ b/lib/ohai/plugins/linux/hostnamectl.rb
@@ -24,8 +24,7 @@ Ohai.plugin(:Hostnamectl) do
hostnamectl_path = which("hostnamectl")
if hostnamectl_path
- hostnamectl_cmd = shell_out(hostnamectl_path)
- hostnamectl_cmd.stdout.split("\n").each do |line|
+ shell_out(hostnamectl_path).stdout.split("\n").each do |line|
key, val = line.split(":")
hostnamectl[key.chomp.lstrip.tr(" ", "_").downcase] = val.chomp.lstrip
end
diff --git a/lib/ohai/plugins/linux/lsb.rb b/lib/ohai/plugins/linux/lsb.rb
index eb15178c..233651c3 100644
--- a/lib/ohai/plugins/linux/lsb.rb
+++ b/lib/ohai/plugins/linux/lsb.rb
@@ -24,8 +24,7 @@ Ohai.plugin(:LSB) do
if File.exist?("/usr/bin/lsb_release")
# From package redhat-lsb on Fedora/Redhat, lsb-release on Debian/Ubuntu
- so = shell_out("lsb_release -a")
- so.stdout.lines do |line|
+ shell_out("lsb_release -a").stdout.lines do |line|
case line
when /^Distributor ID:\s+(.+)$/
lsb[:id] = $1
diff --git a/lib/ohai/plugins/linux/lspci.rb b/lib/ohai/plugins/linux/lspci.rb
index 997544a5..4d51a7d0 100644
--- a/lib/ohai/plugins/linux/lspci.rb
+++ b/lib/ohai/plugins/linux/lspci.rb
@@ -24,7 +24,6 @@ Ohai.plugin(:Lspci) do
collect_data(:linux) do
devices = Mash.new
- lspci = shell_out("lspci -vnnmk")
h = /[0-9a-fA-F]/ # any hex digit
hh = /#{h}#{h}/ # any 2 hex digits
@@ -46,7 +45,7 @@ Ohai.plugin(:Lspci) do
end
end
- lspci.stdout.split("\n").each do |line|
+ shell_out("lspci -vnnmk").stdout.split("\n").each do |line|
dev = line.scan(/^(.*):\s(.*)$/)[0]
next if dev.nil?
diff --git a/lib/ohai/plugins/netbsd/network.rb b/lib/ohai/plugins/netbsd/network.rb
index 66cb6a20..ccd3ea8d 100644
--- a/lib/ohai/plugins/netbsd/network.rb
+++ b/lib/ohai/plugins/netbsd/network.rb
@@ -26,8 +26,7 @@ Ohai.plugin(:Network) do
counters Mash.new unless counters
counters[:network] ||= Mash.new
- so = shell_out("route -n get default")
- so.stdout.lines do |line|
+ shell_out("route -n get default").stdout.lines do |line|
if line =~ /(\w+): ([\w\.]+)/
case $1
when "gateway"
@@ -39,9 +38,8 @@ Ohai.plugin(:Network) do
end
iface = Mash.new
- so = shell_out("#{Ohai.abs_path( "/sbin/ifconfig" )} -a")
cint = nil
- so.stdout.lines do |line|
+ shell_out("#{Ohai.abs_path( "/sbin/ifconfig" )} -a").stdout.lines do |line|
if line =~ /^([0-9a-zA-Z\.]+):\s+/
cint = $1
iface[cint] = Mash.new
@@ -85,8 +83,7 @@ Ohai.plugin(:Network) do
end
end
- so = shell_out("arp -an")
- so.stdout.lines do |line|
+ shell_out("arp -an").stdout.lines do |line|
if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
next unless iface[$3] # this should never happen
@@ -102,8 +99,7 @@ Ohai.plugin(:Network) do
# Show the state of all network interfaces or a single interface
# which have been auto-configured (interfaces statically configured
# into a system, but not located at boot time are not shown).
- so = shell_out("netstat -idn")
- so.stdout.lines do |line|
+ shell_out("netstat -idn").stdout.lines do |line|
# Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll Drop
# em0 1500 <Link> 00:11:25:2d:90:be 3719557 0 3369969 0 0 0
# $1 $2 $3 $4 $5 $6 $7 $8
diff --git a/lib/ohai/plugins/openbsd/network.rb b/lib/ohai/plugins/openbsd/network.rb
index 14664860..083d187e 100644
--- a/lib/ohai/plugins/openbsd/network.rb
+++ b/lib/ohai/plugins/openbsd/network.rb
@@ -26,8 +26,7 @@ Ohai.plugin(:Network) do
counters Mash.new unless counters
counters[:network] ||= Mash.new
- so = shell_out("route -n get default")
- so.stdout.lines do |line|
+ shell_out("route -n get default").stdout.lines do |line|
if line =~ /(\w+): ([\w\.]+)/
case $1
when "gateway"
@@ -39,9 +38,8 @@ Ohai.plugin(:Network) do
end
iface = Mash.new
- so = shell_out( "#{Ohai.abs_path( "/sbin/ifconfig" )} -a" )
cint = nil
- so.stdout.lines do |line|
+ shell_out( "#{Ohai.abs_path( "/sbin/ifconfig" )} -a" ).stdout.lines do |line|
if line =~ /^([0-9a-zA-Z\.]+):\s+/
cint = $1
iface[cint] = Mash.new
@@ -85,8 +83,7 @@ Ohai.plugin(:Network) do
end
end
- so = shell_out("arp -an")
- so.stdout.lines do |line|
+ shell_out("arp -an").stdout.lines do |line|
if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
next unless iface[$3] # this should never happen
@@ -102,8 +99,7 @@ Ohai.plugin(:Network) do
# Show the state of all network interfaces or a single interface
# which have been auto-configured (interfaces statically configured
# into a system, but not located at boot time are not shown).
- so = shell_out("netstat -idn")
- so.stdout.lines do |line|
+ shell_out("netstat -idn").stdout.lines do |line|
# Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll Drop
# em0 1500 <Link> 00:11:25:2d:90:be 3719557 0 3369969 0 0 0
# $1 $2 $3 $4 $5 $6 $7 $8
diff --git a/lib/ohai/plugins/solaris2/dmi.rb b/lib/ohai/plugins/solaris2/dmi.rb
index d4b91a3b..806dd1f6 100644
--- a/lib/ohai/plugins/solaris2/dmi.rb
+++ b/lib/ohai/plugins/solaris2/dmi.rb
@@ -99,7 +99,6 @@ Ohai.plugin(:DMI) do
dmi_record = nil
field = nil
- so = shell_out("smbios")
# ==== EXAMPLE: ====
# ID SIZE TYPE
# 0 40 SMB_TYPE_BIOS (BIOS information)
@@ -111,7 +110,7 @@ Ohai.plugin(:DMI) do
# SMB_BIOSFL_PCI (PCI is supported)
# ... similar lines trimmed
# note the second level of indentation is via a *tab*
- so.stdout.lines do |raw_line|
+ shell_out("smbios").stdout.lines do |raw_line|
next if header_type_line.match(raw_line)
next if blank_line.match(raw_line)
diff --git a/lib/ohai/plugins/solaris2/memory.rb b/lib/ohai/plugins/solaris2/memory.rb
index 1c14be68..c2933b0f 100644
--- a/lib/ohai/plugins/solaris2/memory.rb
+++ b/lib/ohai/plugins/solaris2/memory.rb
@@ -20,8 +20,7 @@ Ohai.plugin(:Memory) do
collect_data(:solaris2) do
memory Mash.new
memory[:swap] = Mash.new
- meminfo = shell_out("prtconf | grep Memory").stdout
- memory[:total] = "#{meminfo.split[2].to_i * 1024}kB"
+ memory[:total] = "#{shell_out("prtconf | grep Memory").stdout.split[2].to_i * 1024}kB"
tokens = shell_out("swap -s").stdout.strip.split
used_swap = tokens[8][0..-1].to_i # strip k from end
diff --git a/lib/ohai/plugins/solaris2/network.rb b/lib/ohai/plugins/solaris2/network.rb
index aa60b21e..d2a9e7e7 100644
--- a/lib/ohai/plugins/solaris2/network.rb
+++ b/lib/ohai/plugins/solaris2/network.rb
@@ -102,10 +102,8 @@ Ohai.plugin(:Network) do
counters Mash.new unless counters
counters[:network] ||= Mash.new
- so = shell_out("ifconfig -a")
cint = nil
-
- so.stdout.lines do |line|
+ shell_out("ifconfig -a").stdout.lines do |line|
# regex: https://rubular.com/r/ZiIHbsnfiWPW1p
if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+)(?: index (\d+))?/
cint = $1
diff --git a/lib/ohai/plugins/solaris2/virtualization.rb b/lib/ohai/plugins/solaris2/virtualization.rb
index 3b85ea9d..6db8b28a 100644
--- a/lib/ohai/plugins/solaris2/virtualization.rb
+++ b/lib/ohai/plugins/solaris2/virtualization.rb
@@ -25,9 +25,7 @@ Ohai.plugin(:Virtualization) do
depends "dmi"
def collect_solaris_guestid
- command = "/usr/sbin/zoneadm list -p"
- so = shell_out(command)
- so.stdout.split(":").first
+ shell_out("/usr/sbin/zoneadm list -p").stdout.split(":").first
end
collect_data(:solaris2) do
@@ -56,8 +54,7 @@ Ohai.plugin(:Virtualization) do
if File.executable?("/usr/sbin/zoneadm")
zones = Mash.new
- so = shell_out("zoneadm list -pc")
- so.stdout.lines do |line|
+ shell_out("zoneadm list -pc").stdout.lines do |line|
info = line.chomp.split(/:/)
zones[info[1]] = {
"id" => info[0],