ohai 8.7.0 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/ohai/application.rb +3 -1
- data/lib/ohai/loader.rb +4 -3
- data/lib/ohai/mixin/dmi_decode.rb +47 -0
- data/lib/ohai/mixin/os.rb +2 -0
- data/lib/ohai/plugins/aix/kernel.rb +2 -1
- data/lib/ohai/plugins/{freebsd → bsd}/filesystem.rb +21 -3
- data/lib/ohai/plugins/bsd/virtualization.rb +80 -0
- data/lib/ohai/plugins/dragonflybsd/cpu.rb +58 -0
- data/lib/ohai/plugins/dragonflybsd/memory.rb +60 -0
- data/lib/ohai/plugins/dragonflybsd/network.rb +126 -0
- data/lib/ohai/plugins/dragonflybsd/os.rb +32 -0
- data/lib/ohai/plugins/dragonflybsd/platform.rb +29 -0
- data/lib/ohai/plugins/freebsd/cpu.rb +14 -8
- data/lib/ohai/plugins/freebsd/os.rb +1 -1
- data/lib/ohai/plugins/hostname.rb +1 -1
- data/lib/ohai/plugins/kernel.rb +12 -0
- data/lib/ohai/plugins/linux/virtualization.rb +8 -37
- data/lib/ohai/plugins/network_listeners.rb +5 -0
- data/lib/ohai/plugins/ps.rb +2 -2
- data/lib/ohai/plugins/solaris2/filesystem.rb +9 -1
- data/lib/ohai/plugins/uptime.rb +1 -1
- data/lib/ohai/plugins/virtualbox.rb +44 -0
- data/lib/ohai/plugins/windows/cpu.rb +26 -27
- data/lib/ohai/plugins/windows/virtualization.rb +29 -17
- data/lib/ohai/system.rb +1 -1
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +50 -0
- data/spec/functional/loader_spec.rb +53 -0
- data/spec/unit/loader_spec.rb +51 -53
- data/spec/unit/plugins/aix/kernel_spec.rb +5 -0
- data/spec/unit/plugins/bsd/filesystem_spec.rb +126 -0
- data/spec/unit/plugins/{freebsd → bsd}/virtualization_spec.rb +7 -4
- data/spec/unit/plugins/freebsd/cpu_spec.rb +60 -14
- data/spec/unit/plugins/linux/virtualization_spec.rb +58 -5
- data/spec/unit/plugins/solaris2/filesystem.rb +84 -0
- data/spec/unit/plugins/virtualbox_spec.rb +88 -0
- data/spec/unit/plugins/windows/cpu_spec.rb +3 -1
- data/spec/unit/plugins/windows/virtualization_spec.rb +182 -32
- metadata +21 -26
- data/lib/ohai/plugins/freebsd/virtualization.rb +0 -94
- data/lib/ohai/plugins/netbsd/filesystem.rb +0 -57
- data/lib/ohai/plugins/netbsd/virtualization.rb +0 -68
- data/lib/ohai/plugins/openbsd/filesystem.rb +0 -57
- data/lib/ohai/plugins/openbsd/virtualization.rb +0 -68
@@ -1,57 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
Ohai.plugin(:Filesystem) do
|
20
|
-
provides "filesystem"
|
21
|
-
|
22
|
-
collect_data(:netbsd) do
|
23
|
-
fs = Mash.new
|
24
|
-
|
25
|
-
# Grab filesystem data from df
|
26
|
-
so = shell_out("df")
|
27
|
-
so.stdout.lines do |line|
|
28
|
-
case line
|
29
|
-
when /^Filesystem/
|
30
|
-
next
|
31
|
-
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
|
32
|
-
filesystem = $1
|
33
|
-
fs[filesystem] = Mash.new
|
34
|
-
fs[filesystem]['kb_size'] = $2
|
35
|
-
fs[filesystem]['kb_used'] = $3
|
36
|
-
fs[filesystem]['kb_available'] = $4
|
37
|
-
fs[filesystem]['percent_used'] = $5
|
38
|
-
fs[filesystem]['mount'] = $6
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Grab mount information from mount
|
43
|
-
so = shell_out("mount -l")
|
44
|
-
so.stdout.lines do |line|
|
45
|
-
if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
|
46
|
-
filesystem = $1
|
47
|
-
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
|
48
|
-
fs[filesystem]['mount'] = $2
|
49
|
-
fs[filesystem]['fs_type'] = $3
|
50
|
-
fs[filesystem]['mount-options'] = $4.split(/,\s*/)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Set the filesystem data
|
55
|
-
filesystem fs
|
56
|
-
end
|
57
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
-
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
Ohai.plugin(:Virtualization) do
|
20
|
-
provides "virtualization"
|
21
|
-
|
22
|
-
collect_data(:netbsd) do
|
23
|
-
virtualization Mash.new
|
24
|
-
|
25
|
-
# KVM Host support for FreeBSD is in development
|
26
|
-
# http://feanor.sssup.it/~fabio/freebsd/lkvm/
|
27
|
-
|
28
|
-
# Detect KVM/QEMU from cpu, report as KVM
|
29
|
-
# hw.model: QEMU Virtual CPU version 0.9.1
|
30
|
-
so = shell_out("sysctl -n hw.model")
|
31
|
-
if so.stdout.split($/)[0] =~ /QEMU Virtual CPU/
|
32
|
-
virtualization[:system] = "kvm"
|
33
|
-
virtualization[:role] = "guest"
|
34
|
-
end
|
35
|
-
|
36
|
-
# http://www.dmo.ca/blog/detecting-virtualization-on-linux
|
37
|
-
if File.exists?("/usr/pkg/sbin/dmidecode")
|
38
|
-
so = shell_out("dmidecode")
|
39
|
-
found_virt_manufacturer = nil
|
40
|
-
found_virt_product = nil
|
41
|
-
so.stdout.lines do |line|
|
42
|
-
case line
|
43
|
-
when /Manufacturer: Microsoft/
|
44
|
-
found_virt_manufacturer = "microsoft"
|
45
|
-
when /Product Name: Virtual Machine/
|
46
|
-
found_virt_product = "microsoft"
|
47
|
-
when /Version: 5.0/
|
48
|
-
if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
|
49
|
-
virtualization[:system] = "virtualpc"
|
50
|
-
virtualization[:role] = "guest"
|
51
|
-
end
|
52
|
-
when /Version: VS2005R2/
|
53
|
-
if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
|
54
|
-
virtualization[:system] = "virtualserver"
|
55
|
-
virtualization[:role] = "guest"
|
56
|
-
end
|
57
|
-
when /Manufacturer: VMware/
|
58
|
-
found_virt_manufacturer = "vmware"
|
59
|
-
when /Product Name: VMware Virtual Platform/
|
60
|
-
if found_virt_manufacturer == "vmware"
|
61
|
-
virtualization[:system] = "vmware"
|
62
|
-
virtualization[:role] = "guest"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
Ohai.plugin(:Filesystem) do
|
20
|
-
provides "filesystem"
|
21
|
-
|
22
|
-
collect_data(:openbsd) do
|
23
|
-
fs = Mash.new
|
24
|
-
|
25
|
-
# Grab filesystem data from df
|
26
|
-
so = shell_out("df")
|
27
|
-
so.stdout.lines do |line|
|
28
|
-
case line
|
29
|
-
when /^Filesystem/
|
30
|
-
next
|
31
|
-
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
|
32
|
-
filesystem = $1
|
33
|
-
fs[filesystem] = Mash.new
|
34
|
-
fs[filesystem]['kb_size'] = $2
|
35
|
-
fs[filesystem]['kb_used'] = $3
|
36
|
-
fs[filesystem]['kb_available'] = $4
|
37
|
-
fs[filesystem]['percent_used'] = $5
|
38
|
-
fs[filesystem]['mount'] = $6
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Grab mount information from mount
|
43
|
-
so = shell_out("mount -l")
|
44
|
-
so.stdout.lines do |line|
|
45
|
-
if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
|
46
|
-
filesystem = $1
|
47
|
-
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
|
48
|
-
fs[filesystem]['mount'] = $2
|
49
|
-
fs[filesystem]['fs_type'] = $3
|
50
|
-
fs[filesystem]['mount-options'] = $4.split(/,\s*/)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Set the filesystem data
|
55
|
-
filesystem fs
|
56
|
-
end
|
57
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
-
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
Ohai.plugin(:Virtualization) do
|
20
|
-
provides "virtualization"
|
21
|
-
|
22
|
-
collect_data(:openbsd) do
|
23
|
-
virtualization Mash.new
|
24
|
-
|
25
|
-
# KVM Host support for FreeBSD is in development
|
26
|
-
# http://feanor.sssup.it/~fabio/freebsd/lkvm/
|
27
|
-
|
28
|
-
# Detect KVM/QEMU from cpu, report as KVM
|
29
|
-
# hw.model: QEMU Virtual CPU version 0.9.1
|
30
|
-
so = shell_out("sysctl -n hw.model")
|
31
|
-
if so.stdout.split($/)[0] =~ /QEMU Virtual CPU/
|
32
|
-
virtualization[:system] = "kvm"
|
33
|
-
virtualization[:role] = "guest"
|
34
|
-
end
|
35
|
-
|
36
|
-
# http://www.dmo.ca/blog/detecting-virtualization-on-linux
|
37
|
-
if File.exists?("/usr/local/sbin/dmidecode")
|
38
|
-
so = shell_out("dmidecode")
|
39
|
-
found_virt_manufacturer = nil
|
40
|
-
found_virt_product = nil
|
41
|
-
so.stdout.lines do |line|
|
42
|
-
case line
|
43
|
-
when /Manufacturer: Microsoft/
|
44
|
-
found_virt_manufacturer = "microsoft"
|
45
|
-
when /Product Name: Virtual Machine/
|
46
|
-
found_virt_product = "microsoft"
|
47
|
-
when /Version: 5.0/
|
48
|
-
if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
|
49
|
-
virtualization[:system] = "virtualpc"
|
50
|
-
virtualization[:role] = "guest"
|
51
|
-
end
|
52
|
-
when /Version: VS2005R2/
|
53
|
-
if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
|
54
|
-
virtualization[:system] = "virtualserver"
|
55
|
-
virtualization[:role] = "guest"
|
56
|
-
end
|
57
|
-
when /Manufacturer: VMware/
|
58
|
-
found_virt_manufacturer = "vmware"
|
59
|
-
when /Product Name: VMware Virtual Platform/
|
60
|
-
if found_virt_manufacturer == "vmware"
|
61
|
-
virtualization[:system] = "vmware"
|
62
|
-
virtualization[:role] = "guest"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|