summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2010-04-24 16:15:22 +1000
committerJames Turnbull <james@lovedthanlost.net>2010-04-24 16:15:22 +1000
commit9a00eaeb3a26fa32f9fda2bf3ff733f5214864ba (patch)
treebf0f4559ae8cc296a366a604e06109096abf2717
parente19024bbef18a4a2053537415bfe16bfaff00b8a (diff)
downloadfacter-9a00eaeb3a26fa32f9fda2bf3ff733f5214864ba.tar.gz
facter-9a00eaeb3a26fa32f9fda2bf3ff733f5214864ba.tar.xz
facter-9a00eaeb3a26fa32f9fda2bf3ff733f5214864ba.zip
Fixed #2313 - Somewhat essential hardware facts not available on OpenBSD, patch included
Thanks to Joe McDonagh for the patch.
-rw-r--r--lib/facter/architecture.rb8
-rw-r--r--lib/facter/memory.rb41
-rw-r--r--lib/facter/processor.rb16
3 files changed, 65 insertions, 0 deletions
diff --git a/lib/facter/architecture.rb b/lib/facter/architecture.rb
index abd54da..e4aaeba 100644
--- a/lib/facter/architecture.rb
+++ b/lib/facter/architecture.rb
@@ -23,3 +23,11 @@ Facter.add(:architecture) do
end
end
end
+
+Facter.add(:architecture) do
+ confine :kernel => :openbsd
+ setcode do
+ architecture = Facter.value(:hardwaremodel)
+ end
+end
+
diff --git a/lib/facter/memory.rb b/lib/facter/memory.rb
index 6880731..f0f0d45 100644
--- a/lib/facter/memory.rb
+++ b/lib/facter/memory.rb
@@ -44,3 +44,44 @@ if Facter.value(:kernel) == "AIX"
end
end
end
+
+if Facter.value(:kernel) == "OpenBSD"
+ swap = Facter::Util::Resolution.exec('swapctl -l | sed 1d')
+ swapfree, swaptotal = 0, 0
+ swap.each do |dev|
+ if dev =~ /^\S+\s+(\S+)\s+\S+\s+(\S+)\s+.*$/
+ swaptotal += $1.to_i
+ swapfree += $2.to_i
+ end
+ end
+
+ Facter.add("SwapSize") do
+ confine :kernel => :openbsd
+ setcode do
+ Facter::Memory.scale_number(swaptotal.to_f,"kB")
+ end
+ end
+
+ Facter.add("SwapFree") do
+ confine :kernel => :openbsd
+ setcode do
+ Facter::Memory.scale_number(swapfree.to_f,"kB")
+ end
+ end
+
+ Facter.add("MemoryFree") do
+ confine :kernel => :openbsd
+ memfree = Facter::Util::Resolution.exec("vmstat | tail -n 1 | awk '{ print $5 }'")
+ setcode do
+ Facter::Memory.scale_number(memfree.to_f,"kB")
+ end
+ end
+
+ Facter.add("MemoryTotal") do
+ confine :kernel => :openbsd
+ memtotal = Facter::Util::Resolution.exec("sysctl hw.physmem | cut -d'=' -f2")
+ setcode do
+ Facter::Memory.scale_number(memtotal.to_f,"")
+ end
+ end
+end
diff --git a/lib/facter/processor.rb b/lib/facter/processor.rb
index 154cced..53998ff 100644
--- a/lib/facter/processor.rb
+++ b/lib/facter/processor.rb
@@ -72,3 +72,19 @@ if Facter.value(:kernel) == "AIX"
end
end
end
+
+if Facter.value(:kernel) == "OpenBSD"
+ Facter.add("Processor") do
+ confine :kernel => :openbsd
+ setcode do
+ Facter::Util::Resolution.exec("uname -p")
+ end
+ end
+
+ Facter.add("ProcessorCount") do
+ confine :kernel => :openbsd
+ setcode do
+ Facter::Util::Resolution.exec("sysctl hw.ncpu | cut -d'=' -f2")
+ end
+ end
+end