summaryrefslogtreecommitdiff
path: root/lib/ohai/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ohai/plugins')
-rw-r--r--lib/ohai/plugins/aix/cpu.rb21
-rw-r--r--lib/ohai/plugins/aix/filesystem.rb21
-rw-r--r--lib/ohai/plugins/aix/memory.rb21
-rw-r--r--lib/ohai/plugins/aix/network.rb21
-rw-r--r--lib/ohai/plugins/aix/platform.rb21
-rw-r--r--lib/ohai/plugins/aix/uptime.rb21
-rw-r--r--lib/ohai/plugins/azure.rb2
-rw-r--r--lib/ohai/plugins/c.rb2
-rw-r--r--lib/ohai/plugins/chef.rb14
-rw-r--r--lib/ohai/plugins/cloud.rb2
-rw-r--r--lib/ohai/plugins/command.rb2
-rw-r--r--lib/ohai/plugins/darwin/cpu.rb4
-rw-r--r--lib/ohai/plugins/darwin/filesystem.rb4
-rw-r--r--lib/ohai/plugins/darwin/kernel.rb41
-rw-r--r--lib/ohai/plugins/darwin/network.rb11
-rw-r--r--lib/ohai/plugins/darwin/platform.rb4
-rw-r--r--lib/ohai/plugins/darwin/ps.rb27
-rw-r--r--lib/ohai/plugins/darwin/system_profiler.rb4
-rw-r--r--lib/ohai/plugins/darwin/uptime.rb33
-rw-r--r--lib/ohai/plugins/dmi.rb6
-rw-r--r--lib/ohai/plugins/ec2.rb8
-rw-r--r--lib/ohai/plugins/erlang.rb2
-rw-r--r--lib/ohai/plugins/eucalyptus.rb6
-rw-r--r--lib/ohai/plugins/freebsd/cpu.rb4
-rw-r--r--lib/ohai/plugins/freebsd/filesystem.rb4
-rw-r--r--lib/ohai/plugins/freebsd/kernel.rb40
-rw-r--r--lib/ohai/plugins/freebsd/memory.rb6
-rw-r--r--lib/ohai/plugins/freebsd/network.rb7
-rw-r--r--lib/ohai/plugins/freebsd/platform.rb7
-rw-r--r--lib/ohai/plugins/freebsd/ps.rb28
-rw-r--r--lib/ohai/plugins/freebsd/uptime.rb33
-rw-r--r--lib/ohai/plugins/freebsd/virtualization.rb4
-rw-r--r--lib/ohai/plugins/gce.rb2
-rw-r--r--lib/ohai/plugins/groovy.rb2
-rw-r--r--lib/ohai/plugins/hostname.rb10
-rw-r--r--lib/ohai/plugins/hpux/cpu.rb21
-rw-r--r--lib/ohai/plugins/hpux/filesystem.rb21
-rw-r--r--lib/ohai/plugins/hpux/memory.rb21
-rw-r--r--lib/ohai/plugins/hpux/network.rb21
-rw-r--r--lib/ohai/plugins/hpux/platform.rb21
-rw-r--r--lib/ohai/plugins/hpux/ps.rb27
-rw-r--r--lib/ohai/plugins/hpux/uptime.rb21
-rw-r--r--lib/ohai/plugins/ip_scopes.rb5
-rw-r--r--lib/ohai/plugins/java.rb2
-rw-r--r--lib/ohai/plugins/kernel.rb203
-rw-r--r--lib/ohai/plugins/keys.rb2
-rw-r--r--lib/ohai/plugins/languages.rb2
-rw-r--r--lib/ohai/plugins/linode.rb4
-rw-r--r--lib/ohai/plugins/linux/block_device.rb4
-rw-r--r--lib/ohai/plugins/linux/cpu.rb4
-rw-r--r--lib/ohai/plugins/linux/filesystem.rb4
-rw-r--r--lib/ohai/plugins/linux/kernel.rb36
-rw-r--r--lib/ohai/plugins/linux/lsb.rb4
-rw-r--r--lib/ohai/plugins/linux/memory.rb6
-rw-r--r--lib/ohai/plugins/linux/network.rb9
-rw-r--r--lib/ohai/plugins/linux/platform.rb7
-rw-r--r--lib/ohai/plugins/linux/ps.rb27
-rw-r--r--lib/ohai/plugins/linux/uptime.rb29
-rw-r--r--lib/ohai/plugins/linux/virtualization.rb4
-rw-r--r--lib/ohai/plugins/lua.rb2
-rw-r--r--lib/ohai/plugins/mono.rb2
-rw-r--r--lib/ohai/plugins/netbsd/cpu.rb4
-rw-r--r--lib/ohai/plugins/netbsd/filesystem.rb4
-rw-r--r--lib/ohai/plugins/netbsd/kernel.rb39
-rw-r--r--lib/ohai/plugins/netbsd/memory.rb4
-rw-r--r--lib/ohai/plugins/netbsd/network.rb7
-rw-r--r--lib/ohai/plugins/netbsd/platform.rb7
-rw-r--r--lib/ohai/plugins/netbsd/ps.rb28
-rw-r--r--lib/ohai/plugins/netbsd/uptime.rb33
-rw-r--r--lib/ohai/plugins/netbsd/virtualization.rb4
-rw-r--r--lib/ohai/plugins/network.rb6
-rw-r--r--lib/ohai/plugins/network_listeners.rb9
-rw-r--r--lib/ohai/plugins/nodejs.rb2
-rw-r--r--lib/ohai/plugins/ohai.rb16
-rw-r--r--lib/ohai/plugins/ohai_time.rb2
-rw-r--r--lib/ohai/plugins/openbsd/cpu.rb4
-rw-r--r--lib/ohai/plugins/openbsd/filesystem.rb4
-rw-r--r--lib/ohai/plugins/openbsd/kernel.rb40
-rw-r--r--lib/ohai/plugins/openbsd/memory.rb6
-rw-r--r--lib/ohai/plugins/openbsd/network.rb7
-rw-r--r--lib/ohai/plugins/openbsd/platform.rb7
-rw-r--r--lib/ohai/plugins/openbsd/ps.rb28
-rw-r--r--lib/ohai/plugins/openbsd/uptime.rb33
-rw-r--r--lib/ohai/plugins/openbsd/virtualization.rb4
-rw-r--r--lib/ohai/plugins/openstack.rb2
-rw-r--r--lib/ohai/plugins/os.rb2
-rw-r--r--lib/ohai/plugins/passwd.rb2
-rw-r--r--lib/ohai/plugins/perl.rb2
-rw-r--r--lib/ohai/plugins/php.rb2
-rw-r--r--lib/ohai/plugins/platform.rb9
-rw-r--r--lib/ohai/plugins/ps.rb (renamed from lib/ohai/plugins/aix/ps.rb)17
-rw-r--r--lib/ohai/plugins/python.rb2
-rw-r--r--lib/ohai/plugins/rackspace.rb5
-rw-r--r--lib/ohai/plugins/root_group.rb2
-rw-r--r--lib/ohai/plugins/ruby.rb2
-rw-r--r--lib/ohai/plugins/sigar/cpu.rb8
-rw-r--r--lib/ohai/plugins/sigar/filesystem.rb11
-rw-r--r--lib/ohai/plugins/sigar/memory.rb7
-rw-r--r--lib/ohai/plugins/sigar/network.rb103
-rw-r--r--lib/ohai/plugins/sigar/network_route.rb11
-rw-r--r--lib/ohai/plugins/sigar/platform.rb10
-rw-r--r--lib/ohai/plugins/sigar/uptime.rb30
-rw-r--r--lib/ohai/plugins/solaris2/dmi.rb4
-rw-r--r--lib/ohai/plugins/solaris2/filesystem.rb4
-rw-r--r--lib/ohai/plugins/solaris2/kernel.rb41
-rw-r--r--lib/ohai/plugins/solaris2/network.rb11
-rw-r--r--lib/ohai/plugins/solaris2/platform.rb8
-rw-r--r--lib/ohai/plugins/solaris2/ps.rb27
-rw-r--r--lib/ohai/plugins/solaris2/uptime.rb38
-rw-r--r--lib/ohai/plugins/solaris2/virtualization.rb4
-rw-r--r--lib/ohai/plugins/solaris2/zpools.rb4
-rw-r--r--lib/ohai/plugins/ssh_host_key.rb2
-rw-r--r--lib/ohai/plugins/uptime.rb99
-rw-r--r--lib/ohai/plugins/virtualization.rb8
-rw-r--r--lib/ohai/plugins/windows/cpu.rb8
-rw-r--r--lib/ohai/plugins/windows/filesystem.rb8
-rw-r--r--lib/ohai/plugins/windows/kernel.rb64
-rw-r--r--lib/ohai/plugins/windows/network.rb11
-rw-r--r--lib/ohai/plugins/windows/platform.rb6
-rw-r--r--lib/ohai/plugins/windows/uptime.rb27
120 files changed, 587 insertions, 1266 deletions
diff --git a/lib/ohai/plugins/aix/cpu.rb b/lib/ohai/plugins/aix/cpu.rb
deleted file mode 100644
index 990b5ec1..00000000
--- a/lib/ohai/plugins/aix/cpu.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::cpu"
-end
diff --git a/lib/ohai/plugins/aix/filesystem.rb b/lib/ohai/plugins/aix/filesystem.rb
deleted file mode 100644
index fb0aaddc..00000000
--- a/lib/ohai/plugins/aix/filesystem.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::filesystem"
-end
diff --git a/lib/ohai/plugins/aix/memory.rb b/lib/ohai/plugins/aix/memory.rb
deleted file mode 100644
index e711fe25..00000000
--- a/lib/ohai/plugins/aix/memory.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::memory"
-end
diff --git a/lib/ohai/plugins/aix/network.rb b/lib/ohai/plugins/aix/network.rb
deleted file mode 100644
index 807b4a4a..00000000
--- a/lib/ohai/plugins/aix/network.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::network"
-end
diff --git a/lib/ohai/plugins/aix/platform.rb b/lib/ohai/plugins/aix/platform.rb
deleted file mode 100644
index 9f142810..00000000
--- a/lib/ohai/plugins/aix/platform.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::platform"
-end
diff --git a/lib/ohai/plugins/aix/uptime.rb b/lib/ohai/plugins/aix/uptime.rb
deleted file mode 100644
index 324ced96..00000000
--- a/lib/ohai/plugins/aix/uptime.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::uptime"
-end
diff --git a/lib/ohai/plugins/azure.rb b/lib/ohai/plugins/azure.rb
index be97b030..27454f48 100644
--- a/lib/ohai/plugins/azure.rb
+++ b/lib/ohai/plugins/azure.rb
@@ -1,5 +1,5 @@
-Ohai.plugin do
+Ohai.plugin(:Azure) do
provides "azure"
collect_data do
diff --git a/lib/ohai/plugins/c.rb b/lib/ohai/plugins/c.rb
index 9eb5d36e..36bb13db 100644
--- a/lib/ohai/plugins/c.rb
+++ b/lib/ohai/plugins/c.rb
@@ -18,7 +18,7 @@
require 'rbconfig'
-Ohai.plugin do
+Ohai.plugin(:C) do
provides "languages/c"
depends "languages"
diff --git a/lib/ohai/plugins/chef.rb b/lib/ohai/plugins/chef.rb
index bbe16b46..fd9b7889 100644
--- a/lib/ohai/plugins/chef.rb
+++ b/lib/ohai/plugins/chef.rb
@@ -16,15 +16,15 @@
# limitations under the License.
#
-require 'chef/version'
-
-Ohai.plugin do
+Ohai.plugin(:Chef) do
provides "chef_packages/chef"
collect_data do
- self[:chef_packages] = Mash.new unless self[:chef_packages]
- self[:chef_packages][:chef] = Mash.new
- self[:chef_packages][:chef][:version] = Chef::VERSION
- self[:chef_packages][:chef][:chef_root] = Chef::CHEF_ROOT
+ require 'chef/version'
+
+ chef_packages Mash.new unless chef_packages
+ chef_packages[:chef] = Mash.new
+ chef_packages[:chef][:version] = Chef::VERSION
+ chef_packages[:chef][:chef_root] = Chef::CHEF_ROOT
end
end
diff --git a/lib/ohai/plugins/cloud.rb b/lib/ohai/plugins/cloud.rb
index 76913871..e8019074 100644
--- a/lib/ohai/plugins/cloud.rb
+++ b/lib/ohai/plugins/cloud.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-Ohai.plugin do
+Ohai.plugin(:Cloud) do
provides "cloud"
depends "ec2"
diff --git a/lib/ohai/plugins/command.rb b/lib/ohai/plugins/command.rb
index 7c49ab3c..930846a5 100644
--- a/lib/ohai/plugins/command.rb
+++ b/lib/ohai/plugins/command.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Command) do
provides "command"
collect_data do
diff --git a/lib/ohai/plugins/darwin/cpu.rb b/lib/ohai/plugins/darwin/cpu.rb
index 6f1dc035..f43554b9 100644
--- a/lib/ohai/plugins/darwin/cpu.rb
+++ b/lib/ohai/plugins/darwin/cpu.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:CPU) do
provides "cpu"
- collect_data do
+ collect_data(:darwin) do
cpu Mash.new
so = shell_out("sysctl -n hw.physicalcpu")
cpu[:real] = so.stdout.to_i
diff --git a/lib/ohai/plugins/darwin/filesystem.rb b/lib/ohai/plugins/darwin/filesystem.rb
index 905df94d..83c8a6cf 100644
--- a/lib/ohai/plugins/darwin/filesystem.rb
+++ b/lib/ohai/plugins/darwin/filesystem.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Filesystem) do
provides "filesystem"
- collect_data do
+ collect_data(:darwin) do
fs = Mash.new
block_size = 0
diff --git a/lib/ohai/plugins/darwin/kernel.rb b/lib/ohai/plugins/darwin/kernel.rb
deleted file mode 100644
index 51e2e4ef..00000000
--- a/lib/ohai/plugins/darwin/kernel.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "kernel/os", "kernel/machine", "kernel/modules"
- depends "kernel/name"
-
- collect_data do
- kernel[:os] = kernel[:name]
-
- so = shell_out("sysctl -n hw.optional.x86_64")
- if so.stdout.split($/)[0].to_i == 1
- kernel[:machine] = 'x86_64'
- end
-
- kext = Mash.new
- so = shell_out("kextstat -k -l")
- so.stdout.lines do |line|
- if line =~ /(\d+)\s+(\d+)\s+0x[0-9a-f]+\s+0x([0-9a-f]+)\s+0x[0-9a-f]+\s+([a-zA-Z0-9\.]+) \(([0-9\.]+)\)/
- kext[$4] = { :version => $5, :size => $3.hex, :index => $1, :refcount => $2 }
- end
- end
-
- kernel[:modules] = kext
- end
-end
diff --git a/lib/ohai/plugins/darwin/network.rb b/lib/ohai/plugins/darwin/network.rb
index cf209a97..4ed63eb7 100644
--- a/lib/ohai/plugins/darwin/network.rb
+++ b/lib/ohai/plugins/darwin/network.rb
@@ -16,10 +16,9 @@
# limitations under the License.
#
-require 'scanf'
-
-Ohai.plugin do
- provides "network", "counters/network"
+Ohai.plugin(:Network) do
+ provides "network", "network/interfaces"
+ provides "counters/network", "counters/network/interfaces"
def parse_media(media_string)
media = Hash.new
@@ -84,7 +83,9 @@ Ohai.plugin do
nil
end
- collect_data do
+ collect_data(:darwin) do
+ require 'scanf'
+
network Mash.new unless network
network[:interfaces] = Mash.new unless network[:interfaces]
counters Mash.new unless counters
diff --git a/lib/ohai/plugins/darwin/platform.rb b/lib/ohai/plugins/darwin/platform.rb
index a96cc0a9..fc26544c 100644
--- a/lib/ohai/plugins/darwin/platform.rb
+++ b/lib/ohai/plugins/darwin/platform.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Platform) do
provides "platform", "platform_version", "platform_build", "platform_family"
- collect_data do
+ collect_data(:darwin) do
so = shell_out("#{ Ohai.abs_path( "/usr/bin/sw_vers" )}")
so.stdout.lines do |line|
case line
diff --git a/lib/ohai/plugins/darwin/ps.rb b/lib/ohai/plugins/darwin/ps.rb
deleted file mode 100644
index 013c1eb0..00000000
--- a/lib/ohai/plugins/darwin/ps.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "command/ps"
-
- depends 'command'
-
- collect_data do
- command[:ps] = 'ps -ef'
- end
-end
diff --git a/lib/ohai/plugins/darwin/system_profiler.rb b/lib/ohai/plugins/darwin/system_profiler.rb
index 5c364beb..e3756d3f 100644
--- a/lib/ohai/plugins/darwin/system_profiler.rb
+++ b/lib/ohai/plugins/darwin/system_profiler.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:SystemProfile) do
provides "system_profile"
- collect_data do
+ collect_data(:darwin) do
begin
require 'plist'
diff --git a/lib/ohai/plugins/darwin/uptime.rb b/lib/ohai/plugins/darwin/uptime.rb
deleted file mode 100644
index 4d966cd5..00000000
--- a/lib/ohai/plugins/darwin/uptime.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Bryan McLellan (btm@loftninjas.org)
-# Copyright:: Copyright (c) 2009 Bryan McLellan
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "uptime", "uptime_seconds"
-
- # kern.boottime: { sec = 1232765114, usec = 823118 } Fri Jan 23 18:45:14 2009
-
- collect_data do
- so = shell_out("#{ Ohai.abs_path( "/usr/sbin/sysctl" )} kern.boottime")
- so.stdout.lines do |line|
- if line =~ /kern.boottime:\D+(\d+)/
- uptime_seconds Time.new.to_i - $1.to_i
- uptime seconds_to_human(uptime_seconds)
- end
- end
- end
-end
diff --git a/lib/ohai/plugins/dmi.rb b/lib/ohai/plugins/dmi.rb
index 48bcb5e1..81c271e9 100644
--- a/lib/ohai/plugins/dmi.rb
+++ b/lib/ohai/plugins/dmi.rb
@@ -16,14 +16,14 @@
# limitations under the License.
#
-require "ohai/plugins/dmi_common"
-
-Ohai.plugin do
+Ohai.plugin(:DMI) do
provides "dmi"
# dmidecode does not return data without access to /dev/mem (or its equivalent)
collect_data do
+ require "ohai/plugins/dmi_common"
+
dmi Mash.new
# all output lines should fall within one of these patterns
diff --git a/lib/ohai/plugins/ec2.rb b/lib/ohai/plugins/ec2.rb
index 2df62ac7..e7ab945d 100644
--- a/lib/ohai/plugins/ec2.rb
+++ b/lib/ohai/plugins/ec2.rb
@@ -19,14 +19,12 @@
require 'ohai/mixin/ec2_metadata'
-Ohai.plugin do
+Ohai.plugin(:EC2) do
include Ohai::Mixin::Ec2Metadata
-
+
provides "ec2"
- depends "fqdn", "domain"
- depends "kernel"
- depends "network", "counters/network"
+ depends "network/interfaces"
def has_ec2_mac?
network[:interfaces].values.each do |iface|
diff --git a/lib/ohai/plugins/erlang.rb b/lib/ohai/plugins/erlang.rb
index e398fc61..ebea9da7 100644
--- a/lib/ohai/plugins/erlang.rb
+++ b/lib/ohai/plugins/erlang.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Erlang) do
provides "languages/erlang"
depends "languages"
diff --git a/lib/ohai/plugins/eucalyptus.rb b/lib/ohai/plugins/eucalyptus.rb
index 2d84cb21..c5fed2f0 100644
--- a/lib/ohai/plugins/eucalyptus.rb
+++ b/lib/ohai/plugins/eucalyptus.rb
@@ -19,14 +19,12 @@
require 'ohai/mixin/ec2_metadata'
-Ohai.plugin do
+Ohai.plugin(:Eucalyptus) do
include Ohai::Mixin::Ec2Metadata
provides "eucalyptus"
- depends "fqdn", "domain"
- depends "kernel"
- depends "network"
+ depends "network/interfaces"
def get_mac_address(addresses)
detected_addresses = addresses.detect { |address, keypair| keypair == {"family"=>"lladdr"} }
diff --git a/lib/ohai/plugins/freebsd/cpu.rb b/lib/ohai/plugins/freebsd/cpu.rb
index 7512c042..1a9c97cf 100644
--- a/lib/ohai/plugins/freebsd/cpu.rb
+++ b/lib/ohai/plugins/freebsd/cpu.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:CPU) do
provides "cpu"
- collect_data do
+ collect_data(:freebsd) do
# all dmesg output for smp I can find only provides info about a single processor
# identical processors is probably a hardware requirement so we'll duplicate data for each cpu
# old examples: http://www.bnv-bamberg.de/home/ba3294/smp/rbuild/index.htm
diff --git a/lib/ohai/plugins/freebsd/filesystem.rb b/lib/ohai/plugins/freebsd/filesystem.rb
index 7131cdad..b0037512 100644
--- a/lib/ohai/plugins/freebsd/filesystem.rb
+++ b/lib/ohai/plugins/freebsd/filesystem.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Filesystem) do
provides "filesystem"
- collect_data do
+ collect_data(:freebsd) do
fs = Mash.new
# Grab filesystem data from df
diff --git a/lib/ohai/plugins/freebsd/kernel.rb b/lib/ohai/plugins/freebsd/kernel.rb
deleted file mode 100644
index e5a5a314..00000000
--- a/lib/ohai/plugins/freebsd/kernel.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Author:: Bryan McLellan (btm@loftninjas.org)
-# Copyright:: Copyright (c) 2009 Bryan McLellan
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "kernel"
-
- collect_data do
- kernel[:os] = kernel[:name]
- so = shell_out("uname -i")
- kernel[:ident] = so.stdout.split($/)[0]
- so = shell_out("sysctl kern.securelevel")
- kernel[:securelevel] = so.stdout.split($/).select { |e| e =~ /kern.securelevel: (.+)$/ }
-
- kld = Mash.new
- so = shell_out("#{ Ohai.abs_path( "/sbin/kldstat" )}")
- so.stdout.lines 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
-
- kernel[:modules] = kld
- end
-end
diff --git a/lib/ohai/plugins/freebsd/memory.rb b/lib/ohai/plugins/freebsd/memory.rb
index 969c89f2..842f9689 100644
--- a/lib/ohai/plugins/freebsd/memory.rb
+++ b/lib/ohai/plugins/freebsd/memory.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "memory"
+Ohai.plugin(:Memory) do
+ provides "memory", "memory/swap"
- collect_data do
+ collect_data(:freebsd) do
memory Mash.new
memory[:swap] = Mash.new
diff --git a/lib/ohai/plugins/freebsd/network.rb b/lib/ohai/plugins/freebsd/network.rb
index 2286e033..6f5eed5b 100644
--- a/lib/ohai/plugins/freebsd/network.rb
+++ b/lib/ohai/plugins/freebsd/network.rb
@@ -16,9 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "network", "counters/network"
-
+Ohai.plugin(:Network) do
+ provides "network", "network/interfaces"
+ provides "counters/network", "counters/network/interfaces"
+
collect_data do
network Mash.new unless network
network[:interfaces] = Mash.new unless network[:interfaces]
diff --git a/lib/ohai/plugins/freebsd/platform.rb b/lib/ohai/plugins/freebsd/platform.rb
index 0bfaee77..bef7b73e 100644
--- a/lib/ohai/plugins/freebsd/platform.rb
+++ b/lib/ohai/plugins/freebsd/platform.rb
@@ -16,13 +16,14 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "platform", "platform_version"
+Ohai.plugin(:Platform) do
+ provides "platform", "platform_version", "platform_family"
- collect_data do
+ collect_data(:freebsd) do
so = shell_out("uname -s")
platform so.stdout.split($/)[0].downcase
so = shell_out("uname -r")
platform_version so.stdout.split($/)[0]
+ platform_family "freebsd"
end
end
diff --git a/lib/ohai/plugins/freebsd/ps.rb b/lib/ohai/plugins/freebsd/ps.rb
deleted file mode 100644
index 8bde6414..00000000
--- a/lib/ohai/plugins/freebsd/ps.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Author:: Bryan McLellan (btm@loftninjas.org)
-# Copyright:: Copyright (c) 2009 Bryan McLellan
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "command/ps"
-
- depends 'command'
-
- collect_data do
- # ps -e requires procfs
- command[:ps] = 'ps -ax'
- end
-end
diff --git a/lib/ohai/plugins/freebsd/uptime.rb b/lib/ohai/plugins/freebsd/uptime.rb
deleted file mode 100644
index db05656f..00000000
--- a/lib/ohai/plugins/freebsd/uptime.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Bryan McLellan (btm@loftninjas.org)
-# Copyright:: Copyright (c) 2009 Bryan McLellan
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "uptime", "uptime_seconds"
-
- # kern.boottime: { sec = 1232765114, usec = 823118 } Fri Jan 23 18:45:14 2009
-
- collect_data do
- so = shell_out("#{ Ohai.abs_path( "/sbin/sysctl" )} kern.boottime")
- so.stdout.lines do |line|
- if line =~ /kern.boottime:\D+(\d+)/
- uptime_seconds Time.new.to_i - $1.to_i
- uptime seconds_to_human(uptime_seconds)
- end
- end
- end
-end
diff --git a/lib/ohai/plugins/freebsd/virtualization.rb b/lib/ohai/plugins/freebsd/virtualization.rb
index 3a7ae79c..aedcb694 100644
--- a/lib/ohai/plugins/freebsd/virtualization.rb
+++ b/lib/ohai/plugins/freebsd/virtualization.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Virtualization) do
provides "virtualization"
- collect_data do
+ collect_data(:freebsd) do
virtualization Mash.new
so = shell_out("sysctl -n security.jail.jailed")
diff --git a/lib/ohai/plugins/gce.rb b/lib/ohai/plugins/gce.rb
index 75930ec3..1fc2841e 100644
--- a/lib/ohai/plugins/gce.rb
+++ b/lib/ohai/plugins/gce.rb
@@ -16,7 +16,7 @@
require 'ohai/mixin/gce_metadata'
-Ohai.plugin do
+Ohai.plugin(:GCE) do
include Ohai::Mixin::GCEMetadata
provides "gce"
diff --git a/lib/ohai/plugins/groovy.rb b/lib/ohai/plugins/groovy.rb
index de45e0e9..044a6e33 100644
--- a/lib/ohai/plugins/groovy.rb
+++ b/lib/ohai/plugins/groovy.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Groovy) do
provides "languages/groovy"
depends "languages"
diff --git a/lib/ohai/plugins/hostname.rb b/lib/ohai/plugins/hostname.rb
index 9016ebf1..779af3ec 100644
--- a/lib/ohai/plugins/hostname.rb
+++ b/lib/ohai/plugins/hostname.rb
@@ -1,6 +1,14 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Author:: Benjamin Black (<nostromo@gmail.com>)
+# Author:: Bryan McLellan (<btm@loftninjas.org>)
+# Author:: Daniel DeLeo (<dan@kallistec.com>)
+# Author:: Doug MacEachern (<dougm@vmware.com>)
+# Author:: James Gartrell (<jgartrel@gmail.com>)
+# Copyright:: Copyright (c) 2008, 2009 Opscode, Inc.
+# Copyright:: Copyright (c) 2009 Bryan McLellan
+# Copyright:: Copyright (c) 2009 Daniel DeLeo
+# Copyright:: Copyright (c) 2010 VMware, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/lib/ohai/plugins/hpux/cpu.rb b/lib/ohai/plugins/hpux/cpu.rb
deleted file mode 100644
index 990b5ec1..00000000
--- a/lib/ohai/plugins/hpux/cpu.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::cpu"
-end
diff --git a/lib/ohai/plugins/hpux/filesystem.rb b/lib/ohai/plugins/hpux/filesystem.rb
deleted file mode 100644
index fb0aaddc..00000000
--- a/lib/ohai/plugins/hpux/filesystem.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::filesystem"
-end
diff --git a/lib/ohai/plugins/hpux/memory.rb b/lib/ohai/plugins/hpux/memory.rb
deleted file mode 100644
index e711fe25..00000000
--- a/lib/ohai/plugins/hpux/memory.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::memory"
-end
diff --git a/lib/ohai/plugins/hpux/network.rb b/lib/ohai/plugins/hpux/network.rb
deleted file mode 100644
index 807b4a4a..00000000
--- a/lib/ohai/plugins/hpux/network.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::network"
-end
diff --git a/lib/ohai/plugins/hpux/platform.rb b/lib/ohai/plugins/hpux/platform.rb
deleted file mode 100644
index 9f142810..00000000
--- a/lib/ohai/plugins/hpux/platform.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::platform"
-end
diff --git a/lib/ohai/plugins/hpux/ps.rb b/lib/ohai/plugins/hpux/ps.rb
deleted file mode 100644
index 51e4e44f..00000000
--- a/lib/ohai/plugins/hpux/ps.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "command/ps"
-
- depends 'command'
-
- collect_data do
- command[:ps] = 'ps -ef'
- end
-end
diff --git a/lib/ohai/plugins/hpux/uptime.rb b/lib/ohai/plugins/hpux/uptime.rb
deleted file mode 100644
index 324ced96..00000000
--- a/lib/ohai/plugins/hpux/uptime.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- depends "sigar::uptime"
-end
diff --git a/lib/ohai/plugins/ip_scopes.rb b/lib/ohai/plugins/ip_scopes.rb
index 62ab6cd0..261bea5b 100644
--- a/lib/ohai/plugins/ip_scopes.rb
+++ b/lib/ohai/plugins/ip_scopes.rb
@@ -15,11 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-Ohai.plugin do
+Ohai.plugin(:IpScopes) do
provides "network_ip_scope", "privateaddress"
- depends "domain", "fqdn"
- depends "network", "counters/network"
+ depends "network/interfaces"
collect_data do
begin
diff --git a/lib/ohai/plugins/java.rb b/lib/ohai/plugins/java.rb
index 6a620a80..11a5a643 100644
--- a/lib/ohai/plugins/java.rb
+++ b/lib/ohai/plugins/java.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Java) do
provides "languages/java"
depends "languages"
diff --git a/lib/ohai/plugins/kernel.rb b/lib/ohai/plugins/kernel.rb
index 17ae07aa..66af66c8 100644
--- a/lib/ohai/plugins/kernel.rb
+++ b/lib/ohai/plugins/kernel.rb
@@ -1,40 +1,203 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Author:: Benjamin Black (<nostromo@gmail.com>)
+# Author:: Bryan McLellan (<btm@loftninjas.org>)
+# Author:: Claire McQuin (<claire@opscode.com>)
+# Author:: James Gartrell (<jgartrel@gmail.com>)
+# Copyright:: Copyright (c) 2008, 2009, 2013 Opscode, Inc.
+# Copyright:: Copyright (c) 2009 Bryan McLellan
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-Ohai.plugin do
- provides "kernel"
- provides "kernel/name", "kernel/release", "kernel/version", "kernel/machine", "kernel/modules"
+Ohai.plugin(:Kernel) do
+ provides "kernel", "kernel/modules"
- depends "languages/ruby"
-
- collect_data do
+ # common initial kernel attribute values
+ def init_kernel
kernel Mash.new
- case languages[:ruby][:host_os]
- when /mswin|mingw32|windows/
- require_plugin "windows::kernel"
- require_plugin "windows::kernel_devices"
- else
- [["uname -s", :name], ["uname -r", :release],
- ["uname -v", :version], ["uname -m", :machine]].each do |command, node|
- so = shell_out(command)
- kernel[node] = so.stdout.split($/)[0]
+ [["uname -s", :name], ["uname -r", :release],
+ ["uname -v", :version], ["uname -m", :machine]].each do |cmd, property|
+ so = shell_out(cmd)
+ kernel[property] = so.stdout.split($/)[0]
+ end
+ kernel
+ end
+
+ # common *bsd code for collecting modules data
+ def bsd_modules(path)
+ modules = Mash.new
+ so = shell_out("#{Ohai.abs_path(path)}")
+ so.stdout.lines 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\_]+)/
+ modules[$5] = { :size => $4, :refcount => $2 }
+ end
+ end
+ modules
+ end
+
+ # windows
+ def machine_lookup(sys_type)
+ return "i386" if sys_type.eql?("X86-based PC")
+ return "x86_64" if sys_type.eql?("x64-based PC")
+ sys_type
+ end
+
+ # windows
+ def os_lookup(sys_type)
+ return "Unknown" if sys_type.to_s.eql?("0")
+ return "Other" if sys_type.to_s.eql?("1")
+ return "MSDOS" if sys_type.to_s.eql?("14")
+ return "WIN3x" if sys_type.to_s.eql?("15")
+ return "WIN95" if sys_type.to_s.eql?("16")
+ return "WIN98" if sys_type.to_s.eql?("17")
+ return "WINNT" if sys_type.to_s.eql?("18")
+ return "WINCE" if sys_type.to_s.eql?("19")
+ return nil
+ end
+
+ collect_data(:default) do
+ kernel init_kernel
+ end
+
+ collect_data(:darwin) do
+ kernel init_kernel
+ kernel[:os] = kernel[:name]
+
+ so = shell_out("sysctl -n hw.optional.x86_64")
+ if so.stdout.split($/)[0].to_i == 1
+ kernel[:machine] = 'x86_64'
+ end
+
+ modules = Mash.new
+ so = shell_out("kextstat -k -l")
+ so.stdout.lines do |line|
+ if line =~ /(\d+)\s+(\d+)\s+0x[0-9a-f]+\s+0x([0-9a-f]+)\s+0x[0-9a-f]+\s+([a-zA-Z0-9\.]+) \(([0-9\.]+)\)/
+ kext[$4] = { :version => $5, :size => $3.hex, :index => $1, :refcount => $2 }
+ end
+ end
+
+ kernel[:modules] = modules
+ end
+
+ collect_data(:freebsd) do
+ kernel init_kernel
+ kernel[:os] = kernel[:name]
+
+ so = shell_out("uname -i")
+ kernel[:ident] = so.stdout.split($/)[0]
+ so = shell_out("sysctl kern.securelevel")
+ kernel[:securelevel] = so.stdout.split($/).select { |e| e =~ /kern.securelevel: (.+)$/ }
+
+ kernel[:modules] = bsd_modules("/sbin/kldstat")
+ end
+
+ collect_data(:linux) do
+ kernel init_kernel
+
+ so = shell_out("uname -o")
+ kernel[:os] = so.stdout.split($/)[0]
+
+ modules = Mash.new
+ so = shell_out("env lsmod")
+ so.stdout.lines do |line|
+ if line =~ /([a-zA-Z0-9\_]+)\s+(\d+)\s+(\d+)/
+ modules[$1] = { :size => $2, :refcount => $3 }
end
- kernel[:modules] = Mash.new
end
+
+ kernel[:modules] = modules
+ end
+
+ collect_data(:netbsd, :openbsd) do
+ kernel init_kernel
+ kernel[:os] = kernel[:name]
+
+ so = shell_out("sysctl kern.securelevel")
+ kernel[:securelevel] = so.stdout.split($/).select { |e| e =~ /kern.securelevel:\ (.+)$/ }
+
+ kernel[:modules] = bsd_modules("/usr/bin/modstat")
+ end
+
+ collect_data(:solaris2) do
+ kernel init_kernel
+
+ so = shell_out("uname -s")
+ kernel[:os] = so.stdout.split($/)[0]
+
+ modules = Mash.new
+
+ so = shell_out("modinfo")
+ # EXAMPLE:
+ # Id Loadaddr Size Info Rev Module Name
+ # 6 1180000 4623 1 1 specfs (filesystem for specfs)
+ module_description = /[\s]*([\d]+)[\s]+([a-f\d]+)[\s]+([a-f\d]+)[\s]+(?:[\-\d]+)[\s]+(?:[\d]+)[\s]+([\S]+)[\s]+\((.+)\)$/
+ so.stdout.lines do |line|
+ if mod = module_description.match(line)
+ modules[mod[4]] = { :id => mod[1].to_i, :loadaddr => mod[2], :size => mod[3].to_i(16), :description => mod[5]}
+ end
+ end
+
+ kernel[:modules] = modules
+ end
+
+ collect_data(:windows) do
+ require 'ruby-wmi'
+ WIN32OLE.codepage = WIN32OLE::CP_UTF8
+
+ kernel = Mash.new
+
+ host = WMI::Win32_OperatingSystem.find(:first)
+ kernel[:os_info] = Mash.new
+ host.properties_.each do |p|
+ kernel[:os_info][p.name.wmi_underscore.to_sym] = host.send(p.name)
+ end
+
+ kernel[:name] = "#{kernel[:os_info][:caption]}"
+ kernel[:release] = "#{kernel[:os_info][:version]}"
+ kernel[:version] = "#{kernel[:os_info][:version]}
+ ##{kernel[:os_info][:csd_version]} Build
+ ###{kernel[:os_info][:build_number]}"
+ kernel[:os] = os_lookup(kernel[:os_info][:os_type]) || languages[:ruby][:host_os]
+
+ host = WMI::Win32_ComputerSystem.find(:first)
+ kernel[:cs_info] = Mash.new
+ host.properties_.each do |p|
+ kernel[:cs_info][p.name.wmi_underscore.to_sym] = host.send(p.name)
+ end
+
+ kernel[:machine] = machine_lookup("#{kernel[:cs_info][:system_type]}")
+
+ kext = Mash.new
+ pnp_drivers = Mash.new
+
+ drivers = WMI::Win32_PnPSignedDriver.find(:all)
+ drivers.each do |driver|
+ pnp_drivers[driver.DeviceID] = Mash.new
+ driver.properties_.each do |p|
+ pnp_drivers[driver.DeviceID][p.name.wmi_underscore.to_sym] = driver.send(p.name)
+ end
+ if driver.DeviceName
+ kext[driver.DeviceName] = pnp_drivers[driver.DeviceID]
+ kext[driver.DeviceName][:version] = pnp_drivers[driver.DeviceID][:driver_version]
+ kext[driver.DeviceName][:date] = pnp_drivers[driver.DeviceID][:driver_date] ? pnp_drivers[driver.DeviceID][:driver_date].to_s[0..7] : nil
+ end
+ end
+
+ kernel[:pnp_drivers] = pnp_drivers
+ kernel[:modules] = kext
end
end
diff --git a/lib/ohai/plugins/keys.rb b/lib/ohai/plugins/keys.rb
index 6de9286d..d786f4fd 100644
--- a/lib/ohai/plugins/keys.rb
+++ b/lib/ohai/plugins/keys.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Keys) do
provides "keys"
collect_data do
diff --git a/lib/ohai/plugins/languages.rb b/lib/ohai/plugins/languages.rb
index e7e1eda2..678c8a24 100644
--- a/lib/ohai/plugins/languages.rb
+++ b/lib/ohai/plugins/languages.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Languages) do
provides "languages"
collect_data do
diff --git a/lib/ohai/plugins/linode.rb b/lib/ohai/plugins/linode.rb
index b21bf097..fb0fea19 100644
--- a/lib/ohai/plugins/linode.rb
+++ b/lib/ohai/plugins/linode.rb
@@ -14,11 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-Ohai.plugin do
+Ohai.plugin(:Linode) do
provides "linode"
depends "kernel"
- depends "network", "counters/network"
+ depends "network/interfaces"
# Checks for matching linode kernel name
#
diff --git a/lib/ohai/plugins/linux/block_device.rb b/lib/ohai/plugins/linux/block_device.rb
index ff8890aa..e8854e68 100644
--- a/lib/ohai/plugins/linux/block_device.rb
+++ b/lib/ohai/plugins/linux/block_device.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:BlockDevice) do
provides "block_device"
- collect_data do
+ collect_data(:linux) do
if File.exists?("/sys/block")
block = Mash.new
Dir["/sys/block/*"].each do |block_device_dir|
diff --git a/lib/ohai/plugins/linux/cpu.rb b/lib/ohai/plugins/linux/cpu.rb
index 5bc189bc..aeee390a 100644
--- a/lib/ohai/plugins/linux/cpu.rb
+++ b/lib/ohai/plugins/linux/cpu.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:CPU) do
provides "cpu"
- collect_data do
+ collect_data(:linux) do
cpuinfo = Mash.new
real_cpu = Mash.new
cpu_number = 0
diff --git a/lib/ohai/plugins/linux/filesystem.rb b/lib/ohai/plugins/linux/filesystem.rb
index 41939c06..6a10d75c 100644
--- a/lib/ohai/plugins/linux/filesystem.rb
+++ b/lib/ohai/plugins/linux/filesystem.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Filesystem) do
provides "filesystem"
- collect_data do
+ collect_data(:linux) do
fs = Mash.new
# Grab filesystem data from df
diff --git a/lib/ohai/plugins/linux/kernel.rb b/lib/ohai/plugins/linux/kernel.rb
deleted file mode 100644
index c2dd3e45..00000000
--- a/lib/ohai/plugins/linux/kernel.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "kernel"
-
- collect_data do
- so = shell_out("uname -o")
- kernel[:os] = so.stdout.split(/\r?\n/)[0]
-
- kext = Mash.new
- so = shell_out("env lsmod")
- so.stdout.lines do |line|
- if line =~ /([a-zA-Z0-9\_]+)\s+(\d+)\s+(\d+)/
- kext[$1] = { :size => $2, :refcount => $3 }
- end
- end
-
- kernel[:modules] = kext
- end
-end
diff --git a/lib/ohai/plugins/linux/lsb.rb b/lib/ohai/plugins/linux/lsb.rb
index a982fce4..7bd16b63 100644
--- a/lib/ohai/plugins/linux/lsb.rb
+++ b/lib/ohai/plugins/linux/lsb.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:LSB) do
provides "lsb"
- collect_data do
+ collect_data(:linux) do
lsb Mash.new
if File.exists?("/etc/lsb-release")
diff --git a/lib/ohai/plugins/linux/memory.rb b/lib/ohai/plugins/linux/memory.rb
index d41fc783..e5c76801 100644
--- a/lib/ohai/plugins/linux/memory.rb
+++ b/lib/ohai/plugins/linux/memory.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "memory"
+Ohai.plugin(:Memory) do
+ provides "memory", "memory/swap"
- collect_data do
+ collect_data(:linux) do
memory Mash.new
memory[:swap] = Mash.new
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb
index ad701b5d..c25e4986 100644
--- a/lib/ohai/plugins/linux/network.rb
+++ b/lib/ohai/plugins/linux/network.rb
@@ -16,10 +16,9 @@
# limitations under the License.
#
-require 'ipaddr'
-
-Ohai.plugin do
- provides "network", "counters/network"
+Ohai.plugin(:Network) do
+ provides "network", "network/interfaces"
+ provides "counters/network", "counters/network/interfaces"
provides "ipaddress", "ip6address", "macaddress"
def encaps_lookup(encap)
@@ -34,6 +33,8 @@ Ohai.plugin do
end
collect_data do
+ require 'ipaddr'
+
iface = Mash.new
net_counters = Mash.new
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb
index 85450560..8d77a491 100644
--- a/lib/ohai/plugins/linux/platform.rb
+++ b/lib/ohai/plugins/linux/platform.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Platform) do
provides "platform", "platform_version", "platform_family"
- depends 'linux::lsb'
+ depends "lsb"
def get_redhatish_platform(contents)
contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1].downcase
@@ -29,7 +29,7 @@ Ohai.plugin do
contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/release ([\d\.]+)/, 1]
end
- collect_data do
+ collect_data(:linux) do
# platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching
if File.exists?("/etc/oracle-release")
contents = File.read("/etc/oracle-release").chomp
@@ -99,7 +99,6 @@ Ohai.plugin do
platform_version lsb[:release]
end
-
case platform
when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /gcel/
platform_family "debian"
diff --git a/lib/ohai/plugins/linux/ps.rb b/lib/ohai/plugins/linux/ps.rb
deleted file mode 100644
index 013c1eb0..00000000
--- a/lib/ohai/plugins/linux/ps.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "command/ps"
-
- depends 'command'
-
- collect_data do
- command[:ps] = 'ps -ef'
- end
-end
diff --git a/lib/ohai/plugins/linux/uptime.rb b/lib/ohai/plugins/linux/uptime.rb
deleted file mode 100644
index d2ecdb1e..00000000
--- a/lib/ohai/plugins/linux/uptime.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "uptime", "idletime", "uptime_seconds", "idletime_seconds"
-
- collect_data do
- uptime, idletime = File.open("/proc/uptime").gets.split(" ")
- uptime_seconds uptime.to_i
- uptime seconds_to_human(uptime.to_i)
- idletime_seconds idletime.to_i
- idletime seconds_to_human(idletime.to_i)
- end
-end
diff --git a/lib/ohai/plugins/linux/virtualization.rb b/lib/ohai/plugins/linux/virtualization.rb
index 6a88aa5a..95b57ef4 100644
--- a/lib/ohai/plugins/linux/virtualization.rb
+++ b/lib/ohai/plugins/linux/virtualization.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Virtualization) do
provides "virtualization"
- collect_data do
+ collect_data(:linux) do
virtualization Mash.new
# if it is possible to detect paravirt vs hardware virt, it should be put in
diff --git a/lib/ohai/plugins/lua.rb b/lib/ohai/plugins/lua.rb
index fb7a4325..0b1a269d 100644
--- a/lib/ohai/plugins/lua.rb
+++ b/lib/ohai/plugins/lua.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Lua) do
provides "languages/lua"
depends "languages"
diff --git a/lib/ohai/plugins/mono.rb b/lib/ohai/plugins/mono.rb
index b51bd7e0..8a458bf1 100644
--- a/lib/ohai/plugins/mono.rb
+++ b/lib/ohai/plugins/mono.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Mono) do
provides "languages/mono"
depends "languages"
diff --git a/lib/ohai/plugins/netbsd/cpu.rb b/lib/ohai/plugins/netbsd/cpu.rb
index fbced143..1b0a2667 100644
--- a/lib/ohai/plugins/netbsd/cpu.rb
+++ b/lib/ohai/plugins/netbsd/cpu.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:CPU) do
provides 'cpu'
- collect_data do
+ collect_data(:netbsd) do
cpuinfo = Mash.new
# NetBSD provides some cpu information via sysctl, and a little via dmesg.boot
diff --git a/lib/ohai/plugins/netbsd/filesystem.rb b/lib/ohai/plugins/netbsd/filesystem.rb
index 225b8ef4..89a715b6 100644
--- a/lib/ohai/plugins/netbsd/filesystem.rb
+++ b/lib/ohai/plugins/netbsd/filesystem.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Filesystem) do
provides "filesystem"
- collect_data do
+ collect_data(:netbsd) do
fs = Mash.new
# Grab filesystem data from df
diff --git a/lib/ohai/plugins/netbsd/kernel.rb b/lib/ohai/plugins/netbsd/kernel.rb
deleted file mode 100644
index 4da3c229..00000000
--- a/lib/ohai/plugins/netbsd/kernel.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Author:: Bryan McLellan (btm@loftninjas.org)
-# Copyright:: Copyright (c) 2009 Bryan McLellan
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "kernel"
-
- collect_data do
- kernel[:os] = kernel[:name]
- so = shell_out("sysctl kern.securelevel")
-
- # regex modified based on sample data in the test
- kernel[:securelevel] = so.stdout.split($/).select { |e| e =~ /kern.securelevel:\ (.+)$/ }
- mod = Mash.new
- so = shell_out("#{ Ohai.abs_path( "/usr/bin/modstat" )}")
- so.stdout.lines 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\_]+)/
- mod[$5] = { :size => $4, :refcount => $2 }
- end
- end
-
- kernel[:modules] = mod unless mod.empty?
- end
-end
diff --git a/lib/ohai/plugins/netbsd/memory.rb b/lib/ohai/plugins/netbsd/memory.rb
index 1326b983..02ddcf5c 100644
--- a/lib/ohai/plugins/netbsd/memory.rb
+++ b/lib/ohai/plugins/netbsd/memory.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Memory) do
provides "memory"
- collect_data do
+ collect_data(:netbsd) do
memory Mash.new
memory[:swap] = Mash.new
diff --git a/lib/ohai/plugins/netbsd/network.rb b/lib/ohai/plugins/netbsd/network.rb
index e418995f..8f0cff56 100644
--- a/lib/ohai/plugins/netbsd/network.rb
+++ b/lib/ohai/plugins/netbsd/network.rb
@@ -16,10 +16,11 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "network", "counters/network"
+Ohai.plugin(:Network) do
+ provides "network", "network/interfaces"
+ provides "counters/network", "counters/network/interfaces"
- collect_data do
+ collect_data(:netbsd) do
network Mash.new unless network
network[:interfaces] = Mash.new unless network[:interfaces]
counters Mash.new unless counters
diff --git a/lib/ohai/plugins/netbsd/platform.rb b/lib/ohai/plugins/netbsd/platform.rb
index 0bfaee77..9293787b 100644
--- a/lib/ohai/plugins/netbsd/platform.rb
+++ b/lib/ohai/plugins/netbsd/platform.rb
@@ -16,13 +16,14 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "platform", "platform_version"
+Ohai.plugin(:Platform) do
+ provides "platform", "platform_version", "platform_family"
- collect_data do
+ collect_data(:netbsd) do
so = shell_out("uname -s")
platform so.stdout.split($/)[0].downcase
so = shell_out("uname -r")
platform_version so.stdout.split($/)[0]
+ platform_family "netbsd"
end
end
diff --git a/lib/ohai/plugins/netbsd/ps.rb b/lib/ohai/plugins/netbsd/ps.rb
deleted file mode 100644
index d0f0fe0b..00000000
--- a/lib/ohai/plugins/netbsd/ps.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Author:: Bryan McLellan (btm@loftninjas.org)
-# Copyright:: Copyright (c) 2009 Bryan McLellan
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "command/ps"
-
- depends 'command'
-
- collect_data do
- # ps -e requires procfs
- command[:ps] = 'ps -ax'
- end
-end
diff --git a/lib/ohai/plugins/netbsd/uptime.rb b/lib/ohai/plugins/netbsd/uptime.rb
deleted file mode 100644
index db05656f..00000000
--- a/lib/ohai/plugins/netbsd/uptime.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Bryan McLellan (btm@loftninjas.org)
-# Copyright:: Copyright (c) 2009 Bryan McLellan
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "uptime", "uptime_seconds"
-
- # kern.boottime: { sec = 1232765114, usec = 823118 } Fri Jan 23 18:45:14 2009
-
- collect_data do
- so = shell_out("#{ Ohai.abs_path( "/sbin/sysctl" )} kern.boottime")
- so.stdout.lines do |line|
- if line =~ /kern.boottime:\D+(\d+)/
- uptime_seconds Time.new.to_i - $1.to_i
- uptime seconds_to_human(uptime_seconds)
- end
- end
- end
-end
diff --git a/lib/ohai/plugins/netbsd/virtualization.rb b/lib/ohai/plugins/netbsd/virtualization.rb
index d9534e94..d2fabf25 100644
--- a/lib/ohai/plugins/netbsd/virtualization.rb
+++ b/lib/ohai/plugins/netbsd/virtualization.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Virtualization) do
provides "virtualization"
- collect_data do
+ collect_data(:netbsd) do
virtualization Mash.new
# KVM Host support for FreeBSD is in development
diff --git a/lib/ohai/plugins/network.rb b/lib/ohai/plugins/network.rb
index 3a679103..b32c6fa4 100644
--- a/lib/ohai/plugins/network.rb
+++ b/lib/ohai/plugins/network.rb
@@ -18,12 +18,10 @@
require 'ipaddress'
-Ohai.plugin do
- provides "network", "counters/network"
+Ohai.plugin(:NetworkAddresses) do
provides "ipaddress", "ip6address", "macaddress"
- depends "hostname"
- depends_os "network"
+ depends "network/interfaces"
FAMILIES = {
"inet" => "default",
diff --git a/lib/ohai/plugins/network_listeners.rb b/lib/ohai/plugins/network_listeners.rb
index 6f97399f..fcfcf0ba 100644
--- a/lib/ohai/plugins/network_listeners.rb
+++ b/lib/ohai/plugins/network_listeners.rb
@@ -16,16 +16,15 @@
# limitations under the License.
#
-require 'sigar'
-
-Ohai.plugin do
+Ohai.plugin(:NetworkListeners) do
provides "network/listeners"
depends "network", "counters/network"
- flags = Sigar::NETCONN_TCP|Sigar::NETCONN_SERVER
+ collect_data(:aix, :hpux, :sigar) do
+ require 'sigar'
+ flags = Sigar::NETCONN_TCP|Sigar::NETCONN_SERVER
- collect_data do
network Mash.new unless network
listeners = Mash.new
diff --git a/lib/ohai/plugins/nodejs.rb b/lib/ohai/plugins/nodejs.rb
index 42c8ae44..1ceef91e 100644
--- a/lib/ohai/plugins/nodejs.rb
+++ b/lib/ohai/plugins/nodejs.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Nodejs) do
provides "languages/nodejs"
depends "languages"
diff --git a/lib/ohai/plugins/ohai.rb b/lib/ohai/plugins/ohai.rb
index 97092ab5..ca01e21e 100644
--- a/lib/ohai/plugins/ohai.rb
+++ b/lib/ohai/plugins/ohai.rb
@@ -16,15 +16,15 @@
# limitations under the License.
#
-require "ohai"
-
-Ohai.plugin do
- provides "ohai"
+Ohai.plugin(:Ohai) do
+ provides "chef_packages/ohai"
collect_data do
- self[:chef_packages] = Mash.new unless self[:chef_packages]
- self[:chef_packages][:ohai] = Mash.new
- self[:chef_packages][:ohai][:version] = Ohai::VERSION
- self[:chef_packages][:ohai][:ohai_root] = Ohai::OHAI_ROOT
+ require 'ohai'
+
+ chef_packages Mash.new unless chef_packages
+ chef_packages[:ohai] = Mash.new
+ chef_packages[:ohai][:version] = Ohai::VERSION
+ chef_packages[:ohai][:ohai_root] = Ohai::OHAI_ROOT
end
end
diff --git a/lib/ohai/plugins/ohai_time.rb b/lib/ohai/plugins/ohai_time.rb
index 6afb6860..9867ec7f 100644
--- a/lib/ohai/plugins/ohai_time.rb
+++ b/lib/ohai/plugins/ohai_time.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:OhaiTime) do
provides "ohai_time"
collect_data do
diff --git a/lib/ohai/plugins/openbsd/cpu.rb b/lib/ohai/plugins/openbsd/cpu.rb
index ed69db61..91af3fe6 100644
--- a/lib/ohai/plugins/openbsd/cpu.rb
+++ b/lib/ohai/plugins/openbsd/cpu.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:CPU) do
provides 'cpu'
- collect_data do
+ collect_data(:openbsd) do
cpuinfo = Mash.new
# OpenBSD provides most cpu information via sysctl, the only thing we need to
diff --git a/lib/ohai/plugins/openbsd/filesystem.rb b/lib/ohai/plugins/openbsd/filesystem.rb
index 225b8ef4..aa33f9b2 100644
--- a/lib/ohai/plugins/openbsd/filesystem.rb
+++ b/lib/ohai/plugins/openbsd/filesystem.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Filesystem) do
provides "filesystem"
- collect_data do
+ collect_data(:openbsd) do
fs = Mash.new
# Grab filesystem data from df
diff --git a/lib/ohai/plugins/openbsd/kernel.rb b/lib/ohai/plugins/openbsd/kernel.rb
deleted file mode 100644
index bc41f620..00000000
--- a/lib/ohai/plugins/openbsd/kernel.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Author:: Bryan McLellan (btm@loftninjas.org)
-# Copyright:: Copyright (c) 2009 Bryan McLellan
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "kernel"
-
- collect_data do
- kernel[:os] = kernel[:name]
- so = shell_out("sysctl kern.securelevel")
-
- #modified regex to fit sample data
- kernel[:securelevel] = so.stdout.split($/).select { |e| e =~ /kern.securelevel:\ (.+)$/ }
-
- mod = Mash.new
- so = shell_out("#{ Ohai.abs_path( "/usr/bin/modstat" )}")
- so.stdout.lines 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\_]+)/
- mod[$5] = { :size => $4, :refcount => $2 }
- end
- end
-
- kernel[:modules] = mod unless mod.empty?
- end
-end
diff --git a/lib/ohai/plugins/openbsd/memory.rb b/lib/ohai/plugins/openbsd/memory.rb
index 8951da08..3ad60fbc 100644
--- a/lib/ohai/plugins/openbsd/memory.rb
+++ b/lib/ohai/plugins/openbsd/memory.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "memory"
+Ohai.plugin(:Memory) do
+ provides "memory", "memory/swap"
- collect_data do
+ collect_data(:openbsd) do
memory Mash.new
memory[:swap] = Mash.new
diff --git a/lib/ohai/plugins/openbsd/network.rb b/lib/ohai/plugins/openbsd/network.rb
index d802f338..a19c4f1e 100644
--- a/lib/ohai/plugins/openbsd/network.rb
+++ b/lib/ohai/plugins/openbsd/network.rb
@@ -16,10 +16,11 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "network", "counters/network"
+Ohai.plugin(:Network) do
+ provides "network", "network/interfaces"
+ provides "counters/network", "counters/network/interfaces"
- collect_data do
+ collect_data(:openbsd) do
network Mash.new unless network
network[:interfaces] = Mash.new unless network[:interfaces]
counters Mash.new unless counters
diff --git a/lib/ohai/plugins/openbsd/platform.rb b/lib/ohai/plugins/openbsd/platform.rb
index 0bfaee77..a99cf7a5 100644
--- a/lib/ohai/plugins/openbsd/platform.rb
+++ b/lib/ohai/plugins/openbsd/platform.rb
@@ -16,13 +16,14 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "platform", "platform_version"
+Ohai.plugin(:Platform) do
+ provides "platform", "platform_version", "platform_family"
- collect_data do
+ collect_data(:openbsd) do
so = shell_out("uname -s")
platform so.stdout.split($/)[0].downcase
so = shell_out("uname -r")
platform_version so.stdout.split($/)[0]
+ platform_family "openbsd"
end
end
diff --git a/lib/ohai/plugins/openbsd/ps.rb b/lib/ohai/plugins/openbsd/ps.rb
deleted file mode 100644
index 8bde6414..00000000
--- a/lib/ohai/plugins/openbsd/ps.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Author:: Bryan McLellan (btm@loftninjas.org)
-# Copyright:: Copyright (c) 2009 Bryan McLellan
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "command/ps"
-
- depends 'command'
-
- 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
deleted file mode 100644
index 48f71908..00000000
--- a/lib/ohai/plugins/openbsd/uptime.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Bryan McLellan (btm@loftninjas.org)
-# Copyright:: Copyright (c) 2009 Bryan McLellan
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "uptime", "uptime_seconds"
-
- # kern.boottime=Tue Nov 1 14:45:52 2011
-
- collect_data do
- so = shell_out("#{ Ohai.abs_path( "/sbin/sysctl" )} kern.boottime")
- so.stdout.lines 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
diff --git a/lib/ohai/plugins/openbsd/virtualization.rb b/lib/ohai/plugins/openbsd/virtualization.rb
index 142fa648..45715887 100644
--- a/lib/ohai/plugins/openbsd/virtualization.rb
+++ b/lib/ohai/plugins/openbsd/virtualization.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Virtualization) do
provides "virtualization"
- collect_data do
+ collect_data(:openbsd) do
virtualization Mash.new
# KVM Host support for FreeBSD is in development
diff --git a/lib/ohai/plugins/openstack.rb b/lib/ohai/plugins/openstack.rb
index 10c23433..afe14a1a 100644
--- a/lib/ohai/plugins/openstack.rb
+++ b/lib/ohai/plugins/openstack.rb
@@ -18,7 +18,7 @@
require 'ohai/mixin/ec2_metadata'
extend Ohai::Mixin::Ec2Metadata
-Ohai.plugin do
+Ohai.plugin(:Openstack) do
provides "openstack"
# does it matter that it's not hitting latest?
diff --git a/lib/ohai/plugins/os.rb b/lib/ohai/plugins/os.rb
index 860475ee..631ed237 100644
--- a/lib/ohai/plugins/os.rb
+++ b/lib/ohai/plugins/os.rb
@@ -18,7 +18,7 @@
require 'ohai/os'
-Ohai.plugin do
+Ohai.plugin(:OS) do
provides "os", "os_version"
depends 'kernel'
diff --git a/lib/ohai/plugins/passwd.rb b/lib/ohai/plugins/passwd.rb
index fd7d0500..397b15c6 100644
--- a/lib/ohai/plugins/passwd.rb
+++ b/lib/ohai/plugins/passwd.rb
@@ -1,7 +1,7 @@
require 'etc'
-Ohai.plugin do
+Ohai.plugin(:Passwd) do
provides 'etc', 'current_user'
def fix_encoding(str)
diff --git a/lib/ohai/plugins/perl.rb b/lib/ohai/plugins/perl.rb
index 3b4b3282..30bd6e1a 100644
--- a/lib/ohai/plugins/perl.rb
+++ b/lib/ohai/plugins/perl.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Perl) do
provides "languages/perl"
depends "languages"
diff --git a/lib/ohai/plugins/php.rb b/lib/ohai/plugins/php.rb
index 3cdb3543..7489b52f 100644
--- a/lib/ohai/plugins/php.rb
+++ b/lib/ohai/plugins/php.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:PHP) do
provides "languages/php"
depends "languages"
diff --git a/lib/ohai/plugins/platform.rb b/lib/ohai/plugins/platform.rb
index 5d5a935e..07d8246e 100644
--- a/lib/ohai/plugins/platform.rb
+++ b/lib/ohai/plugins/platform.rb
@@ -16,16 +16,13 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Platform) do
provides "platform", "platform_version", "platform_family"
+ depends "os", "os_version"
- depends_os "platform"
-
- collect_data do
+ collect_data(:default) do
platform os unless attribute?("platform")
-
platform_version os_version unless attribute?("platform_version")
-
platform_family platform unless attribute?("platform_family")
end
end
diff --git a/lib/ohai/plugins/aix/ps.rb b/lib/ohai/plugins/ps.rb
index 51e4e44f..ac0ee07d 100644
--- a/lib/ohai/plugins/aix/ps.rb
+++ b/lib/ohai/plugins/ps.rb
@@ -1,6 +1,8 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
+# Author:: Bryan McLellan (<btm@loftninjas.org>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Copyright:: Copyright (c) 2009 Bryan McLellan
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,17 +13,22 @@
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:PS) do
provides "command/ps"
+ depends "command"
- depends 'command'
-
- collect_data do
+ collect_data(:aix, :darwin, :hpux, :linux, :solaris2) do
command[:ps] = 'ps -ef'
end
+
+ collect_data(:freebsd, :netbsd, :openbsd) do
+ # ps -e requires procfs
+ command[:ps] = 'ps -ax'
+ end
end
diff --git a/lib/ohai/plugins/python.rb b/lib/ohai/plugins/python.rb
index b551a661..683042ba 100644
--- a/lib/ohai/plugins/python.rb
+++ b/lib/ohai/plugins/python.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Python) do
provides "languages/python"
depends "languages"
diff --git a/lib/ohai/plugins/rackspace.rb b/lib/ohai/plugins/rackspace.rb
index 8f113611..b96ebdf9 100644
--- a/lib/ohai/plugins/rackspace.rb
+++ b/lib/ohai/plugins/rackspace.rb
@@ -14,11 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-Ohai.plugin do
+Ohai.plugin(:Rackspace) do
provides "rackspace"
- depends "kernel"
- depends "network", "counters/network"
+ depends "kernel", "network/interfaces"
# Checks for matching rackspace kernel name
#
diff --git a/lib/ohai/plugins/root_group.rb b/lib/ohai/plugins/root_group.rb
index 212e4e05..1e5145e9 100644
--- a/lib/ohai/plugins/root_group.rb
+++ b/lib/ohai/plugins/root_group.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-Ohai.plugin do
+Ohai.plugin(:RootGroup) do
provides 'root_group'
collect_data do
diff --git a/lib/ohai/plugins/ruby.rb b/lib/ohai/plugins/ruby.rb
index 13c94bcb..bbb08397 100644
--- a/lib/ohai/plugins/ruby.rb
+++ b/lib/ohai/plugins/ruby.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Ruby) do
provides "languages/ruby"
depends "languages"
diff --git a/lib/ohai/plugins/sigar/cpu.rb b/lib/ohai/plugins/sigar/cpu.rb
index 66d09609..c61da5a0 100644
--- a/lib/ohai/plugins/sigar/cpu.rb
+++ b/lib/ohai/plugins/sigar/cpu.rb
@@ -16,12 +16,12 @@
# limitations under the License.
#
-require "sigar"
-
-Ohai.plugin do
+Ohai.plugin(:CPU) do
provides "cpu"
- collect_data do
+ collect_data(:aix, :hpux, :sigar) do
+ require 'sigar'
+
sigar = Sigar.new
cpuinfo = Mash.new
diff --git a/lib/ohai/plugins/sigar/filesystem.rb b/lib/ohai/plugins/sigar/filesystem.rb
index 603b4892..e243c4ce 100644
--- a/lib/ohai/plugins/sigar/filesystem.rb
+++ b/lib/ohai/plugins/sigar/filesystem.rb
@@ -16,16 +16,15 @@
# limitations under the License.
#
-require "sigar"
-
-Ohai.plugin do
+Ohai.plugin(:Filesystem) do
provides "filesystem"
- collect_data do
- fs = Mash.new
-
+ collect_data(:aix, :hpux, :sigar) do
+ require "sigar"
sigar = Sigar.new
+ fs = Mash.new
+
sigar.file_system_list.each do |fsys|
filesystem = fsys.dev_name
fs[filesystem] = Mash.new
diff --git a/lib/ohai/plugins/sigar/memory.rb b/lib/ohai/plugins/sigar/memory.rb
index 95daef24..7390cac5 100644
--- a/lib/ohai/plugins/sigar/memory.rb
+++ b/lib/ohai/plugins/sigar/memory.rb
@@ -16,12 +16,11 @@
# limitations under the License.
#
-require "sigar"
-
-Ohai.plugin do
+Ohai.plugin(:Memory) do
provides "memory"
- collect_data do
+ collect_data(:aix, :hpux, :sigar) do
+ require "sigar"
sigar = Sigar.new
memory Mash.new
diff --git a/lib/ohai/plugins/sigar/network.rb b/lib/ohai/plugins/sigar/network.rb
index b683986c..a6029ac3 100644
--- a/lib/ohai/plugins/sigar/network.rb
+++ b/lib/ohai/plugins/sigar/network.rb
@@ -18,10 +18,9 @@
#http://github.com/mdkent/ohai/commit/92f51aa18b6add9682510a87dcf94835ea72b04d
-require "sigar"
-
-Ohai.plugin do
- provides "network", "counters/network"
+Ohai.plugin(:Network) do
+ provides "network", "network/interfaces"
+ provides "counters/network", "counters/network/interfaces"
def encaps_lookup(encap)
return "Loopback" if encap.eql?("Local Loopback")
@@ -33,31 +32,21 @@ Ohai.plugin do
encap
end
- collect_data do
- sigar = Sigar.new
- network Mash.new unless network
- network[:interfaces] = Mash.new unless network[:interfaces]
- counters Mash.new unless counters
- counters[:network] = Mash.new unless counters[:network]
-
- ninfo = sigar.net_info
-
- network[:default_interface] = ninfo.default_gateway_interface
-
- network[:default_gateway] = ninfo.default_gateway
-
+ def fetch_interfaces(sigar)
iface = Mash.new
-
net_counters = Mash.new
sigar.net_interface_list.each do |cint|
iface[cint] = Mash.new
+
if cint =~ /^(\w+)(\d+.*)/
iface[cint][:type] = $1
iface[cint][:number] = $2
end
+
ifconfig = sigar.net_interface_config(cint)
iface[cint][:encapsulation] = encaps_lookup(ifconfig.type)
+
iface[cint][:addresses] = Mash.new
# Backwards compat: loopback has no hwaddr
if (ifconfig.flags & Sigar::IFF_LOOPBACK) == 0
@@ -72,14 +61,17 @@ Ohai.plugin do
end
iface[cint][:addresses][ifconfig.address]["netmask"] = ifconfig.netmask
end
- iface[cint][:flags] = Sigar.net_interface_flags_to_s(ifconfig.flags).split(' ')
- iface[cint][:mtu] = ifconfig.mtu.to_s
- iface[cint][:queuelen] = ifconfig.tx_queue_len.to_s
+
if ifconfig.prefix6_length != 0
iface[cint][:addresses][ifconfig.address6] = { "family" => "inet6" }
iface[cint][:addresses][ifconfig.address6]["prefixlen"] = ifconfig.prefix6_length.to_s
iface[cint][:addresses][ifconfig.address6]["scope"] = Sigar.net_scope_to_s(ifconfig.scope6)
end
+
+ iface[cint][:flags] = Sigar.net_interface_flags_to_s(ifconfig.flags).split(' ')
+ iface[cint][:mtu] = ifconfig.mtu.to_s
+ iface[cint][:queuelen] = ifconfig.tx_queue_len.to_s
+
net_counters[cint] = Mash.new unless net_counters[cint]
if (!cint.include?(":"))
ifstat = sigar.net_interface_stat(cint)
@@ -103,8 +95,75 @@ Ohai.plugin do
#64-bit AIX for example requires 64-bit caller
end
- counters[:network][:interfaces] = net_counters
+ [iface, net_counters]
+ end
+ # sigar-only, from network_route plugin
+ def flags(flags)
+ f = ""
+ if (flags & Sigar::RTF_UP) != 0
+ f += "U"
+ end
+ if (flags & Sigar::RTF_GATEWAY) != 0
+ f += "G"
+ end
+ if (flags & Sigar::RTF_HOST) != 0
+ f += "H"
+ end
+ f
+ end
+
+ # From sigar: include/sigar.h sigar_net_route_t
+ SIGAR_ROUTE_METHODS = [:destination, :gateway, :mask, :flags, :refcnt, :use, :metric, :mtu, :window, :irtt, :ifname]
+
+ collect_data(:aix, :hpux) do
+ require "sigar"
+ sigar = Sigar.new
+
+ network Mash.new unless network
+ network[:interfaces] = Mash.new unless network[:interfaces]
+ counters Mash.new unless counters
+ counters[:network] = Mash.new unless counters[:network]
+
+ ninfo = sigar.net_info
+ network[:default_interface] = ninfo.default_gateway_interface
+ network[:default_gateway] = ninfo.default_gateway
+
+ iface, net_counters = fetch_interfaces(sigar)
+ counters[:network][:interfaces] = net_counters
network["interfaces"] = iface
end
+
+ collect_data(:sigar) do
+ require "sigar"
+ sigar = Sigar.new
+
+ network Mash.new unless network
+ network[:interfaces] = Mash.new unless network[:interfaces]
+ counters Mash.new unless counters
+ counters[:network] = Mash.new unless counters[:network]
+
+ ninfo = sigar.net_info
+ network[:default_interface] = ninfo.default_gateway_interface
+ network[:default_gateway] = ninfo.default_gateway
+
+ iface, net_counters = fetch_interfaces(sigar)
+ counters[:network][:interfaces] = net_counters
+ network[:interfaces] = iface
+
+ sigar.net_route_list.each do |route|
+ next unless network[:interfaces][route.ifname] # this
+ # should never happen
+ network[:interfaces][route.ifname][:route] = Mash.new unless network[:interfaces][route.ifname][:route]
+ route_data={}
+ SIGAR_ROUTE_METHODS.each do |m|
+ if(m == :flags)
+ route_data[m]=flags(route.send(m))
+ else
+ route_data[m]=route.send(m)
+ end
+ end
+ network[:interfaces][route.ifname][:route][route.destination] = route_data
+ end
+ end
end
diff --git a/lib/ohai/plugins/sigar/network_route.rb b/lib/ohai/plugins/sigar/network_route.rb
index 022112db..d06352aa 100644
--- a/lib/ohai/plugins/sigar/network_route.rb
+++ b/lib/ohai/plugins/sigar/network_route.rb
@@ -19,8 +19,6 @@
require "sigar"
Ohai.plugin do
- depends "network"
-
provides "network"
def flags(flags)
@@ -40,12 +38,9 @@ Ohai.plugin do
# From sigar: include/sigar.h sigar_net_route_t
SIGAR_ROUTE_METHODS = [:destination, :gateway, :mask, :flags, :refcnt, :use, :metric, :mtu, :window, :irtt, :ifname]
- collect_data do
- sigar=Sigar.new
- network Mash.new unless network
- network[:interfaces] = Mash.new unless network[:interfaces]
- counters Mash.new unless counters
- counters[:network] = Mash.new unless counters[:network]
+ collect_data(:sigar) do
+ require "sigar"
+ sigar = Sigar.new
sigar.net_route_list.each do |route|
next unless network[:interfaces][route.ifname] # this should never happen
diff --git a/lib/ohai/plugins/sigar/platform.rb b/lib/ohai/plugins/sigar/platform.rb
index cbdf283e..c90a4115 100644
--- a/lib/ohai/plugins/sigar/platform.rb
+++ b/lib/ohai/plugins/sigar/platform.rb
@@ -16,15 +16,15 @@
# limitations under the License.
#
-require "sigar"
+Ohai.plugin(:Platform) do
+ provides "platform", "platform_version", "platform_family"
-Ohai.plugin do
- provides "platform", "platform_version"
-
- collect_data do
+ collect_data(:aix, :hpux, :sigar) do
+ require "sigar"
sys = Sigar.new.sys_info
platform sys.name.downcase
platform_version sys.version
+ platform_family platform
end
end
diff --git a/lib/ohai/plugins/sigar/uptime.rb b/lib/ohai/plugins/sigar/uptime.rb
deleted file mode 100644
index d1beca2c..00000000
--- a/lib/ohai/plugins/sigar/uptime.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Author:: Doug MacEachern <dougm@vmware.com>
-# Copyright:: Copyright (c) 2010 VMware, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require "sigar"
-
-Ohai.plugin do
- provides "uptime", "uptime_seconds"
-
- collect_data do
- sigar = Sigar.new
- uptime = sigar.uptime.uptime
- uptime_seconds uptime.to_i * 1000
- uptime seconds_to_human(uptime.to_i)
- end
-end
diff --git a/lib/ohai/plugins/solaris2/dmi.rb b/lib/ohai/plugins/solaris2/dmi.rb
index c3010771..8308bc78 100644
--- a/lib/ohai/plugins/solaris2/dmi.rb
+++ b/lib/ohai/plugins/solaris2/dmi.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:DMI) do
depends "dmi"
- collect_data do
+ collect_data(:solaris2) do
# if we already have a "dmi" with keys (presumably from dmidecode), don't try smbios
# note that a single key just means dmidecode exited with its version
if (dmi.class.to_s == 'Mash') and (dmi.keys.length > 1)
diff --git a/lib/ohai/plugins/solaris2/filesystem.rb b/lib/ohai/plugins/solaris2/filesystem.rb
index 0d73ff4b..2bf5e505 100644
--- a/lib/ohai/plugins/solaris2/filesystem.rb
+++ b/lib/ohai/plugins/solaris2/filesystem.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Filesystem) do
provides "filesystem"
- collect_data do
+ collect_data(:solaris2) do
fs = Mash.new
# Grab filesystem data from df
diff --git a/lib/ohai/plugins/solaris2/kernel.rb b/lib/ohai/plugins/solaris2/kernel.rb
deleted file mode 100644
index 9e14f458..00000000
--- a/lib/ohai/plugins/solaris2/kernel.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Author:: Benjamin Black (<nostromo@gmail.com>)
-# Copyright:: Copyright (c) 2009 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "kernel/os"
-
- collect_data do
- so = shell_out("uname -s")
- kernel[:os] = so.stdout.split($/)[0]
-
- modules = Mash.new
-
- so = shell_out("modinfo")
- # EXAMPLE:
- # Id Loadaddr Size Info Rev Module Name
- # 6 1180000 4623 1 1 specfs (filesystem for specfs)
- module_description = /[\s]*([\d]+)[\s]+([a-f\d]+)[\s]+([a-f\d]+)[\s]+(?:[\-\d]+)[\s]+(?:[\d]+)[\s]+([\S]+)[\s]+\((.+)\)$/
- so.stdout.lines do |line|
- if mod = module_description.match(line)
- modules[mod[4]] = { :id => mod[1].to_i, :loadaddr => mod[2], :size => mod[3].to_i(16), :description => mod[5]}
- end
- end
-
- kernel[:modules] = modules
- end
-end
diff --git a/lib/ohai/plugins/solaris2/network.rb b/lib/ohai/plugins/solaris2/network.rb
index 2cf3907d..6a69b4a6 100644
--- a/lib/ohai/plugins/solaris2/network.rb
+++ b/lib/ohai/plugins/solaris2/network.rb
@@ -53,10 +53,9 @@
# srcof qfe1
# inet6 fe80::203:baff:fe17:4444/128
-require 'scanf'
-
-Ohai.plugin do
- provides "network"
+Ohai.plugin(:Network) do
+ provides "network", "network/interfaces"
+ provides "counters/network", "counters/network/interfaces"
def encaps_lookup(ifname)
return "Ethernet" if ifname.eql?("e1000g")
@@ -74,7 +73,9 @@ Ohai.plugin do
nil
end
- collect_data do
+ collect_data(:solaris2) do
+ require 'scanf'
+
iface = Mash.new
network Mash.new unless network
network[:interfaces] = Mash.new unless network[:interfaces]
diff --git a/lib/ohai/plugins/solaris2/platform.rb b/lib/ohai/plugins/solaris2/platform.rb
index a9172fcd..ea10e7a8 100644
--- a/lib/ohai/plugins/solaris2/platform.rb
+++ b/lib/ohai/plugins/solaris2/platform.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "platform", "platform_version", "platform_build"
+Ohai.plugin(:Platform) do
+ provides "platform", "platform_version", "platform_build", "platform_family"
- collect_data do
+ collect_data(:solaris2) do
if File.exists?("/sbin/uname")
uname_exec = "/sbin/uname"
else
@@ -59,5 +59,7 @@ Ohai.plugin do
end
end
end
+
+ platform_family platform
end
end
diff --git a/lib/ohai/plugins/solaris2/ps.rb b/lib/ohai/plugins/solaris2/ps.rb
deleted file mode 100644
index 51e4e44f..00000000
--- a/lib/ohai/plugins/solaris2/ps.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Ohai.plugin do
- provides "command/ps"
-
- depends 'command'
-
- collect_data do
- command[:ps] = 'ps -ef'
- end
-end
diff --git a/lib/ohai/plugins/solaris2/uptime.rb b/lib/ohai/plugins/solaris2/uptime.rb
deleted file mode 100644
index e44632b9..00000000
--- a/lib/ohai/plugins/solaris2/uptime.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Author:: Kurt Yoder (<ktyopscode@yoderhome.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-require 'date'
-# It would be far better if we could include sys/uptime from sys-uptime RubyGem
-# It would also be good if we could pull idle time; how do we do this on Solaris?
-
-Ohai.plugin do
- provides "uptime", "uptime_seconds"
-
- collect_data do
- # Example output:
- # $ who -b
- # . system boot Jul 9 17:51
- so = shell_out("who -b")
- so.stdout.lines do |line|
- if line =~ /.* boot (.+)/
- uptime_seconds Time.now.to_i - DateTime.parse($1).strftime('%s').to_i
- uptime seconds_to_human(uptime_seconds)
- break
- end
- end
- end
-end
diff --git a/lib/ohai/plugins/solaris2/virtualization.rb b/lib/ohai/plugins/solaris2/virtualization.rb
index ec38fd64..af3ea7c1 100644
--- a/lib/ohai/plugins/solaris2/virtualization.rb
+++ b/lib/ohai/plugins/solaris2/virtualization.rb
@@ -18,10 +18,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Virtualization) do
provides "virtualization"
- collect_data do
+ collect_data(:solaris2) do
virtualization Mash.new
# Detect KVM/QEMU from cpuinfo, report as KVM
diff --git a/lib/ohai/plugins/solaris2/zpools.rb b/lib/ohai/plugins/solaris2/zpools.rb
index e6f6e469..f0867cd5 100644
--- a/lib/ohai/plugins/solaris2/zpools.rb
+++ b/lib/ohai/plugins/solaris2/zpools.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:Zpools) do
provides "zpools"
- collect_data do
+ collect_data(:solaris2) do
pools = Mash.new
# Grab ZFS zpools overall health and attributes
diff --git a/lib/ohai/plugins/ssh_host_key.rb b/lib/ohai/plugins/ssh_host_key.rb
index e23ab523..82d89308 100644
--- a/lib/ohai/plugins/ssh_host_key.rb
+++ b/lib/ohai/plugins/ssh_host_key.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-Ohai.plugin do
+Ohai.plugin(:SSHHostKey) do
provides "keys/ssh"
depends "keys"
diff --git a/lib/ohai/plugins/uptime.rb b/lib/ohai/plugins/uptime.rb
index c5f9c58f..a29a0680 100644
--- a/lib/ohai/plugins/uptime.rb
+++ b/lib/ohai/plugins/uptime.rb
@@ -1,19 +1,110 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Author:: Bryan McLellan (<btm@loftninjas.org>)
+# Author:: Claire McQuin (<claire@opscode.com>)
+# Author:: Doug MacEachern (<dougm@vmware.com>)
+# Author:: Kurt Yoder (<ktyopscode@yoderhome.com>)
+# Author:: Paul Mooring (<paul@opscode.com>)
+# Copyright:: Copyright (c) 2008, 2012, 2013 Opscode, Inc.
+# Copyright:: Copyright (c) 2009 Bryan McLellan
+# Copyright:: Copyright (c) 2010 VMware, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
+require 'ohai/mixin/seconds_to_human'
+
+Ohai.plugin(:Uptime) do
+ provides "uptime", "uptime_seconds"
+ provides "idletime", "idletime_seconds" # linux only
+
+ def collect_uptime(path)
+ # kern.boottime: { sec = 1232765114, usec = 823118 } Fri Jan 23 18:45:14 2009
+ so = shell_out("#{Ohai.abs_path(path)} kern.boottime")
+ so.stdout.lines do |line|
+ if line =~ /kern.boottime:\D+(\d+)/
+ usec = Time.new.to_i - $1.to_i
+ return [usec, seconds_to_human(usec)]
+ end
+ end
+ return [nil, nil]
+ end
+
+ collect_data(:aix, :hpux, :sigar) do
+ require 'sigar'
+
+ sigar = Sigar.new
+ uptime = sigar.uptime.uptime
+ uptime_seconds uptime.to_i * 1000
+ uptime seconds_to_human(uptime.to_i)
+ end
+
+ collect_data(:darwin) do
+ data = collect_uptime("/usr/sbin/sysctl")
+ uptime_seconds data.first
+ uptime data.last
+ end
+
+ collect_data(:freebsd, :netbsd) do
+ data = collect_uptime("/sbin/sysctl")
+ uptime_seconds data.first
+ uptime data.last
+ end
+
+ collect_data(:linux) do
+ uptime, idletime = File.open("/proc/uptime").gets.split(" ")
+ uptime_seconds uptime.to_i
+ uptime seconds_to_human(uptime.to_i)
+ idletime_seconds idletime.to_i
+ idletime seconds_to_human(idletime.to_i)
+ end
+
+ collect_data(:openbsd) do
+ # kern.boottime=Tue Nov 1 14:45:52 2011
+ so = shell_out("#{ Ohai.abs_path( "/sbin/sysctl" )}
+ #kern.boottime")
+ so.stdout.lines 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
+
+ collect_data(:solaris2) do
+ require 'date'
+
+ # Example output:
+ # $ who -b
+ # . system boot Jul 9 17:51
+ so = shell_out("who -b")
+ so.stdout.lines do |line|
+ if line =~ /.* boot (.+)/
+ uptime_seconds Time.now.to_i - DateTime.parse($1).strftime('%s').to_i
+ uptime seconds_to_human(uptime_seconds)
+ break
+ end
+ end
+ end
+
+ collect_data(:windows) do
+ require 'ruby-wmi'
+
+ uptime_seconds ::WMI::Win32_PerfFormattedData_PerfOS_System.find(:first).SystemUpTime.to_i
+ uptime seconds_to_human(uptime_seconds)
+ end
+
+end
diff --git a/lib/ohai/plugins/virtualization.rb b/lib/ohai/plugins/virtualization.rb
index 4c9a0d91..310bdeeb 100644
--- a/lib/ohai/plugins/virtualization.rb
+++ b/lib/ohai/plugins/virtualization.rb
@@ -16,10 +16,12 @@
# limitations under the License.
#
-Ohai.plugin do
- provides "virtualization"
+Ohai.plugin(:VirtualizationInfo) do
+ %w{ uri capabilities nodeinfo domains networks storage }.each do |info|
+ provides "virtualization/#{info}"
+ end
- depends_os "virtualization"
+ depends "virtualization"
collect_data do
unless virtualization.nil? || !(virtualization[:role].eql?("host"))
diff --git a/lib/ohai/plugins/windows/cpu.rb b/lib/ohai/plugins/windows/cpu.rb
index 4ffa9328..5c52a4d7 100644
--- a/lib/ohai/plugins/windows/cpu.rb
+++ b/lib/ohai/plugins/windows/cpu.rb
@@ -16,12 +16,12 @@
# limitations under the License.
#
-require 'ruby-wmi'
-
-Ohai.plugin do
+Ohai.plugin(:CPU) do
provides "cpu"
- collect_data do
+ collect_data(:windows) do
+ require 'ruby-wmi'
+
cpuinfo = Mash.new
cpu_number = 0
index = 0
diff --git a/lib/ohai/plugins/windows/filesystem.rb b/lib/ohai/plugins/windows/filesystem.rb
index 7aec0c1e..9a7e7dea 100644
--- a/lib/ohai/plugins/windows/filesystem.rb
+++ b/lib/ohai/plugins/windows/filesystem.rb
@@ -16,12 +16,12 @@
# limitations under the License.
#
-require 'ruby-wmi'
-
-Ohai.plugin do
+Ohai.plugin(:Filesystem) do
provides "filesystem"
- collect_data do
+ collect_data(:windows) do
+ require 'ruby-wmi'
+
fs = Mash.new
ld_info = Mash.new
diff --git a/lib/ohai/plugins/windows/kernel.rb b/lib/ohai/plugins/windows/kernel.rb
deleted file mode 100644
index a5c73167..00000000
--- a/lib/ohai/plugins/windows/kernel.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-#
-# Author:: James Gartrell (<jgartrel@gmail.com>)
-# Copyright:: Copyright (c) 2009 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'ruby-wmi'
-
-Ohai.plugin do
- provides "kernel"
-
- WIN32OLE.codepage = WIN32OLE::CP_UTF8
-
- def machine_lookup(sys_type)
- return "i386" if sys_type.eql?("X86-based PC")
- return "x86_64" if sys_type.eql?("x64-based PC")
- sys_type
- end
-
- def os_lookup(sys_type)
- return "Unknown" if sys_type.to_s.eql?("0")
- return "Other" if sys_type.to_s.eql?("1")
- return "MSDOS" if sys_type.to_s.eql?("14")
- return "WIN3x" if sys_type.to_s.eql?("15")
- return "WIN95" if sys_type.to_s.eql?("16")
- return "WIN98" if sys_type.to_s.eql?("17")
- return "WINNT" if sys_type.to_s.eql?("18")
- return "WINCE" if sys_type.to_s.eql?("19")
- return nil
- end
-
- collect_data do
- host = WMI::Win32_OperatingSystem.find(:first)
- kernel[:os_info] = Mash.new
- host.properties_.each do |p|
- kernel[:os_info][p.name.wmi_underscore.to_sym] = host.send(p.name)
- end
-
- kernel[:name] = "#{kernel[:os_info][:caption]}"
- kernel[:release] = "#{kernel[:os_info][:version]}"
- kernel[:version] = "#{kernel[:os_info][:version]} #{kernel[:os_info][:csd_version]} Build #{kernel[:os_info][:build_number]}"
- kernel[:os] = os_lookup(kernel[:os_info][:os_type]) || languages[:ruby][:host_os]
-
- host = WMI::Win32_ComputerSystem.find(:first)
- kernel[:cs_info] = Mash.new
- host.properties_.each do |p|
- kernel[:cs_info][p.name.wmi_underscore.to_sym] = host.send(p.name)
- end
-
- kernel[:machine] = machine_lookup("#{kernel[:cs_info][:system_type]}")
- end
-end
diff --git a/lib/ohai/plugins/windows/network.rb b/lib/ohai/plugins/windows/network.rb
index 0720672a..d1454805 100644
--- a/lib/ohai/plugins/windows/network.rb
+++ b/lib/ohai/plugins/windows/network.rb
@@ -16,17 +16,18 @@
# limitations under the License.
#
-require 'ruby-wmi'
-
-Ohai.plugin do
- provides "network"
+Ohai.plugin(:Network) do
+ provides "network", "network/interfaces"
+ provides "counters/network", "counters/network/interfaces"
def encaps_lookup(encap)
return "Ethernet" if encap.eql?("Ethernet 802.3")
encap
end
- collect_data do
+ collect_data(:windows) do
+ require 'ruby-wmi'
+
iface = Mash.new
iface_config = Mash.new
iface_instance = Mash.new
diff --git a/lib/ohai/plugins/windows/platform.rb b/lib/ohai/plugins/windows/platform.rb
index 690daa9b..2d2951c1 100644
--- a/lib/ohai/plugins/windows/platform.rb
+++ b/lib/ohai/plugins/windows/platform.rb
@@ -22,10 +22,10 @@
# platforms built upon the Windows_NT kernel and have access to win32 or win64
# subsystems.
-Ohai.plugin do
- provides "platform"
+Ohai.plugin(:Platform) do
+ provides "platform", "platform_version", "platform_family"
- collect_data do
+ collect_data (:windows)do
platform os
platform_version kernel['release']
platform_family "windows"
diff --git a/lib/ohai/plugins/windows/uptime.rb b/lib/ohai/plugins/windows/uptime.rb
deleted file mode 100644
index 59d79529..00000000
--- a/lib/ohai/plugins/windows/uptime.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Author:: Paul Mooring (paul@opscode.com)
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-require 'ruby-wmi'
-
-Ohai.plugin do
- provides "uptime", "uptime_seconds"
-
- collect_data do
- uptime_seconds ::WMI::Win32_PerfFormattedData_PerfOS_System.find(:first).SystemUpTime.to_i
- uptime seconds_to_human(uptime_seconds)
- end
-end