summaryrefslogtreecommitdiff
path: root/lib/ohai/plugins/openbsd
diff options
context:
space:
mode:
authorClaire McQuin <claire@opscode.com>2013-07-31 17:10:15 -0700
committerClaire McQuin <claire@opscode.com>2013-08-07 10:16:39 -0700
commit2fdf7078f3497c84ee8469d294030a3b169ea5d0 (patch)
treeb17bb9f89ee7c789e438e87d3a9a974b494a794d /lib/ohai/plugins/openbsd
parent07a1512d4b941c76bd62dcd27e1aa94969814e52 (diff)
downloadohai-2fdf7078f3497c84ee8469d294030a3b169ea5d0.tar.gz
convert plugins to new dsl.
Diffstat (limited to 'lib/ohai/plugins/openbsd')
-rw-r--r--lib/ohai/plugins/openbsd/cpu.rb34
-rw-r--r--lib/ohai/plugins/openbsd/filesystem.rb68
-rw-r--r--lib/ohai/plugins/openbsd/hostname.rb10
-rw-r--r--lib/ohai/plugins/openbsd/kernel.rb28
-rw-r--r--lib/ohai/plugins/openbsd/memory.rb148
-rw-r--r--lib/ohai/plugins/openbsd/network.rb184
-rw-r--r--lib/ohai/plugins/openbsd/platform.rb11
-rw-r--r--lib/ohai/plugins/openbsd/ps.rb12
-rw-r--r--lib/ohai/plugins/openbsd/uptime.rb21
-rw-r--r--lib/ohai/plugins/openbsd/virtualization.rb80
10 files changed, 317 insertions, 279 deletions
diff --git a/lib/ohai/plugins/openbsd/cpu.rb b/lib/ohai/plugins/openbsd/cpu.rb
index d350ada0..392f21af 100644
--- a/lib/ohai/plugins/openbsd/cpu.rb
+++ b/lib/ohai/plugins/openbsd/cpu.rb
@@ -16,23 +16,27 @@
# limitations under the License.
#
-provides 'cpu'
+Ohai.plugin(:Cpu) do
+ provides 'cpu'
-cpuinfo = Mash.new
+ collect_data do
+ cpuinfo = Mash.new
-# OpenBSD provides most cpu information via sysctl, the only thing we need to
-# to scrape from dmesg.boot is the cpu feature list.
-# cpu0: FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2
+ # OpenBSD provides most cpu information via sysctl, the only thing we need to
+ # to scrape from dmesg.boot is the cpu feature list.
+ # cpu0: FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2
-File.open("/var/run/dmesg.boot").each do |line|
- case line
- when /cpu\d+:\s+([A-Z]+$|[A-Z]+,.*$)/
- cpuinfo["flags"] = $1.downcase.split(',')
- end
-end
+ File.open("/var/run/dmesg.boot").each do |line|
+ case line
+ when /cpu\d+:\s+([A-Z]+$|[A-Z]+,.*$)/
+ cpuinfo["flags"] = $1.downcase.split(',')
+ end
+ end
-cpuinfo[:model_name] = from("sysctl -n hw.model")
-cpuinfo[:total] = from("sysctl -n hw.ncpu")
-cpuinfo[:mhz] = from("sysctl -n hw.cpuspeed")
+ cpuinfo[:model_name] = from("sysctl -n hw.model")
+ cpuinfo[:total] = from("sysctl -n hw.ncpu")
+ cpuinfo[:mhz] = from("sysctl -n hw.cpuspeed")
-cpu cpuinfo
+ cpu cpuinfo
+ end
+end
diff --git a/lib/ohai/plugins/openbsd/filesystem.rb b/lib/ohai/plugins/openbsd/filesystem.rb
index 90a76498..c50be3b9 100644
--- a/lib/ohai/plugins/openbsd/filesystem.rb
+++ b/lib/ohai/plugins/openbsd/filesystem.rb
@@ -16,42 +16,46 @@
# limitations under the License.
#
-provides "filesystem"
+Ohai.plugin(:Filesystem) do
+ provides "filesystem"
-fs = Mash.new
+ collect_data do
+ fs = Mash.new
-# Grab filesystem data from df
-popen4("df") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- case line
- when /^Filesystem/
- next
- when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
- filesystem = $1
- fs[filesystem] = Mash.new
- fs[filesystem]['kb_size'] = $2
- fs[filesystem]['kb_used'] = $3
- fs[filesystem]['kb_available'] = $4
- fs[filesystem]['percent_used'] = $5
- fs[filesystem]['mount'] = $6
+ # Grab filesystem data from df
+ popen4("df") do |pid, stdin, stdout, stderr|
+ stdin.close
+ stdout.each do |line|
+ case line
+ when /^Filesystem/
+ next
+ when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
+ filesystem = $1
+ fs[filesystem] = Mash.new
+ fs[filesystem]['kb_size'] = $2
+ fs[filesystem]['kb_used'] = $3
+ fs[filesystem]['kb_available'] = $4
+ fs[filesystem]['percent_used'] = $5
+ fs[filesystem]['mount'] = $6
+ end
+ end
end
- end
-end
-# Grab mount information from mount
-popen4("mount -l") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
- filesystem = $1
- fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
- fs[filesystem]['mount'] = $2
- fs[filesystem]['fs_type'] = $3
- fs[filesystem]['mount-options'] = $4.split(/,\s*/)
+ # Grab mount information from mount
+ popen4("mount -l") do |pid, stdin, stdout, stderr|
+ stdin.close
+ stdout.each do |line|
+ if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
+ filesystem = $1
+ fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
+ fs[filesystem]['mount'] = $2
+ fs[filesystem]['fs_type'] = $3
+ fs[filesystem]['mount-options'] = $4.split(/,\s*/)
+ end
+ end
end
+
+ # Set the filesystem data
+ filesystem fs
end
end
-
-# Set the filesystem data
-filesystem fs
diff --git a/lib/ohai/plugins/openbsd/hostname.rb b/lib/ohai/plugins/openbsd/hostname.rb
index 337203dd..a25ef821 100644
--- a/lib/ohai/plugins/openbsd/hostname.rb
+++ b/lib/ohai/plugins/openbsd/hostname.rb
@@ -16,7 +16,11 @@
# limitations under the License.
#
-provides "hostname", "fqdn"
+Ohai.plugin(:Hostname) do
+ provides "hostname", "fqdn"
-hostname from("hostname -s")
-fqdn from("hostname")
+ collect_data do
+ hostname from("hostname -s")
+ fqdn from("hostname")
+ end
+end
diff --git a/lib/ohai/plugins/openbsd/kernel.rb b/lib/ohai/plugins/openbsd/kernel.rb
index 38d14e81..02f7da99 100644
--- a/lib/ohai/plugins/openbsd/kernel.rb
+++ b/lib/ohai/plugins/openbsd/kernel.rb
@@ -16,20 +16,24 @@
# limitations under the License.
#
-provides "kernel"
+Ohai.plugin(:Kernel) do
+ provides "kernel"
-kernel[:os] = kernel[:name]
-kernel[:securelevel] = from_with_regex("sysctl kern.securelevel", /kern.securelevel=(.+)$/)
+ collect_data do
+ kernel[:os] = kernel[:name]
+ kernel[:securelevel] = from_with_regex("sysctl kern.securelevel", /kern.securelevel=(.+)$/)
-mod = Mash.new
-popen4("/usr/bin/modstat") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- # 1 7 0xc0400000 97f830 kernel
- if line =~ /(\d+)\s+(\d+)\s+([0-9a-fx]+)\s+([0-9a-fx]+)\s+([a-zA-Z0-9\_]+)/
- kld[$5] = { :size => $4, :refcount => $2 }
+ mod = Mash.new
+ popen4("/usr/bin/modstat") do |pid, stdin, stdout, stderr|
+ stdin.close
+ stdout.each do |line|
+ # 1 7 0xc0400000 97f830 kernel
+ if line =~ /(\d+)\s+(\d+)\s+([0-9a-fx]+)\s+([0-9a-fx]+)\s+([a-zA-Z0-9\_]+)/
+ kld[$5] = { :size => $4, :refcount => $2 }
+ end
+ end
end
+
+ kernel[:modules] = mod unless mod.empty?
end
end
-
-kernel[:modules] = mod unless mod.empty?
diff --git a/lib/ohai/plugins/openbsd/memory.rb b/lib/ohai/plugins/openbsd/memory.rb
index 54f554bf..9d8ad197 100644
--- a/lib/ohai/plugins/openbsd/memory.rb
+++ b/lib/ohai/plugins/openbsd/memory.rb
@@ -16,83 +16,87 @@
# limitations under the License.
#
-provides "memory"
+Ohai.plugin(:Memory) do
+ provides "memory"
-memory Mash.new
-memory[:swap] = Mash.new
+ collect_data do
+ memory Mash.new
+ memory[:swap] = Mash.new
-# $ vmstat -s
-# 4096 bytes per page
-# 514011 pages managed
-# 224519 pages free
-# 209339 pages active
-# 4647 pages inactive
-# 0 pages being paged out
-# 5 pages wired
-# 0 pages zeroed
-# 4 pages reserved for pagedaemon
-# 6 pages reserved for kernel
-# 262205 swap pages
-# 0 swap pages in use
-# 0 total anon's in system
-# 0 free anon's
-# 1192991609 page faults
-# 1369579301 traps
-# 814549706 interrupts
-# 771702498 cpu context switches
-# 208810590 fpu context switches
-# 492361360 software interrupts
-# 1161998825 syscalls
-# 0 pagein operations
-# 0 swap ins
-# 0 swap outs
-# 768352 forks
-# 16 forks where vmspace is shared
-# 1763 kernel map entries
-# 0 number of times the pagedaemon woke up
-# 0 revolutions of the clock hand
-# 0 pages freed by pagedaemon
-# 0 pages scanned by pagedaemon
-# 0 pages reactivated by pagedaemon
-# 0 busy pages found by pagedaemon
-# 1096393776 total name lookups
-# cache hits (37% pos + 2% neg) system 1% per-directory
-# deletions 0%, falsehits 6%, toolong 26%
-# 0 select collisions
+ # $ vmstat -s
+ # 4096 bytes per page
+ # 514011 pages managed
+ # 224519 pages free
+ # 209339 pages active
+ # 4647 pages inactive
+ # 0 pages being paged out
+ # 5 pages wired
+ # 0 pages zeroed
+ # 4 pages reserved for pagedaemon
+ # 6 pages reserved for kernel
+ # 262205 swap pages
+ # 0 swap pages in use
+ # 0 total anon's in system
+ # 0 free anon's
+ # 1192991609 page faults
+ # 1369579301 traps
+ # 814549706 interrupts
+ # 771702498 cpu context switches
+ # 208810590 fpu context switches
+ # 492361360 software interrupts
+ # 1161998825 syscalls
+ # 0 pagein operations
+ # 0 swap ins
+ # 0 swap outs
+ # 768352 forks
+ # 16 forks where vmspace is shared
+ # 1763 kernel map entries
+ # 0 number of times the pagedaemon woke up
+ # 0 revolutions of the clock hand
+ # 0 pages freed by pagedaemon
+ # 0 pages scanned by pagedaemon
+ # 0 pages reactivated by pagedaemon
+ # 0 busy pages found by pagedaemon
+ # 1096393776 total name lookups
+ # cache hits (37% pos + 2% neg) system 1% per-directory
+ # deletions 0%, falsehits 6%, toolong 26%
+ # 0 select collisions
-popen4("vmstat -s") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- case line
- when /(\d+) bytes per page/
- memory[:page_size] = $1
- when /(\d+) pages managed/
- memory[:page_count] = $1
- memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
- when /(\d+) pages free/
- memory[:free] = memory[:page_size].to_i * $1.to_i
- when /(\d+) pages active/
- memory[:active] = memory[:page_size].to_i * $1.to_i
- when /(\d+) pages inactive/
- memory[:inactive] = memory[:page_size].to_i * $1.to_i
- when /(\d+) pages wired/
- memory[:wired] = memory[:page_size].to_i * $1.to_i
+ popen4("vmstat -s") do |pid, stdin, stdout, stderr|
+ stdin.close
+ stdout.each do |line|
+ case line
+ when /(\d+) bytes per page/
+ memory[:page_size] = $1
+ when /(\d+) pages managed/
+ memory[:page_count] = $1
+ memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
+ when /(\d+) pages free/
+ memory[:free] = memory[:page_size].to_i * $1.to_i
+ when /(\d+) pages active/
+ memory[:active] = memory[:page_size].to_i * $1.to_i
+ when /(\d+) pages inactive/
+ memory[:inactive] = memory[:page_size].to_i * $1.to_i
+ when /(\d+) pages wired/
+ memory[:wired] = memory[:page_size].to_i * $1.to_i
+ end
end
- end
-end
+ end
-popen4("swapctl -l") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- # Device 1024-blocks Used Avail Capacity Priority
- # swap_device 1048824 0 1048824 0% 0
- if line =~ /^([\d\w\/]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\%]+)/
- mdev = $1
- memory[:swap][mdev] = Mash.new
- memory[:swap][mdev][:total] = $2
- memory[:swap][mdev][:used] = $3
- memory[:swap][mdev][:free] = $4
- memory[:swap][mdev][:percent_free] = $5
+ popen4("swapctl -l") do |pid, stdin, stdout, stderr|
+ stdin.close
+ stdout.each do |line|
+ # Device 1024-blocks Used Avail Capacity Priority
+ # swap_device 1048824 0 1048824 0% 0
+ if line =~ /^([\d\w\/]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\%]+)/
+ mdev = $1
+ memory[:swap][mdev] = Mash.new
+ memory[:swap][mdev][:total] = $2
+ memory[:swap][mdev][:used] = $3
+ memory[:swap][mdev][:free] = $4
+ memory[:swap][mdev][:percent_free] = $5
+ end
+ end
end
end
end
diff --git a/lib/ohai/plugins/openbsd/network.rb b/lib/ohai/plugins/openbsd/network.rb
index 4a3c18ef..08b53919 100644
--- a/lib/ohai/plugins/openbsd/network.rb
+++ b/lib/ohai/plugins/openbsd/network.rb
@@ -16,105 +16,109 @@
# limitations under the License.
#
-provides "network", "counters/network"
+Ohai.plugin(:Network) do
+ provides "network", "counters/network"
-from("route -n get default").split("\n").each do |line|
- if line =~ /(\w+): ([\w\.]+)/
- case $1
- when "gateway"
- network[:default_gateway] = $2
- when "interface"
- network[:default_interface] = $2
- end
- end
-end
-
-iface = Mash.new
-popen4("/sbin/ifconfig -a") do |pid, stdin, stdout, stderr|
- stdin.close
- cint = nil
- stdout.each do |line|
- if line =~ /^([0-9a-zA-Z\.]+):\s+/
- cint = $1
- iface[cint] = Mash.new
- if cint =~ /^(\w+)(\d+.*)/
- iface[cint][:type] = $1
- iface[cint][:number] = $2
+ collect_data do
+ from("route -n get default").split("\n").each do |line|
+ if line =~ /(\w+): ([\w\.]+)/
+ case $1
+ when "gateway"
+ network[:default_gateway] = $2
+ when "interface"
+ network[:default_interface] = $2
+ end
end
end
- # call the family lladdr to match linux for consistency
- if line =~ /\s+lladdr (.+?)\s/
- iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
- iface[cint][:addresses][$1] = { "family" => "lladdr" }
- end
- if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
- iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
- # convert the netmask to decimal for consistency
- netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}"
- if $3.empty?
- iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask }
- else
- # found a broadcast address
- iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask, "broadcast" => $3 }
- end
- end
- if line =~ /\s+inet6 ([a-f0-9\:]+)%?(\w*)\s+prefixlen\s+(\d+)\s*\w*\s*([\da-fx]*)/
- iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
- if $4.empty?
- iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
- else
- #found a zone_id / scope
- iface[cint][:addresses][$1] = { "family" => "inet6", "zoneid" => $2, "prefixlen" => $3, "scopeid" => $4 }
+
+ iface = Mash.new
+ popen4("/sbin/ifconfig -a") do |pid, stdin, stdout, stderr|
+ stdin.close
+ cint = nil
+ stdout.each do |line|
+ if line =~ /^([0-9a-zA-Z\.]+):\s+/
+ cint = $1
+ iface[cint] = Mash.new
+ if cint =~ /^(\w+)(\d+.*)/
+ iface[cint][:type] = $1
+ iface[cint][:number] = $2
+ end
+ end
+ # call the family lladdr to match linux for consistency
+ if line =~ /\s+lladdr (.+?)\s/
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
+ iface[cint][:addresses][$1] = { "family" => "lladdr" }
+ end
+ if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
+ # convert the netmask to decimal for consistency
+ netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}"
+ if $3.empty?
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask }
+ else
+ # found a broadcast address
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask, "broadcast" => $3 }
+ end
+ end
+ if line =~ /\s+inet6 ([a-f0-9\:]+)%?(\w*)\s+prefixlen\s+(\d+)\s*\w*\s*([\da-fx]*)/
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
+ if $4.empty?
+ iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
+ else
+ #found a zone_id / scope
+ iface[cint][:addresses][$1] = { "family" => "inet6", "zoneid" => $2, "prefixlen" => $3, "scopeid" => $4 }
+ end
+ end
+ if line =~ /flags=\d+<(.+)>/
+ flags = $1.split(',')
+ iface[cint][:flags] = flags if flags.length > 0
+ end
+ if line =~ /metric: (\d+) mtu: (\d+)/
+ iface[cint][:metric] = $1
+ iface[cint][:mtu] = $2
+ end
end
end
- if line =~ /flags=\d+<(.+)>/
- flags = $1.split(',')
- iface[cint][:flags] = flags if flags.length > 0
- end
- if line =~ /metric: (\d+) mtu: (\d+)/
- iface[cint][:metric] = $1
- iface[cint][:mtu] = $2
- end
- end
-end
-popen4("arp -an") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each 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
- iface[$3][:arp] = Mash.new unless iface[$3][:arp]
- iface[$3][:arp][$1] = $2.downcase
+ popen4("arp -an") do |pid, stdin, stdout, stderr|
+ stdin.close
+ stdout.each 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
+ iface[$3][:arp] = Mash.new unless iface[$3][:arp]
+ iface[$3][:arp][$1] = $2.downcase
+ end
+ end
end
- end
-end
-network["interfaces"] = iface
+ network["interfaces"] = iface
-net_counters = Mash.new
-# From netstat(1), not sure of the implications:
-# 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).
-popen4("netstat -idn") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each 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
- if line =~ /^([\w\.\*]+)\s+\d+\s+<Link>\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
- cint = $1
- net_counters[cint] = Mash.new unless net_counters[cint]
- net_counters[cint] = Mash.new unless net_counters[cint]["rx"]
- net_counters[cint] = Mash.new unless net_counters[cint]["tx"]
- net_counters[cint] = $3
- net_counters[cint] = $4
- net_counters[cint] = $5
- net_counters[cint] = $6
- net_counters[cint] = $7
- net_counters[cint] = $8
+ net_counters = Mash.new
+ # From netstat(1), not sure of the implications:
+ # 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).
+ popen4("netstat -idn") do |pid, stdin, stdout, stderr|
+ stdin.close
+ stdout.each 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
+ if line =~ /^([\w\.\*]+)\s+\d+\s+<Link>\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
+ cint = $1
+ net_counters[cint] = Mash.new unless net_counters[cint]
+ net_counters[cint] = Mash.new unless net_counters[cint]["rx"]
+ net_counters[cint] = Mash.new unless net_counters[cint]["tx"]
+ net_counters[cint] = $3
+ net_counters[cint] = $4
+ net_counters[cint] = $5
+ net_counters[cint] = $6
+ net_counters[cint] = $7
+ net_counters[cint] = $8
+ end
+ end
end
+
+ counters[:network][:interfaces] = net_counters
end
end
-
-counters[:network][:interfaces] = net_counters
diff --git a/lib/ohai/plugins/openbsd/platform.rb b/lib/ohai/plugins/openbsd/platform.rb
index 78697e72..45891989 100644
--- a/lib/ohai/plugins/openbsd/platform.rb
+++ b/lib/ohai/plugins/openbsd/platform.rb
@@ -16,8 +16,11 @@
# limitations under the License.
#
-provides "platform", "platform_version"
-
-platform from("uname -s").downcase
-platform_version from("uname -r")
+Ohai.plugin(:Platform) do
+ provides "platform", "platform_version"
+ collect_data do
+ platform from("uname -s").downcase
+ platform_version from("uname -r")
+ end
+end
diff --git a/lib/ohai/plugins/openbsd/ps.rb b/lib/ohai/plugins/openbsd/ps.rb
index f4823327..876ded11 100644
--- a/lib/ohai/plugins/openbsd/ps.rb
+++ b/lib/ohai/plugins/openbsd/ps.rb
@@ -16,9 +16,13 @@
# limitations under the License.
#
-provides "command/ps"
+Ohai.plugin(:Ps) do
+ provides "command/ps"
-require_plugin 'command'
+ depends 'command'
-# ps -e requires procfs
-command[:ps] = 'ps -ax'
+ collect_data do
+ # ps -e requires procfs
+ command[:ps] = 'ps -ax'
+ end
+end
diff --git a/lib/ohai/plugins/openbsd/uptime.rb b/lib/ohai/plugins/openbsd/uptime.rb
index 6028d1e7..82f16383 100644
--- a/lib/ohai/plugins/openbsd/uptime.rb
+++ b/lib/ohai/plugins/openbsd/uptime.rb
@@ -16,17 +16,20 @@
# limitations under the License.
#
-provides "uptime", "uptime_seconds"
+Ohai.plugin(:Uptime) do
+ provides "uptime", "uptime_seconds"
-# kern.boottime=Tue Nov 1 14:45:52 2011
+ # kern.boottime=Tue Nov 1 14:45:52 2011
-popen4("/sbin/sysctl kern.boottime") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- if line =~ /kern.boottime=(.+)/
- uptime_seconds Time.new.to_i - Time.parse($1).to_i
- uptime seconds_to_human(uptime_seconds)
+ collect_data do
+ popen4("/sbin/sysctl kern.boottime") do |pid, stdin, stdout, stderr|
+ stdin.close
+ stdout.each do |line|
+ if line =~ /kern.boottime=(.+)/
+ uptime_seconds Time.new.to_i - Time.parse($1).to_i
+ uptime seconds_to_human(uptime_seconds)
+ end
+ end
end
end
end
-
diff --git a/lib/ohai/plugins/openbsd/virtualization.rb b/lib/ohai/plugins/openbsd/virtualization.rb
index f351e4af..bc3072db 100644
--- a/lib/ohai/plugins/openbsd/virtualization.rb
+++ b/lib/ohai/plugins/openbsd/virtualization.rb
@@ -16,48 +16,52 @@
# limitations under the License.
#
-provides "virtualization"
+Ohai.plugin(:Virtualization) do
+ provides "virtualization"
-virtualization Mash.new
+ collect_data do
+ virtualization Mash.new
-# KVM Host support for FreeBSD is in development
-# http://feanor.sssup.it/~fabio/freebsd/lkvm/
+ # KVM Host support for FreeBSD is in development
+ # http://feanor.sssup.it/~fabio/freebsd/lkvm/
-# Detect KVM/QEMU from cpu, report as KVM
-# hw.model: QEMU Virtual CPU version 0.9.1
-if from("sysctl -n hw.model") =~ /QEMU Virtual CPU/
- virtualization[:system] = "kvm"
- virtualization[:role] = "guest"
-end
+ # Detect KVM/QEMU from cpu, report as KVM
+ # hw.model: QEMU Virtual CPU version 0.9.1
+ if from("sysctl -n hw.model") =~ /QEMU Virtual CPU/
+ virtualization[:system] = "kvm"
+ virtualization[:role] = "guest"
+ end
-# http://www.dmo.ca/blog/detecting-virtualization-on-linux
-if File.exists?("/usr/local/sbin/dmidecode")
- popen4("dmidecode") do |pid, stdin, stdout, stderr|
- stdin.close
- found_virt_manufacturer = nil
- found_virt_product = nil
- stdout.each do |line|
- case line
- when /Manufacturer: Microsoft/
- found_virt_manufacturer = "microsoft"
- when /Product Name: Virtual Machine/
- found_virt_product = "microsoft"
- when /Version: 5.0/
- if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
- virtualization[:system] = "virtualpc"
- virtualization[:role] = "guest"
- end
- when /Version: VS2005R2/
- if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
- virtualization[:system] = "virtualserver"
- virtualization[:role] = "guest"
- end
- when /Manufacturer: VMware/
- found_virt_manufacturer = "vmware"
- when /Product Name: VMware Virtual Platform/
- if found_virt_manufacturer == "vmware"
- virtualization[:system] = "vmware"
- virtualization[:role] = "guest"
+ # http://www.dmo.ca/blog/detecting-virtualization-on-linux
+ if File.exists?("/usr/local/sbin/dmidecode")
+ popen4("dmidecode") do |pid, stdin, stdout, stderr|
+ stdin.close
+ found_virt_manufacturer = nil
+ found_virt_product = nil
+ stdout.each do |line|
+ case line
+ when /Manufacturer: Microsoft/
+ found_virt_manufacturer = "microsoft"
+ when /Product Name: Virtual Machine/
+ found_virt_product = "microsoft"
+ when /Version: 5.0/
+ if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
+ virtualization[:system] = "virtualpc"
+ virtualization[:role] = "guest"
+ end
+ when /Version: VS2005R2/
+ if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
+ virtualization[:system] = "virtualserver"
+ virtualization[:role] = "guest"
+ end
+ when /Manufacturer: VMware/
+ found_virt_manufacturer = "vmware"
+ when /Product Name: VMware Virtual Platform/
+ if found_virt_manufacturer == "vmware"
+ virtualization[:system] = "vmware"
+ virtualization[:role] = "guest"
+ end
+ end
end
end
end