ohai 6.24.2 → 7.0.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohai.rb +1 -1
- data/lib/ohai/application.rb +5 -12
- data/lib/ohai/common/dmi.rb +126 -0
- data/lib/ohai/config.rb +9 -9
- data/lib/ohai/{plugins/darwin/hostname.rb → dsl.rb} +7 -7
- data/lib/ohai/dsl/plugin.rb +186 -0
- data/lib/ohai/dsl/plugin/versionvi.rb +62 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +106 -0
- data/lib/ohai/exception.rb +11 -2
- data/lib/ohai/hints.rb +48 -0
- data/lib/ohai/loader.rb +205 -0
- data/lib/ohai/mixin/command.rb +14 -18
- data/lib/ohai/mixin/constant_helper.rb +53 -0
- data/lib/ohai/mixin/gce_metadata.rb +0 -2
- data/lib/ohai/{plugins/freebsd/uptime.rb → mixin/network_constants.rb} +15 -13
- data/lib/ohai/mixin/os.rb +59 -0
- data/lib/ohai/mixin/seconds_to_human.rb +48 -0
- data/lib/ohai/plugins/aix/cpu.rb +26 -22
- data/lib/ohai/plugins/aix/filesystem.rb +47 -48
- data/lib/ohai/plugins/aix/kernel.rb +11 -7
- data/lib/ohai/plugins/aix/memory.rb +8 -4
- data/lib/ohai/plugins/aix/network.rb +73 -82
- data/lib/ohai/plugins/aix/platform.rb +9 -6
- data/lib/ohai/plugins/aix/uptime.rb +14 -12
- data/lib/ohai/plugins/azure.rb +33 -11
- data/lib/ohai/plugins/c.rb +103 -78
- data/lib/ohai/plugins/chef.rb +20 -8
- data/lib/ohai/plugins/cloud.rb +234 -230
- data/lib/ohai/plugins/command.rb +6 -2
- data/lib/ohai/plugins/darwin/cpu.rb +10 -4
- data/lib/ohai/plugins/darwin/filesystem.rb +32 -32
- data/lib/ohai/plugins/darwin/network.rb +157 -154
- data/lib/ohai/plugins/darwin/platform.rb +18 -16
- data/lib/ohai/plugins/darwin/system_profiler.rb +49 -46
- data/lib/ohai/plugins/dmi.rb +102 -102
- data/lib/ohai/plugins/ec2.rb +30 -28
- data/lib/ohai/plugins/erlang.rb +19 -16
- data/lib/ohai/plugins/eucalyptus.rb +37 -36
- data/lib/ohai/plugins/freebsd/cpu.rb +34 -29
- data/lib/ohai/plugins/freebsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/freebsd/memory.rb +35 -25
- data/lib/ohai/plugins/freebsd/network.rb +94 -89
- data/lib/ohai/plugins/freebsd/platform.rb +10 -4
- data/lib/ohai/plugins/freebsd/virtualization.rb +62 -61
- data/lib/ohai/plugins/gce.rb +30 -36
- data/lib/ohai/plugins/groovy.rb +14 -11
- data/lib/ohai/plugins/hostname.rb +132 -10
- data/lib/ohai/plugins/ip_scopes.rb +31 -16
- data/lib/ohai/plugins/java.rb +45 -21
- data/lib/ohai/plugins/kernel.rb +186 -19
- data/lib/ohai/plugins/keys.rb +6 -2
- data/lib/ohai/plugins/languages.rb +6 -2
- data/lib/ohai/plugins/linode.rb +38 -30
- data/lib/ohai/plugins/linux/block_device.rb +19 -15
- data/lib/ohai/plugins/linux/cpu.rb +42 -38
- data/lib/ohai/plugins/linux/filesystem.rb +70 -130
- data/lib/ohai/plugins/linux/lsb.rb +35 -35
- data/lib/ohai/plugins/linux/memory.rb +65 -61
- data/lib/ohai/plugins/linux/network.rb +343 -362
- data/lib/ohai/plugins/linux/platform.rb +90 -88
- data/lib/ohai/plugins/linux/virtualization.rb +95 -90
- data/lib/ohai/plugins/lua.rb +14 -10
- data/lib/ohai/plugins/mono.rb +17 -13
- data/lib/ohai/plugins/netbsd/cpu.rb +25 -23
- data/lib/ohai/plugins/netbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/netbsd/memory.rb +59 -59
- data/lib/ohai/plugins/netbsd/network.rb +92 -88
- data/lib/ohai/plugins/netbsd/platform.rb +10 -3
- data/lib/ohai/plugins/netbsd/virtualization.rb +41 -38
- data/lib/ohai/plugins/network.rb +131 -130
- data/lib/ohai/plugins/network_listeners.rb +26 -22
- data/lib/ohai/plugins/nodejs.rb +14 -10
- data/lib/ohai/plugins/ohai.rb +11 -6
- data/lib/ohai/plugins/ohai_time.rb +6 -2
- data/lib/ohai/plugins/openbsd/cpu.rb +20 -15
- data/lib/ohai/plugins/openbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/openbsd/memory.rb +59 -59
- data/lib/ohai/plugins/openbsd/network.rb +92 -88
- data/lib/ohai/plugins/openbsd/platform.rb +10 -4
- data/lib/ohai/plugins/openbsd/virtualization.rb +41 -39
- data/lib/ohai/plugins/openstack.rb +23 -21
- data/lib/ohai/plugins/os.rb +8 -32
- data/lib/ohai/plugins/passwd.rb +27 -22
- data/lib/ohai/plugins/perl.rb +21 -16
- data/lib/ohai/plugins/php.rb +15 -12
- data/lib/ohai/plugins/platform.rb +9 -9
- data/lib/ohai/plugins/{linux/kernel.rb → ps.rb} +13 -12
- data/lib/ohai/plugins/python.rb +16 -12
- data/lib/ohai/plugins/rackspace.rb +82 -77
- data/lib/ohai/plugins/root_group.rb +13 -9
- data/lib/ohai/plugins/ruby.rb +50 -48
- data/lib/ohai/plugins/sigar/cpu.rb +21 -17
- data/lib/ohai/plugins/sigar/filesystem.rb +26 -23
- data/lib/ohai/plugins/sigar/memory.rb +17 -14
- data/lib/ohai/plugins/sigar/network.rb +133 -67
- data/lib/ohai/plugins/sigar/network_route.rb +33 -28
- data/lib/ohai/plugins/sigar/platform.rb +10 -6
- data/lib/ohai/plugins/solaris2/cpu.rb +41 -33
- data/lib/ohai/plugins/solaris2/dmi.rb +146 -146
- data/lib/ohai/plugins/solaris2/filesystem.rb +74 -77
- data/lib/ohai/plugins/{aix/hostname.rb → solaris2/memory.rb} +7 -4
- data/lib/ohai/plugins/solaris2/network.rb +91 -86
- data/lib/ohai/plugins/solaris2/platform.rb +40 -36
- data/lib/ohai/plugins/solaris2/virtualization.rb +54 -59
- data/lib/ohai/plugins/solaris2/zpools.rb +38 -38
- data/lib/ohai/plugins/ssh_host_key.rb +49 -45
- data/lib/ohai/plugins/uptime.rb +87 -25
- data/lib/ohai/plugins/virtualization.rb +59 -55
- data/lib/ohai/plugins/windows/cpu.rb +44 -40
- data/lib/ohai/plugins/windows/filesystem.rb +28 -22
- data/lib/ohai/plugins/windows/network.rb +88 -79
- data/lib/ohai/plugins/windows/platform.rb +10 -3
- data/lib/ohai/provides_map.rb +184 -0
- data/lib/ohai/runner.rb +109 -0
- data/lib/ohai/system.rb +103 -184
- data/lib/ohai/version.rb +4 -3
- data/spec/data/plugins/___lib64___libc.so.6.output +135 -0
- data/spec/data/plugins/___lib___libc.so.6.output +135 -0
- data/spec/data/plugins/cc.output +135 -0
- data/spec/data/plugins/cl.output +135 -0
- data/spec/data/plugins/devenv.com.output +135 -0
- data/spec/data/plugins/env.output +71 -0
- data/spec/data/plugins/erl.output +144 -0
- data/spec/data/plugins/gcc.output +135 -0
- data/spec/data/plugins/groovy.output +159 -0
- data/spec/data/plugins/java.output +143 -0
- data/spec/data/plugins/lua.output +143 -0
- data/spec/data/plugins/messages.rb +8 -0
- data/spec/data/plugins/node.output +143 -0
- data/spec/data/plugins/perl.output +143 -0
- data/spec/data/plugins/php.output +143 -0
- data/spec/data/plugins/python.output +143 -0
- data/spec/data/plugins/uname.output +71 -0
- data/spec/data/plugins/v6message.rb +2 -0
- data/spec/data/plugins/v7message.rb +7 -0
- data/spec/data/plugins/what.output +135 -0
- data/spec/data/plugins/xlc.output +135 -0
- data/spec/spec_helper.rb +52 -18
- data/spec/support/integration_helper.rb +44 -0
- data/spec/unit/dsl/plugin_spec.rb +298 -0
- data/spec/unit/hints_spec.rb +65 -0
- data/spec/unit/loader_spec.rb +226 -0
- data/spec/unit/mixin/ec2_metadata_spec.rb +9 -9
- data/spec/unit/plugins/aix/cpu_spec.rb +17 -18
- data/spec/unit/plugins/aix/filesystem_spec.rb +20 -18
- data/spec/unit/plugins/aix/hostname_spec.rb +8 -4
- data/spec/unit/plugins/aix/kernel_spec.rb +13 -12
- data/spec/unit/plugins/aix/network_spec.rb +66 -45
- data/spec/unit/plugins/aix/platform_spec.rb +11 -10
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -8
- data/spec/unit/plugins/azure_spec.rb +20 -21
- data/spec/unit/plugins/c_spec.rb +88 -87
- data/spec/unit/plugins/chef_spec.rb +5 -6
- data/spec/unit/plugins/cloud_spec.rb +81 -82
- data/spec/unit/plugins/darwin/cpu_spec.rb +8 -9
- data/spec/unit/plugins/darwin/hostname_spec.rb +23 -11
- data/spec/unit/plugins/darwin/kernel_spec.rb +39 -16
- data/spec/unit/plugins/darwin/network_spec.rb +375 -378
- data/spec/unit/plugins/darwin/platform_spec.rb +23 -50
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +7 -8
- data/spec/unit/plugins/dmi_spec.rb +7 -12
- data/spec/unit/plugins/ec2_spec.rb +70 -59
- data/spec/unit/plugins/erlang_spec.rb +18 -20
- data/spec/unit/plugins/eucalyptus_spec.rb +37 -33
- data/spec/unit/plugins/fail_spec.rb +276 -23
- data/spec/unit/plugins/freebsd/hostname_spec.rb +11 -9
- data/spec/unit/plugins/freebsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/platform_spec.rb +9 -10
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +32 -32
- data/spec/unit/plugins/gce_spec.rb +19 -25
- data/spec/unit/plugins/groovy_spec.rb +10 -16
- data/spec/unit/plugins/hostname_spec.rb +45 -20
- data/spec/unit/plugins/ip_scopes_spec.rb +97 -0
- data/spec/unit/plugins/java_spec.rb +145 -99
- data/spec/unit/plugins/kernel_spec.rb +51 -15
- data/spec/unit/plugins/linode_spec.rb +31 -29
- data/spec/unit/plugins/linux/cpu_spec.rb +42 -43
- data/spec/unit/plugins/linux/filesystem_spec.rb +143 -324
- data/spec/unit/plugins/linux/hostname_spec.rb +16 -23
- data/spec/unit/plugins/linux/kernel_spec.rb +22 -8
- data/spec/unit/plugins/linux/lsb_spec.rb +54 -56
- data/spec/unit/plugins/linux/network_spec.rb +196 -238
- data/spec/unit/plugins/linux/platform_spec.rb +186 -205
- data/spec/unit/plugins/linux/uptime_spec.rb +13 -25
- data/spec/unit/plugins/linux/virtualization_spec.rb +149 -129
- data/spec/unit/plugins/lua_spec.rb +12 -15
- data/spec/unit/plugins/mono_spec.rb +10 -15
- data/spec/unit/plugins/netbsd/hostname_spec.rb +17 -7
- data/spec/unit/plugins/netbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/netbsd/platform_spec.rb +8 -10
- data/spec/unit/plugins/network_spec.rb +358 -235
- data/spec/unit/plugins/nodejs_spec.rb +13 -15
- data/spec/unit/plugins/ohai_spec.rb +3 -4
- data/spec/unit/plugins/ohai_time_spec.rb +8 -9
- data/spec/unit/plugins/openbsd/hostname_spec.rb +21 -11
- data/spec/unit/plugins/openbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/openbsd/platform_spec.rb +6 -12
- data/spec/unit/plugins/openstack_spec.rb +214 -0
- data/spec/unit/plugins/os_spec.rb +13 -16
- data/spec/unit/plugins/passwd_spec.rb +12 -13
- data/spec/unit/plugins/perl_spec.rb +20 -44
- data/spec/unit/plugins/php_spec.rb +20 -15
- data/spec/unit/plugins/platform_spec.rb +24 -29
- data/spec/unit/plugins/python_spec.rb +13 -17
- data/spec/unit/plugins/rackspace_spec.rb +90 -57
- data/spec/unit/plugins/root_group_spec.rb +17 -19
- data/spec/unit/plugins/ruby_spec.rb +15 -16
- data/spec/unit/plugins/sigar/network_route_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/cpu_spec.rb +82 -0
- data/spec/unit/plugins/solaris2/hostname_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/kernel_spec.rb +11 -15
- data/{lib/ohai/plugins/openbsd/uptime.rb → spec/unit/plugins/solaris2/memory_spec.rb} +10 -12
- data/spec/unit/plugins/solaris2/network_spec.rb +44 -20
- data/spec/unit/plugins/solaris2/platform_spec.rb +13 -22
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +37 -45
- data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -15
- data/spec/unit/provides_map_spec.rb +208 -0
- data/spec/unit/runner_spec.rb +488 -0
- data/spec/unit/system_spec.rb +639 -104
- metadata +151 -87
- checksums.yaml +0 -7
- data/lib/ohai/mixin/from_file.rb +0 -36
- data/lib/ohai/plugins/aix/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/kernel.rb +0 -37
- data/lib/ohai/plugins/darwin/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/uptime.rb +0 -32
- data/lib/ohai/plugins/dmi_common.rb +0 -121
- data/lib/ohai/plugins/freebsd/hostname.rb +0 -22
- data/lib/ohai/plugins/freebsd/kernel.rb +0 -37
- data/lib/ohai/plugins/freebsd/ps.rb +0 -24
- data/lib/ohai/plugins/hpux/cpu.rb +0 -19
- data/lib/ohai/plugins/hpux/filesystem.rb +0 -19
- data/lib/ohai/plugins/hpux/hostname.rb +0 -19
- data/lib/ohai/plugins/hpux/memory.rb +0 -19
- data/lib/ohai/plugins/hpux/network.rb +0 -19
- data/lib/ohai/plugins/hpux/platform.rb +0 -19
- data/lib/ohai/plugins/hpux/ps.rb +0 -23
- data/lib/ohai/plugins/hpux/uptime.rb +0 -19
- data/lib/ohai/plugins/linux/hostname.rb +0 -40
- data/lib/ohai/plugins/linux/ps.rb +0 -23
- data/lib/ohai/plugins/linux/uptime.rb +0 -28
- data/lib/ohai/plugins/netbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/netbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/netbsd/ps.rb +0 -24
- data/lib/ohai/plugins/netbsd/uptime.rb +0 -31
- data/lib/ohai/plugins/openbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/openbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/openbsd/ps.rb +0 -24
- data/lib/ohai/plugins/sigar/hostname.rb +0 -28
- data/lib/ohai/plugins/sigar/uptime.rb +0 -27
- data/lib/ohai/plugins/solaris2/hostname.rb +0 -34
- data/lib/ohai/plugins/solaris2/kernel.rb +0 -40
- data/lib/ohai/plugins/solaris2/ps.rb +0 -23
- data/lib/ohai/plugins/solaris2/uptime.rb +0 -36
- data/lib/ohai/plugins/windows/hostname.rb +0 -33
- data/lib/ohai/plugins/windows/kernel.rb +0 -58
- data/lib/ohai/plugins/windows/kernel_devices.rb +0 -39
- data/lib/ohai/plugins/windows/uptime.rb +0 -23
- data/spec/unit/mixin/from_file_spec.rb +0 -53
@@ -16,71 +16,75 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:VirtualizationInfo) do
|
20
|
+
%w{ uri capabilities nodeinfo domains networks storage }.each do |info|
|
21
|
+
provides "virtualization/#{info}"
|
22
|
+
end
|
20
23
|
|
21
|
-
|
24
|
+
collect_data do
|
25
|
+
unless virtualization.nil? || !(virtualization[:role].eql?("host"))
|
26
|
+
begin
|
27
|
+
require 'libvirt'
|
28
|
+
require 'hpricot'
|
22
29
|
|
23
|
-
|
24
|
-
|
25
|
-
require 'libvirt'
|
26
|
-
require 'hpricot'
|
30
|
+
emu = (virtualization[:system].eql?('kvm') ? 'qemu' : virtualization[:system])
|
31
|
+
virtualization[:libvirt_version] = Libvirt::version(emu)[0].to_s
|
27
32
|
|
28
|
-
|
29
|
-
virtualization[:libvirt_version] = Libvirt::version(emu)[0].to_s
|
33
|
+
virtconn = Libvirt::open_read_only("#{emu}:///system")
|
30
34
|
|
31
|
-
|
35
|
+
virtualization[:uri] = virtconn.uri
|
36
|
+
virtualization[:capabilities] = Mash.new
|
37
|
+
virtualization[:capabilities][:xml_desc] = (virtconn.capabilities.split("\n").collect {|line| line.strip}).join
|
38
|
+
#xdoc = Hpricot virtualization[:capabilities][:xml_desc]
|
39
|
+
|
40
|
+
virtualization[:nodeinfo] = Mash.new
|
41
|
+
ni = virtconn.node_get_info
|
42
|
+
['cores','cpus','memory','mhz','model','nodes','sockets','threads'].each {|a| virtualization[:nodeinfo][a] = ni.send(a)}
|
32
43
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
44
|
+
virtualization[:domains] = Mash.new
|
45
|
+
virtconn.list_domains.each do |d|
|
46
|
+
dv = virtconn.lookup_domain_by_id d
|
47
|
+
virtualization[:domains][dv.name] = Mash.new
|
48
|
+
virtualization[:domains][dv.name][:id] = d
|
49
|
+
virtualization[:domains][dv.name][:xml_desc] = (dv.xml_desc.split("\n").collect {|line| line.strip}).join
|
50
|
+
['os_type','uuid'].each {|a| virtualization[:domains][dv.name][a] = dv.send(a)}
|
51
|
+
['cpu_time','max_mem','memory','nr_virt_cpu','state'].each {|a| virtualization[:domains][dv.name][a] = dv.info.send(a)}
|
52
|
+
#xdoc = Hpricot virtualization[:domains][dv.name][:xml_desc]
|
53
|
+
|
54
|
+
end
|
41
55
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
56
|
+
virtualization[:networks] = Mash.new
|
57
|
+
virtconn.list_networks.each do |n|
|
58
|
+
nv = virtconn.lookup_network_by_name n
|
59
|
+
virtualization[:networks][n] = Mash.new
|
60
|
+
virtualization[:networks][n][:xml_desc] = (nv.xml_desc.split("\n").collect {|line| line.strip}).join
|
61
|
+
['bridge_name','uuid'].each {|a| virtualization[:networks][n][a] = nv.send(a)}
|
62
|
+
#xdoc = Hpricot virtualization[:networks][n][:xml_desc]
|
63
|
+
|
64
|
+
end
|
53
65
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
66
|
+
virtualization[:storage] = Mash.new
|
67
|
+
virtconn.list_storage_pools.each do |pool|
|
68
|
+
sp = virtconn.lookup_storage_pool_by_name pool
|
69
|
+
virtualization[:storage][pool] = Mash.new
|
70
|
+
virtualization[:storage][pool][:xml_desc] = (sp.xml_desc.split("\n").collect {|line| line.strip}).join
|
71
|
+
['autostart','uuid'].each {|a| virtualization[:storage][pool][a] = sp.send(a)}
|
72
|
+
['allocation','available','capacity','state'].each {|a| virtualization[:storage][pool][a] = sp.info.send(a)}
|
73
|
+
#xdoc = Hpricot virtualization[:storage][pool][:xml_desc]
|
63
74
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
75
|
+
virtualization[:storage][pool][:volumes] = Mash.new
|
76
|
+
sp.list_volumes.each do |v|
|
77
|
+
virtualization[:storage][pool][:volumes][v] = Mash.new
|
78
|
+
sv = sp.lookup_volume_by_name v
|
79
|
+
['key','name','path'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.send(a)}
|
80
|
+
['allocation','capacity','type'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.info.send(a)}
|
81
|
+
end
|
82
|
+
end
|
72
83
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
sv = sp.lookup_volume_by_name v
|
77
|
-
['key','name','path'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.send(a)}
|
78
|
-
['allocation','capacity','type'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.info.send(a)}
|
84
|
+
virtconn.close
|
85
|
+
rescue LoadError => e
|
86
|
+
Ohai::Log.debug("Can't load gem: #{e}. virtualization plugin is disabled.")
|
79
87
|
end
|
80
88
|
end
|
81
|
-
|
82
|
-
virtconn.close
|
83
|
-
rescue LoadError => e
|
84
|
-
Ohai::Log.debug("Can't load gem: #{e}. virtualization plugin is disabled.")
|
85
89
|
end
|
86
90
|
end
|
@@ -16,49 +16,53 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:CPU) do
|
20
|
+
provides "cpu"
|
20
21
|
|
21
|
-
|
22
|
+
collect_data(:windows) do
|
23
|
+
require 'ruby-wmi'
|
22
24
|
|
23
|
-
cpuinfo = Mash.new
|
24
|
-
cpu_number = 0
|
25
|
-
index = 0
|
25
|
+
cpuinfo = Mash.new
|
26
|
+
cpu_number = 0
|
27
|
+
index = 0
|
26
28
|
|
27
|
-
WMI::Win32_Processor.find(:all).each do |processor|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
WMI::Win32_Processor.find(:all).each do |processor|
|
30
|
+
#
|
31
|
+
# On Windows Server 2003 R2 (i.e. 5.2.*), numberofcores property
|
32
|
+
# doesn't exist on the Win32_Processor class unless the user has
|
33
|
+
# patched their system with:
|
34
|
+
# http://support.microsoft.com/kb/932370
|
35
|
+
#
|
36
|
+
# We're returning nil for cpu["cores"] and cpu["count"]
|
37
|
+
# when we don't see numberofcores property
|
38
|
+
#
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
number_of_cores = nil
|
41
|
+
begin
|
42
|
+
number_of_cores = processor.numberofcores
|
43
|
+
cpu_number += number_of_cores
|
44
|
+
rescue NoMethodError => e
|
45
|
+
Ohai::Log.info("Can not find numberofcores property on Win32_Processor. Consider applying this patch: http://support.microsoft.com/kb/932370")
|
46
|
+
end
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
48
|
+
current_cpu = index.to_s
|
49
|
+
index += 1
|
50
|
+
cpuinfo[current_cpu] = Mash.new
|
51
|
+
cpuinfo[current_cpu]["vendor_id"] = processor.manufacturer
|
52
|
+
cpuinfo[current_cpu]["family"] = processor.family.to_s
|
53
|
+
cpuinfo[current_cpu]["model"] = processor.revision.to_s
|
54
|
+
cpuinfo[current_cpu]["stepping"] = processor.stepping
|
55
|
+
cpuinfo[current_cpu]["physical_id"] = processor.deviceid
|
56
|
+
#cpuinfo[current_cpu]["core_id"] = XXX
|
57
|
+
cpuinfo[current_cpu]["cores"] = number_of_cores
|
58
|
+
cpuinfo[current_cpu]["model_name"] = processor.description
|
59
|
+
cpuinfo[current_cpu]["mhz"] = processor.maxclockspeed.to_s
|
60
|
+
cpuinfo[current_cpu]["cache_size"] = "#{processor.l2cachesize} KB"
|
61
|
+
#cpuinfo[current_cpu]["flags"] = XXX
|
62
|
+
end
|
61
63
|
|
62
|
-
cpu cpuinfo
|
63
|
-
cpu[:total] = (cpu_number == 0) ? nil : cpu_number
|
64
|
-
cpu[:real] = index
|
64
|
+
cpu cpuinfo
|
65
|
+
cpu[:total] = (cpu_number == 0) ? nil : cpu_number
|
66
|
+
cpu[:real] = index
|
67
|
+
end
|
68
|
+
end
|
@@ -16,29 +16,35 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Filesystem) do
|
20
|
+
provides "filesystem"
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
collect_data(:windows) do
|
23
|
+
require 'ruby-wmi'
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
fs = Mash.new
|
26
|
+
ld_info = Mash.new
|
27
|
+
|
28
|
+
# Grab filesystem data from WMI
|
29
|
+
# Note: we should really be parsing Win32_Volume and Win32_Mapped drive
|
30
|
+
disks = WMI::Win32_LogicalDisk.find(:all)
|
31
|
+
disks.each do |disk|
|
32
|
+
filesystem = disk.DeviceID
|
33
|
+
fs[filesystem] = Mash.new
|
34
|
+
ld_info[filesystem] = Mash.new
|
35
|
+
disk.properties_.each do |p|
|
36
|
+
ld_info[filesystem][p.name.wmi_underscore.to_sym] = disk.send(p.name)
|
37
|
+
end
|
38
|
+
fs[filesystem][:kb_size] = ld_info[filesystem][:size].to_i / 1000
|
39
|
+
fs[filesystem][:kb_available] = ld_info[filesystem][:free_space].to_i / 1000
|
40
|
+
fs[filesystem][:kb_used] = fs[filesystem][:kb_size].to_i - fs[filesystem][:kb_available].to_i
|
41
|
+
fs[filesystem][:percent_used] = (fs[filesystem][:kb_size].to_i != 0 ? fs[filesystem][:kb_used].to_i * 100 / fs[filesystem][:kb_size].to_i : 0)
|
42
|
+
fs[filesystem][:mount] = ld_info[filesystem][:name]
|
43
|
+
fs[filesystem][:fs_type] = ld_info[filesystem][:file_system].downcase unless ld_info[filesystem][:file_system] == nil
|
44
|
+
fs[filesystem][:volume_name] = ld_info[filesystem][:volume_name]
|
33
45
|
end
|
34
|
-
fs[filesystem][:kb_size] = ld_info[filesystem][:size].to_i / 1000
|
35
|
-
fs[filesystem][:kb_available] = ld_info[filesystem][:free_space].to_i / 1000
|
36
|
-
fs[filesystem][:kb_used] = fs[filesystem][:kb_size].to_i - fs[filesystem][:kb_available].to_i
|
37
|
-
fs[filesystem][:percent_used] = (fs[filesystem][:kb_size].to_i != 0 ? fs[filesystem][:kb_used].to_i * 100 / fs[filesystem][:kb_size].to_i : 0)
|
38
|
-
fs[filesystem][:mount] = ld_info[filesystem][:name]
|
39
|
-
fs[filesystem][:fs_type] = ld_info[filesystem][:file_system].downcase unless ld_info[filesystem][:file_system] == nil
|
40
|
-
fs[filesystem][:volume_name] = ld_info[filesystem][:volume_name]
|
41
|
-
end
|
42
46
|
|
43
|
-
# Set the filesystem data
|
44
|
-
filesystem fs
|
47
|
+
# Set the filesystem data
|
48
|
+
filesystem fs
|
49
|
+
end
|
50
|
+
end
|
@@ -16,98 +16,107 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Network) do
|
20
|
+
provides "network", "network/interfaces"
|
21
|
+
provides "counters/network", "counters/network/interfaces"
|
20
22
|
|
21
|
-
|
23
|
+
def windows_encaps_lookup(encap)
|
24
|
+
return "Ethernet" if encap.eql?("Ethernet 802.3")
|
25
|
+
encap
|
26
|
+
end
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
encap
|
26
|
-
end
|
28
|
+
collect_data(:windows) do
|
29
|
+
require 'ruby-wmi'
|
27
30
|
|
28
|
-
iface = Mash.new
|
29
|
-
iface_config = Mash.new
|
30
|
-
iface_instance = Mash.new
|
31
|
+
iface = Mash.new
|
32
|
+
iface_config = Mash.new
|
33
|
+
iface_instance = Mash.new
|
34
|
+
network Mash.new unless network
|
35
|
+
network[:interfaces] = Mash.new unless network[:interfaces]
|
36
|
+
counters Mash.new unless counters
|
37
|
+
counters[:network] = Mash.new unless counters[:network]
|
31
38
|
|
32
|
-
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa394217%28v=vs.85%29.aspx
|
33
|
-
adapters = WMI::Win32_NetworkAdapterConfiguration.find(:all)
|
34
|
-
adapters.each do |adapter|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa394217%28v=vs.85%29.aspx
|
40
|
+
adapters = WMI::Win32_NetworkAdapterConfiguration.find(:all)
|
41
|
+
adapters.each do |adapter|
|
42
|
+
i = adapter.Index
|
43
|
+
iface_config[i] = Mash.new
|
44
|
+
adapter.properties_.each do |p|
|
45
|
+
iface_config[i][p.name.wmi_underscore.to_sym] = adapter.invoke(p.name)
|
46
|
+
end
|
39
47
|
end
|
40
|
-
end
|
41
48
|
|
42
|
-
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx
|
43
|
-
adapters = WMI::Win32_NetworkAdapter.find(:all)
|
44
|
-
adapters.each do |adapter|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx
|
50
|
+
adapters = WMI::Win32_NetworkAdapter.find(:all)
|
51
|
+
adapters.each do |adapter|
|
52
|
+
i = adapter.Index
|
53
|
+
iface_instance[i] = Mash.new
|
54
|
+
adapter.properties_.each do |p|
|
55
|
+
iface_instance[i][p.name.wmi_underscore.to_sym] = adapter.invoke(p.name)
|
56
|
+
end
|
49
57
|
end
|
50
|
-
end
|
51
58
|
|
52
|
-
iface_instance.keys.each do |i|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
59
|
+
iface_instance.keys.each do |i|
|
60
|
+
if iface_config[i][:ip_enabled] and iface_instance[i][:net_connection_id]
|
61
|
+
cint = sprintf("0x%x", iface_instance[i][:interface_index] ? iface_instance[i][:interface_index] : iface_instance[i][:index] ).downcase
|
62
|
+
iface[cint] = Mash.new
|
63
|
+
iface[cint][:configuration] = iface_config[i]
|
64
|
+
iface[cint][:instance] = iface_instance[i]
|
58
65
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
66
|
+
iface[cint][:counters] = Mash.new
|
67
|
+
iface[cint][:addresses] = Mash.new
|
68
|
+
iface[cint][:configuration][:ip_address].each_index do |i|
|
69
|
+
ip = iface[cint][:configuration][:ip_address][i]
|
70
|
+
_ip = IPAddress("#{ip}/#{iface[cint][:configuration][:ip_subnet][i]}")
|
71
|
+
iface[cint][:addresses][ip] = Mash.new(
|
72
|
+
:prefixlen => _ip.prefix
|
73
|
+
)
|
74
|
+
if _ip.ipv6?
|
75
|
+
# inet6 address
|
76
|
+
iface[cint][:addresses][ip][:family] = "inet6"
|
77
|
+
iface[cint][:addresses][ip][:scope] = "Link" if ip =~ /^fe80/i
|
78
|
+
else
|
79
|
+
# should be an inet4 address
|
80
|
+
iface[cint][:addresses][ip][:netmask] = _ip.netmask.to_s
|
81
|
+
if iface[cint][:configuration][:ip_use_zero_broadcast]
|
82
|
+
iface[cint][:addresses][ip][:broadcast] = _ip.network.to_s
|
83
|
+
else
|
84
|
+
iface[cint][:addresses][ip][:broadcast] = _ip.broadcast.to_s
|
85
|
+
end
|
86
|
+
iface[cint][:addresses][ip][:family] = "inet"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
# Apparently you can have more than one mac_address? Odd.
|
90
|
+
[iface[cint][:configuration][:mac_address]].flatten.each do |mac_addr|
|
91
|
+
iface[cint][:addresses][mac_addr] = {
|
92
|
+
"family" => "lladdr"
|
93
|
+
}
|
94
|
+
end
|
95
|
+
iface[cint][:mtu] = iface[cint][:configuration][:mtu]
|
96
|
+
iface[cint][:type] = iface[cint][:instance][:adapter_type]
|
97
|
+
iface[cint][:arp] = {}
|
98
|
+
iface[cint][:encapsulation] = windows_encaps_lookup(iface[cint][:instance][:adapter_type])
|
99
|
+
if iface[cint][:configuration][:default_ip_gateway] != nil and iface[cint][:configuration][:default_ip_gateway].size > 0
|
100
|
+
network[:default_gateway] = iface[cint][:configuration][:default_ip_gateway].first
|
101
|
+
network[:default_interface] = cint
|
78
102
|
end
|
79
|
-
iface[cint][:addresses][ip][:family] = "inet"
|
80
103
|
end
|
81
104
|
end
|
82
|
-
# Apparently you can have more than one mac_address? Odd.
|
83
|
-
[iface[cint][:configuration][:mac_address]].flatten.each do |mac_addr|
|
84
|
-
iface[cint][:addresses][mac_addr] = {
|
85
|
-
"family" => "lladdr"
|
86
|
-
}
|
87
|
-
end
|
88
|
-
iface[cint][:mtu] = iface[cint][:configuration][:mtu]
|
89
|
-
iface[cint][:type] = iface[cint][:instance][:adapter_type]
|
90
|
-
iface[cint][:arp] = {}
|
91
|
-
iface[cint][:encapsulation] = encaps_lookup(iface[cint][:instance][:adapter_type])
|
92
|
-
if iface[cint][:configuration][:default_ip_gateway] != nil and iface[cint][:configuration][:default_ip_gateway].size > 0
|
93
|
-
network[:default_gateway] = iface[cint][:configuration][:default_ip_gateway].first
|
94
|
-
network[:default_interface] = cint
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
105
|
|
99
|
-
cint=nil
|
100
|
-
|
101
|
-
if
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
106
|
+
cint=nil
|
107
|
+
so = shell_out("arp -a")
|
108
|
+
if so.exitstatus == 0
|
109
|
+
so.stdout.lines do |line|
|
110
|
+
if line =~ /^Interface:\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+[-]+\s+(0x\S+)/
|
111
|
+
cint = $2.downcase
|
112
|
+
end
|
113
|
+
next unless iface[cint]
|
114
|
+
if line =~ /^\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+([a-fA-F0-9\:-]+)/
|
115
|
+
iface[cint][:arp][$1] = $2.gsub("-",":").downcase
|
116
|
+
end
|
117
|
+
end
|
109
118
|
end
|
119
|
+
|
120
|
+
network["interfaces"] = iface
|
110
121
|
end
|
111
122
|
end
|
112
|
-
|
113
|
-
network["interfaces"] = iface
|