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,87 +16,153 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
require 'ohai/mixin/network_constants'
|
20
20
|
|
21
|
-
|
21
|
+
Ohai.plugin(:Network) do
|
22
|
+
include Ohai::Mixin::NetworkConstants
|
22
23
|
|
23
|
-
|
24
|
+
provides "network", "network/interfaces"
|
25
|
+
provides "counters/network", "counters/network/interfaces"
|
24
26
|
|
25
|
-
|
27
|
+
def sigar_encaps_lookup(encap)
|
28
|
+
return "Loopback" if encap.eql?("Local Loopback")
|
29
|
+
return "PPP" if encap.eql?("Point-to-Point Protocol")
|
30
|
+
return "SLIP" if encap.eql?("Serial Line IP")
|
31
|
+
return "VJSLIP" if encap.eql?("VJ Serial Line IP")
|
32
|
+
return "IPIP" if encap.eql?("IPIP Tunnel")
|
33
|
+
return "6to4" if encap.eql?("IPv6-in-IPv4")
|
34
|
+
encap
|
35
|
+
end
|
26
36
|
|
27
|
-
|
37
|
+
def fetch_interfaces(sigar)
|
38
|
+
iface = Mash.new
|
39
|
+
net_counters = Mash.new
|
28
40
|
|
29
|
-
|
41
|
+
sigar.net_interface_list.each do |cint|
|
42
|
+
iface[cint] = Mash.new
|
30
43
|
|
31
|
-
|
44
|
+
if cint =~ /^(\w+)(\d+.*)/
|
45
|
+
iface[cint][:type] = $1
|
46
|
+
iface[cint][:number] = $2
|
47
|
+
end
|
32
48
|
|
33
|
-
|
34
|
-
|
35
|
-
return "PPP" if encap.eql?("Point-to-Point Protocol")
|
36
|
-
return "SLIP" if encap.eql?("Serial Line IP")
|
37
|
-
return "VJSLIP" if encap.eql?("VJ Serial Line IP")
|
38
|
-
return "IPIP" if encap.eql?("IPIP Tunnel")
|
39
|
-
return "6to4" if encap.eql?("IPv6-in-IPv4")
|
40
|
-
encap
|
41
|
-
end
|
49
|
+
ifconfig = sigar.net_interface_config(cint)
|
50
|
+
iface[cint][:encapsulation] = sigar_encaps_lookup(ifconfig.type)
|
42
51
|
|
43
|
-
iface = Mash.new
|
52
|
+
iface[cint][:addresses] = Mash.new
|
53
|
+
# Backwards compat: loopback has no hwaddr
|
54
|
+
if (ifconfig.flags & Sigar::IFF_LOOPBACK) == 0
|
55
|
+
iface[cint][:addresses][ifconfig.hwaddr] = { "family" => "lladdr" }
|
56
|
+
end
|
57
|
+
if ifconfig.address != "0.0.0.0"
|
58
|
+
iface[cint][:addresses][ifconfig.address] = { "family" => "inet" }
|
59
|
+
# Backwards compat: no broadcast on tunnel or loopback dev
|
60
|
+
if (((ifconfig.flags & Sigar::IFF_POINTOPOINT) == 0) &&
|
61
|
+
((ifconfig.flags & Sigar::IFF_LOOPBACK) == 0))
|
62
|
+
iface[cint][:addresses][ifconfig.address]["broadcast"] = ifconfig.broadcast
|
63
|
+
end
|
64
|
+
iface[cint][:addresses][ifconfig.address]["netmask"] = ifconfig.netmask
|
65
|
+
end
|
44
66
|
|
45
|
-
|
67
|
+
if ifconfig.prefix6_length != 0
|
68
|
+
iface[cint][:addresses][ifconfig.address6] = { "family" => "inet6" }
|
69
|
+
iface[cint][:addresses][ifconfig.address6]["prefixlen"] = ifconfig.prefix6_length.to_s
|
70
|
+
iface[cint][:addresses][ifconfig.address6]["scope"] = Sigar.net_scope_to_s(ifconfig.scope6)
|
71
|
+
end
|
46
72
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
# Backwards compat: no broadcast on tunnel or loopback dev
|
63
|
-
if (((ifconfig.flags & Sigar::IFF_POINTOPOINT) == 0) &&
|
64
|
-
((ifconfig.flags & Sigar::IFF_LOOPBACK) == 0))
|
65
|
-
iface[cint][:addresses][ifconfig.address]["broadcast"] = ifconfig.broadcast
|
73
|
+
iface[cint][:flags] = Sigar.net_interface_flags_to_s(ifconfig.flags).split(' ')
|
74
|
+
iface[cint][:mtu] = ifconfig.mtu.to_s
|
75
|
+
iface[cint][:queuelen] = ifconfig.tx_queue_len.to_s
|
76
|
+
|
77
|
+
net_counters[cint] = Mash.new unless net_counters[cint]
|
78
|
+
if (!cint.include?(":"))
|
79
|
+
ifstat = sigar.net_interface_stat(cint)
|
80
|
+
net_counters[cint][:rx] = { "packets" => ifstat.rx_packets.to_s, "errors" => ifstat.rx_errors.to_s,
|
81
|
+
"drop" => ifstat.rx_dropped.to_s, "overrun" => ifstat.rx_overruns.to_s,
|
82
|
+
"frame" => ifstat.rx_frame.to_s, "bytes" => ifstat.rx_bytes.to_s }
|
83
|
+
net_counters[cint][:tx] = { "packets" => ifstat.tx_packets.to_s, "errors" => ifstat.tx_errors.to_s,
|
84
|
+
"drop" => ifstat.tx_dropped.to_s, "overrun" => ifstat.tx_overruns.to_s,
|
85
|
+
"carrier" => ifstat.tx_carrier.to_s, "collisions" => ifstat.tx_collisions.to_s,
|
86
|
+
"bytes" => ifstat.tx_bytes.to_s }
|
87
|
+
end
|
66
88
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
89
|
+
|
90
|
+
begin
|
91
|
+
sigar.arp_list.each do |arp|
|
92
|
+
next unless iface[arp.ifname] # this should never happen
|
93
|
+
iface[arp.ifname][:arp] = Mash.new unless iface[arp.ifname][:arp]
|
94
|
+
iface[arp.ifname][:arp][arp.address] = arp.hwaddr
|
95
|
+
end
|
96
|
+
rescue
|
97
|
+
#64-bit AIX for example requires 64-bit caller
|
98
|
+
end
|
99
|
+
|
100
|
+
[iface, net_counters]
|
76
101
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
102
|
+
|
103
|
+
# sigar-only, from network_route plugin
|
104
|
+
def flags(flags)
|
105
|
+
f = ""
|
106
|
+
if (flags & Sigar::RTF_UP) != 0
|
107
|
+
f += "U"
|
108
|
+
end
|
109
|
+
if (flags & Sigar::RTF_GATEWAY) != 0
|
110
|
+
f += "G"
|
111
|
+
end
|
112
|
+
if (flags & Sigar::RTF_HOST) != 0
|
113
|
+
f += "H"
|
114
|
+
end
|
115
|
+
f
|
87
116
|
end
|
88
|
-
end
|
89
117
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
118
|
+
collect_data(:hpux) do
|
119
|
+
require "sigar"
|
120
|
+
sigar = Sigar.new
|
121
|
+
|
122
|
+
network Mash.new unless network
|
123
|
+
network[:interfaces] = Mash.new unless network[:interfaces]
|
124
|
+
counters Mash.new unless counters
|
125
|
+
counters[:network] = Mash.new unless counters[:network]
|
126
|
+
|
127
|
+
ninfo = sigar.net_info
|
128
|
+
network[:default_interface] = ninfo.default_gateway_interface
|
129
|
+
network[:default_gateway] = ninfo.default_gateway
|
130
|
+
|
131
|
+
iface, net_counters = fetch_interfaces(sigar)
|
132
|
+
counters[:network][:interfaces] = net_counters
|
133
|
+
network["interfaces"] = iface
|
95
134
|
end
|
96
|
-
rescue
|
97
|
-
#64-bit AIX for example requires 64-bit caller
|
98
|
-
end
|
99
135
|
|
100
|
-
|
136
|
+
collect_data(:default) do
|
137
|
+
require "sigar"
|
138
|
+
sigar = Sigar.new
|
101
139
|
|
102
|
-
network
|
140
|
+
network Mash.new unless network
|
141
|
+
network[:interfaces] = Mash.new unless network[:interfaces]
|
142
|
+
counters Mash.new unless counters
|
143
|
+
counters[:network] = Mash.new unless counters[:network]
|
144
|
+
|
145
|
+
ninfo = sigar.net_info
|
146
|
+
network[:default_interface] = ninfo.default_gateway_interface
|
147
|
+
network[:default_gateway] = ninfo.default_gateway
|
148
|
+
|
149
|
+
iface, net_counters = fetch_interfaces(sigar)
|
150
|
+
counters[:network][:interfaces] = net_counters
|
151
|
+
network[:interfaces] = iface
|
152
|
+
|
153
|
+
sigar.net_route_list.each do |route|
|
154
|
+
next unless network[:interfaces][route.ifname] # this
|
155
|
+
# should never happen
|
156
|
+
network[:interfaces][route.ifname][:route] = Mash.new unless network[:interfaces][route.ifname][:route]
|
157
|
+
route_data={}
|
158
|
+
Ohai::Mixin::NetworkConstants::SIGAR_ROUTE_METHODS.each do |m|
|
159
|
+
if(m == :flags)
|
160
|
+
route_data[m]=flags(route.send(m))
|
161
|
+
else
|
162
|
+
route_data[m]=route.send(m)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
network[:interfaces][route.ifname][:route][route.destination] = route_data
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -16,39 +16,44 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require
|
20
|
-
require_plugin "network"
|
19
|
+
require 'ohai/mixin/network_constants'
|
21
20
|
|
22
|
-
|
21
|
+
Ohai.plugin(:NetworkRoutes) do
|
22
|
+
include Ohai::Mixin::NetworkConstants
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
provides "network/interfaces/adapters/route"
|
25
|
+
depends "network/interfaces"
|
26
|
+
|
27
|
+
def flags(flags)
|
28
|
+
f = ""
|
29
|
+
if (flags & Sigar::RTF_UP) != 0
|
30
|
+
f += "U"
|
31
|
+
end
|
32
|
+
if (flags & Sigar::RTF_GATEWAY) != 0
|
33
|
+
f += "G"
|
34
|
+
end
|
35
|
+
if (flags & Sigar::RTF_HOST) != 0
|
36
|
+
f += "H"
|
37
|
+
end
|
38
|
+
f
|
34
39
|
end
|
35
|
-
f
|
36
|
-
end
|
37
40
|
|
38
|
-
|
39
|
-
|
41
|
+
collect_data(:default) do
|
42
|
+
require "sigar"
|
43
|
+
sigar = Sigar.new
|
40
44
|
|
41
|
-
sigar
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
sigar.net_route_list.each do |route|
|
46
|
+
next unless network[:interfaces][route.ifname] # this should never happen
|
47
|
+
network[:interfaces][route.ifname][:route] = Mash.new unless network[:interfaces][route.ifname][:route]
|
48
|
+
route_data={}
|
49
|
+
Ohai::Mixin::NetworkConstants::SIGAR_ROUTE_METHODS.each do |m|
|
50
|
+
if(m == :flags)
|
51
|
+
route_data[m]=flags(route.send(m))
|
52
|
+
else
|
53
|
+
route_data[m]=route.send(m)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
network[:interfaces][route.ifname][:route][route.destination] = route_data
|
51
57
|
end
|
52
58
|
end
|
53
|
-
network[:interfaces][route.ifname][:route][route.destination] = route_data
|
54
59
|
end
|
@@ -16,11 +16,15 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Platform) do
|
20
|
+
provides "platform", "platform_version", "platform_family"
|
20
21
|
|
21
|
-
|
22
|
+
collect_data(:hpux) do
|
23
|
+
require "sigar"
|
24
|
+
sys = Sigar.new.sys_info
|
22
25
|
|
23
|
-
sys
|
24
|
-
|
25
|
-
platform
|
26
|
-
|
26
|
+
platform sys.name.downcase
|
27
|
+
platform_version sys.version
|
28
|
+
platform_family platform
|
29
|
+
end
|
30
|
+
end
|
@@ -1,33 +1,41 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
1
|
+
#
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
Ohai.plugin(:CPU) do
|
18
|
+
provides "cpu"
|
19
|
+
|
20
|
+
collect_data(:solaris2) do
|
21
|
+
cpu Mash.new
|
22
|
+
cpu[:total] = shell_out("psrinfo | wc -l").stdout.to_i
|
23
|
+
cpu[:real] = shell_out("psrinfo -p").stdout.to_i
|
24
|
+
|
25
|
+
processor_info = shell_out("psrinfo -v -p | grep Hz").stdout
|
26
|
+
processors = processor_info.split(/^ [^\s]/)
|
27
|
+
processors.each_with_index do |processor, i|
|
28
|
+
cpu_info, model_name = processor.split("\n ")
|
29
|
+
cpu_info = cpu_info.tr("()","").split
|
30
|
+
|
31
|
+
index = i.to_s
|
32
|
+
cpu[index] = Mash.new
|
33
|
+
cpu[index]['vendor_id'] = cpu_info[1]
|
34
|
+
cpu[index]['family'] = cpu_info[4]
|
35
|
+
cpu[index]['model'] = cpu_info[6]
|
36
|
+
cpu[index]['stepping'] = cpu_info[8]
|
37
|
+
cpu[index]['model_name'] = model_name.strip
|
38
|
+
cpu[index]['mhz'] = cpu_info[10]
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -16,161 +16,161 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:DMI) do
|
20
20
|
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
dmi Mash.new
|
29
|
-
|
30
|
-
# bad Solaris shows strings defined by system instead of SMB IDs
|
31
|
-
# this is what the *real* IDs are:
|
32
|
-
# pulled from http://src.opensolaris.org/source/xref/nwam/nwam1/usr/src/uts/common/sys/smbios.h
|
33
|
-
smb_to_id = {
|
34
|
-
'SMB_TYPE_BIOS' => 0, # BIOS information (R)
|
35
|
-
'SMB_TYPE_SYSTEM' => 1, # system information (R)
|
36
|
-
'SMB_TYPE_BASEBOARD' => 2, # base board
|
37
|
-
'SMB_TYPE_CHASSIS' => 3, # system enclosure or chassis (R)
|
38
|
-
'SMB_TYPE_PROCESSOR' => 4, # processor (R)
|
39
|
-
'SMB_TYPE_MEMCTL' => 5, # memory controller (O)
|
40
|
-
'SMB_TYPE_MEMMOD' => 6, # memory module (O)
|
41
|
-
'SMB_TYPE_CACHE' => 7, # processor cache (R)
|
42
|
-
'SMB_TYPE_PORT' => 8, # port connector
|
43
|
-
'SMB_TYPE_SLOT' => 9, # upgradeable system slot (R)
|
44
|
-
'SMB_TYPE_OBDEVS' => 10, # on-board devices
|
45
|
-
'SMB_TYPE_OEMSTR' => 11, # OEM string table
|
46
|
-
'SMB_TYPE_SYSCONFSTR' => 12, # system configuration string table
|
47
|
-
'SMB_TYPE_LANG' => 13, # BIOS language information
|
48
|
-
'SMB_TYPE_GROUP' => 14, # group associations
|
49
|
-
'SMB_TYPE_EVENTLOG' => 15, # system event log
|
50
|
-
'SMB_TYPE_MEMARRAY' => 16, # physical memory array (R)
|
51
|
-
'SMB_TYPE_MEMDEVICE' => 17, # memory device (R)
|
52
|
-
'SMB_TYPE_MEMERR32' => 18, # 32-bit memory error information
|
53
|
-
'SMB_TYPE_MEMARRAYMAP' => 19, # memory array mapped address (R)
|
54
|
-
'SMB_TYPE_MEMDEVICEMAP' => 20, # memory device mapped address (R)
|
55
|
-
'SMB_TYPE_POINTDEV' => 21, # built-in pointing device
|
56
|
-
'SMB_TYPE_BATTERY' => 22, # portable battery
|
57
|
-
'SMB_TYPE_RESET' => 23, # system reset settings
|
58
|
-
'SMB_TYPE_SECURITY' => 24, # hardware security settings
|
59
|
-
'SMB_TYPE_POWERCTL' => 25, # system power controls
|
60
|
-
'SMB_TYPE_VPROBE' => 26, # voltage probe
|
61
|
-
'SMB_TYPE_COOLDEV' => 27, # cooling device
|
62
|
-
'SMB_TYPE_TPROBE' => 28, # temperature probe
|
63
|
-
'SMB_TYPE_IPROBE' => 29, # current probe
|
64
|
-
'SMB_TYPE_OOBRA' => 30, # out-of-band remote access facility
|
65
|
-
'SMB_TYPE_BIS' => 31, # boot integrity services
|
66
|
-
'SMB_TYPE_BOOT' => 32, # system boot status (R)
|
67
|
-
'SMB_TYPE_MEMERR64' => 33, # 64-bit memory error information
|
68
|
-
'SMB_TYPE_MGMTDEV' => 34, # management device
|
69
|
-
'SMB_TYPE_MGMTDEVCP' => 35, # management device component
|
70
|
-
'SMB_TYPE_MGMTDEVDATA' => 36, # management device threshold data
|
71
|
-
'SMB_TYPE_MEMCHAN' => 37, # memory channel
|
72
|
-
'SMB_TYPE_IPMIDEV' => 38, # IPMI device information
|
73
|
-
'SMB_TYPE_POWERSUP' => 39, # system power supply
|
74
|
-
'SMB_TYPE_INACTIVE' => 126, # inactive table entry
|
75
|
-
'SMB_TYPE_EOT' => 127, # end of table
|
76
|
-
'SMB_TYPE_OEM_LO' => 128, # start of OEM-specific type range
|
77
|
-
'SUN_OEM_EXT_PROCESSOR' => 132, # processor extended info
|
78
|
-
'SUN_OEM_PCIEXRC' => 138, # PCIE RootComplex/RootPort info
|
79
|
-
'SUN_OEM_EXT_MEMARRAY' => 144, # phys memory array extended info
|
80
|
-
'SUN_OEM_EXT_MEMDEVICE' => 145, # memory device extended info
|
81
|
-
'SMB_TYPE_OEM_HI' => 256, # end of OEM-specific type range
|
82
|
-
}
|
83
|
-
|
84
|
-
# all output lines should fall within one of these patterns
|
85
|
-
header_type_line = /^ID\s+SIZE\s+TYPE/
|
86
|
-
header_information_line = /^(\d+)\s+(\d+)\s+(\S+)\s+\(([^\)]+)\)/
|
87
|
-
blank_line = /^\s*$/
|
88
|
-
data_key_value_line = /^ ([^:]+): (.*)/
|
89
|
-
data_key_only_line = /^ (\S.*)(:\s*)?$/
|
90
|
-
extended_data_line = /^\t(\S+) \((.+)\)/
|
91
|
-
|
92
|
-
dmi_record = nil
|
93
|
-
field = nil
|
94
|
-
|
95
|
-
popen4("smbios") do |pid, stdin, stdout, stderr|
|
96
|
-
stdin.close
|
97
|
-
|
98
|
-
# ==== EXAMPLE: ====
|
99
|
-
# ID SIZE TYPE
|
100
|
-
# 0 40 SMB_TYPE_BIOS (BIOS information)
|
101
|
-
#
|
102
|
-
# Vendor: HP
|
103
|
-
# Version String: 2.16
|
104
|
-
# ... similar lines trimmed
|
105
|
-
# Characteristics: 0x7fc9da80
|
106
|
-
# SMB_BIOSFL_PCI (PCI is supported)
|
107
|
-
# ... similar lines trimmed
|
108
|
-
# note the second level of indentation is via a *tab*
|
109
|
-
stdout.each do |raw_line|
|
110
|
-
next if header_type_line.match(raw_line)
|
111
|
-
next if blank_line.match(raw_line)
|
112
|
-
|
113
|
-
# remove/replace any characters that don't fall inside permissible ASCII range, or whitespace
|
114
|
-
line = raw_line.gsub(/[^\x20-\x7E\n\t\r]/, '.')
|
115
|
-
if (line != raw_line)
|
116
|
-
Ohai::Log.debug("converted characters from line:\n#{raw_line}")
|
21
|
+
collect_data(:solaris2) do
|
22
|
+
# if we already have a "dmi" with keys (presumably from dmidecode), don't try smbios
|
23
|
+
# note that a single key just means dmidecode exited with its version
|
24
|
+
if (dmi.class.to_s == 'Mash') and (dmi.keys.length > 1)
|
25
|
+
Ohai::Log.debug('skipping smbios output, since DMI information has already been provided')
|
26
|
+
return
|
117
27
|
end
|
118
28
|
|
119
|
-
|
120
|
-
dmi_record = {}
|
29
|
+
dmi Mash.new
|
121
30
|
|
122
|
-
|
123
|
-
|
124
|
-
|
31
|
+
# bad Solaris shows strings defined by system instead of SMB IDs
|
32
|
+
# this is what the *real* IDs are:
|
33
|
+
# pulled from http://src.opensolaris.org/source/xref/nwam/nwam1/usr/src/uts/common/sys/smbios.h
|
34
|
+
smb_to_id = {
|
35
|
+
'SMB_TYPE_BIOS' => 0, # BIOS information (R)
|
36
|
+
'SMB_TYPE_SYSTEM' => 1, # system information (R)
|
37
|
+
'SMB_TYPE_BASEBOARD' => 2, # base board
|
38
|
+
'SMB_TYPE_CHASSIS' => 3, # system enclosure or chassis (R)
|
39
|
+
'SMB_TYPE_PROCESSOR' => 4, # processor (R)
|
40
|
+
'SMB_TYPE_MEMCTL' => 5, # memory controller (O)
|
41
|
+
'SMB_TYPE_MEMMOD' => 6, # memory module (O)
|
42
|
+
'SMB_TYPE_CACHE' => 7, # processor cache (R)
|
43
|
+
'SMB_TYPE_PORT' => 8, # port connector
|
44
|
+
'SMB_TYPE_SLOT' => 9, # upgradeable system slot (R)
|
45
|
+
'SMB_TYPE_OBDEVS' => 10, # on-board devices
|
46
|
+
'SMB_TYPE_OEMSTR' => 11, # OEM string table
|
47
|
+
'SMB_TYPE_SYSCONFSTR' => 12, # system configuration string table
|
48
|
+
'SMB_TYPE_LANG' => 13, # BIOS language information
|
49
|
+
'SMB_TYPE_GROUP' => 14, # group associations
|
50
|
+
'SMB_TYPE_EVENTLOG' => 15, # system event log
|
51
|
+
'SMB_TYPE_MEMARRAY' => 16, # physical memory array (R)
|
52
|
+
'SMB_TYPE_MEMDEVICE' => 17, # memory device (R)
|
53
|
+
'SMB_TYPE_MEMERR32' => 18, # 32-bit memory error information
|
54
|
+
'SMB_TYPE_MEMARRAYMAP' => 19, # memory array mapped address (R)
|
55
|
+
'SMB_TYPE_MEMDEVICEMAP' => 20, # memory device mapped address (R)
|
56
|
+
'SMB_TYPE_POINTDEV' => 21, # built-in pointing device
|
57
|
+
'SMB_TYPE_BATTERY' => 22, # portable battery
|
58
|
+
'SMB_TYPE_RESET' => 23, # system reset settings
|
59
|
+
'SMB_TYPE_SECURITY' => 24, # hardware security settings
|
60
|
+
'SMB_TYPE_POWERCTL' => 25, # system power controls
|
61
|
+
'SMB_TYPE_VPROBE' => 26, # voltage probe
|
62
|
+
'SMB_TYPE_COOLDEV' => 27, # cooling device
|
63
|
+
'SMB_TYPE_TPROBE' => 28, # temperature probe
|
64
|
+
'SMB_TYPE_IPROBE' => 29, # current probe
|
65
|
+
'SMB_TYPE_OOBRA' => 30, # out-of-band remote access facility
|
66
|
+
'SMB_TYPE_BIS' => 31, # boot integrity services
|
67
|
+
'SMB_TYPE_BOOT' => 32, # system boot status (R)
|
68
|
+
'SMB_TYPE_MEMERR64' => 33, # 64-bit memory error information
|
69
|
+
'SMB_TYPE_MGMTDEV' => 34, # management device
|
70
|
+
'SMB_TYPE_MGMTDEVCP' => 35, # management device component
|
71
|
+
'SMB_TYPE_MGMTDEVDATA' => 36, # management device threshold data
|
72
|
+
'SMB_TYPE_MEMCHAN' => 37, # memory channel
|
73
|
+
'SMB_TYPE_IPMIDEV' => 38, # IPMI device information
|
74
|
+
'SMB_TYPE_POWERSUP' => 39, # system power supply
|
75
|
+
'SMB_TYPE_INACTIVE' => 126, # inactive table entry
|
76
|
+
'SMB_TYPE_EOT' => 127, # end of table
|
77
|
+
'SMB_TYPE_OEM_LO' => 128, # start of OEM-specific type range
|
78
|
+
'SUN_OEM_EXT_PROCESSOR' => 132, # processor extended info
|
79
|
+
'SUN_OEM_PCIEXRC' => 138, # PCIE RootComplex/RootPort info
|
80
|
+
'SUN_OEM_EXT_MEMARRAY' => 144, # phys memory array extended info
|
81
|
+
'SUN_OEM_EXT_MEMDEVICE' => 145, # memory device extended info
|
82
|
+
'SMB_TYPE_OEM_HI' => 256, # end of OEM-specific type range
|
83
|
+
}
|
125
84
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
85
|
+
# all output lines should fall within one of these patterns
|
86
|
+
header_type_line = /^ID\s+SIZE\s+TYPE/
|
87
|
+
header_information_line = /^(\d+)\s+(\d+)\s+(\S+)\s+\(([^\)]+)\)/
|
88
|
+
blank_line = /^\s*$/
|
89
|
+
data_key_value_line = /^ ([^:]+): (.*)/
|
90
|
+
data_key_only_line = /^ (\S.*)(:\s*)?$/
|
91
|
+
extended_data_line = /^\t(\S+) \((.+)\)/
|
130
92
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
field = data[1]
|
155
|
-
|
156
|
-
elsif extended_data = extended_data_line.match(line)
|
157
|
-
if dmi_record == nil
|
158
|
-
Ohai::Log.debug("unexpected extended data line found before header; discarding:\n#{line}")
|
159
|
-
next
|
160
|
-
end
|
161
|
-
if field == nil
|
162
|
-
Ohai::Log.debug("unexpected extended data line found outside data section; discarding:\n#{line}")
|
163
|
-
next
|
93
|
+
dmi_record = nil
|
94
|
+
field = nil
|
95
|
+
|
96
|
+
so = shell_out("smbios")
|
97
|
+
# ==== EXAMPLE: ====
|
98
|
+
# ID SIZE TYPE
|
99
|
+
# 0 40 SMB_TYPE_BIOS (BIOS information)
|
100
|
+
#
|
101
|
+
# Vendor: HP
|
102
|
+
# Version String: 2.16
|
103
|
+
# ... similar lines trimmed
|
104
|
+
# Characteristics: 0x7fc9da80
|
105
|
+
# SMB_BIOSFL_PCI (PCI is supported)
|
106
|
+
# ... similar lines trimmed
|
107
|
+
# note the second level of indentation is via a *tab*
|
108
|
+
so.stdout.lines do |raw_line|
|
109
|
+
next if header_type_line.match(raw_line)
|
110
|
+
next if blank_line.match(raw_line)
|
111
|
+
|
112
|
+
# remove/replace any characters that don't fall inside permissible ASCII range, or whitespace
|
113
|
+
line = raw_line.gsub(/[^\x20-\x7E\n\t\r]/, '.')
|
114
|
+
if (line != raw_line)
|
115
|
+
Ohai::Log.debug("converted characters from line:\n#{raw_line}")
|
164
116
|
end
|
165
|
-
# overwrite "raw" value with a new Mash
|
166
|
-
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field] = Mash.new unless dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field].class.to_s == 'Mash'
|
167
|
-
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field][extended_data[1]] = extended_data[2]
|
168
117
|
|
169
|
-
|
170
|
-
|
118
|
+
if header_information = header_information_line.match(line)
|
119
|
+
dmi_record = {}
|
120
|
+
|
121
|
+
# look up SMB ID
|
122
|
+
if smb_to_id.has_key?(header_information[3])
|
123
|
+
dmi_record[:type] = DMI.id_lookup(smb_to_id[header_information[3]])
|
171
124
|
|
125
|
+
else
|
126
|
+
dmi_record[:type] = header_information[3].downcase
|
127
|
+
Ohai::Log.debug("unrecognized header type; falling back to #{dmi_record[:type]}")
|
128
|
+
end
|
129
|
+
|
130
|
+
dmi[dmi_record[:type]] = Mash.new unless dmi.has_key?(dmi_record[:type])
|
131
|
+
dmi[dmi_record[:type]][:all_records] = [] unless dmi[dmi_record[:type]].has_key?(:all_records)
|
132
|
+
dmi_record[:position] = dmi[dmi_record[:type]][:all_records].length
|
133
|
+
dmi[dmi_record[:type]][:all_records].push(Mash.new)
|
134
|
+
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:record_id] = header_information[1]
|
135
|
+
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:size] = header_information[2]
|
136
|
+
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:application_identifier] = header_information[4]
|
137
|
+
field = nil
|
138
|
+
|
139
|
+
elsif data = data_key_value_line.match(line)
|
140
|
+
if dmi_record == nil
|
141
|
+
Ohai::Log.debug("unexpected data line found before header; discarding:\n#{line}")
|
142
|
+
next
|
143
|
+
end
|
144
|
+
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][data[1]] = data[2]
|
145
|
+
field = data[1]
|
146
|
+
|
147
|
+
elsif data = data_key_only_line.match(line)
|
148
|
+
if dmi_record == nil
|
149
|
+
Ohai::Log.debug("unexpected data line found before header; discarding:\n#{line}")
|
150
|
+
next
|
151
|
+
end
|
152
|
+
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][data[1]] = ''
|
153
|
+
field = data[1]
|
154
|
+
|
155
|
+
elsif extended_data = extended_data_line.match(line)
|
156
|
+
if dmi_record == nil
|
157
|
+
Ohai::Log.debug("unexpected extended data line found before header; discarding:\n#{line}")
|
158
|
+
next
|
159
|
+
end
|
160
|
+
if field == nil
|
161
|
+
Ohai::Log.debug("unexpected extended data line found outside data section; discarding:\n#{line}")
|
162
|
+
next
|
163
|
+
end
|
164
|
+
# overwrite "raw" value with a new Mash
|
165
|
+
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field] = Mash.new unless dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field].class.to_s == 'Mash'
|
166
|
+
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][field][extended_data[1]] = extended_data[2]
|
167
|
+
|
168
|
+
else
|
169
|
+
Ohai::Log.debug("unrecognized output line; discarding:\n#{line}")
|
170
|
+
|
171
|
+
end
|
172
172
|
end
|
173
|
+
|
174
|
+
DMI.convenience_keys(dmi)
|
173
175
|
end
|
174
176
|
end
|
175
|
-
|
176
|
-
DMI.convenience_keys(dmi)
|