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
data/lib/ohai/plugins/command.rb
CHANGED
@@ -16,8 +16,14 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:CPU) do
|
20
|
+
provides "cpu"
|
20
21
|
|
21
|
-
|
22
|
-
cpu
|
23
|
-
|
22
|
+
collect_data(:darwin) do
|
23
|
+
cpu Mash.new
|
24
|
+
so = shell_out("sysctl -n hw.physicalcpu")
|
25
|
+
cpu[:real] = so.stdout.to_i
|
26
|
+
so = shell_out("sysctl -n hw.logicalcpu")
|
27
|
+
cpu[:total] = so.stdout.to_i
|
28
|
+
end
|
29
|
+
end
|
@@ -16,42 +16,42 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Filesystem) do
|
20
|
+
provides "filesystem"
|
20
21
|
|
21
|
-
|
22
|
+
collect_data(:darwin) do
|
23
|
+
fs = Mash.new
|
22
24
|
|
23
|
-
block_size = 0
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
25
|
+
block_size = 0
|
26
|
+
so = shell_out("df")
|
27
|
+
so.stdout.lines do |line|
|
28
|
+
case line
|
29
|
+
when /^Filesystem\s+(\d+)-/
|
30
|
+
block_size = $1.to_i
|
31
|
+
next
|
32
|
+
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
|
33
|
+
filesystem = $1
|
34
|
+
fs[filesystem] = Mash.new
|
35
|
+
fs[filesystem][:block_size] = block_size
|
36
|
+
fs[filesystem][:kb_size] = $2.to_i / (1024 / block_size)
|
37
|
+
fs[filesystem][:kb_used] = $3.to_i / (1024 / block_size)
|
38
|
+
fs[filesystem][:kb_available] = $4.to_i / (1024 / block_size)
|
39
|
+
fs[filesystem][:percent_used] = $5
|
40
|
+
fs[filesystem][:mount] = $6
|
41
|
+
end
|
40
42
|
end
|
41
|
-
end
|
42
|
-
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
44
|
+
so = shell_out("mount")
|
45
|
+
so.stdout.lines do |line|
|
46
|
+
if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
|
47
|
+
filesystem = $1
|
48
|
+
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
|
49
|
+
fs[filesystem][:mount] = $2
|
50
|
+
fs[filesystem][:fs_type] = $3
|
51
|
+
fs[filesystem][:mount_options] = $4.split(/,\s*/)
|
52
|
+
end
|
53
53
|
end
|
54
|
+
|
55
|
+
filesystem fs
|
54
56
|
end
|
55
57
|
end
|
56
|
-
|
57
|
-
filesystem fs
|
@@ -16,182 +16,185 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
0.upto(line_array.length - 1) do |i|
|
39
|
-
unless line_array[i].eql?("none")
|
40
|
-
|
41
|
-
if line_array[i + 1] =~ /^\<([a-zA-Z\-\,]+)\>$/
|
42
|
-
media[line_array[i]] = Hash.new unless media.has_key?(line_array[i])
|
43
|
-
if media[line_array[i]].has_key?("options")
|
44
|
-
$1.split(",").each do |opt|
|
45
|
-
media[line_array[i]]["options"] << opt unless media[line_array[i]]["options"].include?(opt)
|
19
|
+
Ohai.plugin(:Network) do
|
20
|
+
provides "network", "network/interfaces"
|
21
|
+
provides "counters/network", "counters/network/interfaces"
|
22
|
+
|
23
|
+
def parse_media(media_string)
|
24
|
+
media = Hash.new
|
25
|
+
line_array = media_string.split(' ')
|
26
|
+
|
27
|
+
0.upto(line_array.length - 1) do |i|
|
28
|
+
unless line_array[i].eql?("none")
|
29
|
+
|
30
|
+
if line_array[i + 1] =~ /^\<([a-zA-Z\-\,]+)\>$/
|
31
|
+
media[line_array[i]] = Hash.new unless media.has_key?(line_array[i])
|
32
|
+
if media[line_array[i]].has_key?("options")
|
33
|
+
$1.split(",").each do |opt|
|
34
|
+
media[line_array[i]]["options"] << opt unless media[line_array[i]]["options"].include?(opt)
|
35
|
+
end
|
36
|
+
else
|
37
|
+
media[line_array[i]]["options"] = $1.split(",")
|
46
38
|
end
|
47
39
|
else
|
48
|
-
|
40
|
+
if line_array[i].eql?("autoselect")
|
41
|
+
media["autoselect"] = Hash.new unless media.has_key?("autoselect")
|
42
|
+
media["autoselect"]["options"] = []
|
43
|
+
end
|
49
44
|
end
|
50
45
|
else
|
51
|
-
|
52
|
-
media["autoselect"] = Hash.new unless media.has_key?("autoselect")
|
53
|
-
media["autoselect"]["options"] = []
|
54
|
-
end
|
46
|
+
media["none"] = { "options" => [] }
|
55
47
|
end
|
56
|
-
else
|
57
|
-
media["none"] = { "options" => [] }
|
58
48
|
end
|
59
|
-
end
|
60
49
|
|
61
|
-
|
62
|
-
end
|
50
|
+
media
|
51
|
+
end
|
63
52
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
53
|
+
def darwin_encaps_lookup(ifname)
|
54
|
+
return "Loopback" if ifname.eql?("lo")
|
55
|
+
return "1394" if ifname.eql?("fw")
|
56
|
+
return "IPIP" if ifname.eql?("gif")
|
57
|
+
return "6to4" if ifname.eql?("stf")
|
58
|
+
return "dot1q" if ifname.eql?("vlan")
|
59
|
+
"Unknown"
|
60
|
+
end
|
72
61
|
|
73
|
-
def scope_lookup(scope)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
62
|
+
def scope_lookup(scope)
|
63
|
+
return "Node" if scope.eql?("::1")
|
64
|
+
return "Link" if scope.match(/^fe80\:/)
|
65
|
+
return "Site" if scope.match(/^fec0\:/)
|
66
|
+
"Global"
|
67
|
+
end
|
79
68
|
|
80
|
-
def excluded_setting?(setting)
|
81
|
-
|
82
|
-
end
|
69
|
+
def excluded_setting?(setting)
|
70
|
+
setting.match('_sw_cksum')
|
71
|
+
end
|
83
72
|
|
84
|
-
def locate_interface(ifaces, ifname, mac)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
73
|
+
def locate_interface(ifaces, ifname, mac)
|
74
|
+
return ifname unless ifaces[ifname].nil?
|
75
|
+
# oh well, time to go hunting!
|
76
|
+
return ifname.chop if ifname.match /\*$/
|
77
|
+
ifaces.keys.each do |ifc|
|
78
|
+
ifaces[ifc][:addresses].keys.each do |addr|
|
79
|
+
return ifc if addr.eql? mac
|
80
|
+
end
|
91
81
|
end
|
82
|
+
|
83
|
+
nil
|
92
84
|
end
|
93
|
-
|
94
|
-
nil
|
95
|
-
end
|
96
85
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
iface[cint][:number] = $2
|
115
|
-
iface[cint][:encapsulation] = encaps_lookup($1)
|
86
|
+
collect_data(:darwin) do
|
87
|
+
require 'scanf'
|
88
|
+
|
89
|
+
network Mash.new unless network
|
90
|
+
network[:interfaces] = Mash.new unless network[:interfaces]
|
91
|
+
counters Mash.new unless counters
|
92
|
+
counters[:network] = Mash.new unless counters[:network]
|
93
|
+
|
94
|
+
so = shell_out("route -n get default")
|
95
|
+
so.stdout.lines do |line|
|
96
|
+
if line =~ /(\w+): ([\w\.]+)/
|
97
|
+
case $1
|
98
|
+
when "gateway"
|
99
|
+
network[:default_gateway] = $2
|
100
|
+
when "interface"
|
101
|
+
network[:default_interface] = $2
|
102
|
+
end
|
116
103
|
end
|
117
104
|
end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
105
|
+
|
106
|
+
iface = Mash.new
|
107
|
+
so = shell_out("ifconfig -a")
|
108
|
+
cint = nil
|
109
|
+
so.stdout.lines do |line|
|
110
|
+
if line =~ /^([0-9a-zA-Z\.\:\-]+): \S+ mtu (\d+)$/
|
111
|
+
cint = $1
|
112
|
+
iface[cint] = Mash.new unless iface[cint]; iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
113
|
+
iface[cint][:mtu] = $2
|
114
|
+
if line =~ /\sflags\=\d+\<((UP|BROADCAST|DEBUG|SMART|SIMPLEX|LOOPBACK|POINTOPOINT|NOTRAILERS|RUNNING|NOARP|PROMISC|ALLMULTI|SLAVE|MASTER|MULTICAST|DYNAMIC|,)+)\>\s/
|
115
|
+
flags = $1.split(',')
|
116
|
+
else
|
117
|
+
flags = Array.new
|
118
|
+
end
|
119
|
+
iface[cint][:flags] = flags.flatten
|
120
|
+
if cint =~ /^(\w+)(\d+.*)/
|
121
|
+
iface[cint][:type] = $1
|
122
|
+
iface[cint][:number] = $2
|
123
|
+
iface[cint][:encapsulation] = darwin_encaps_lookup($1)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
if line =~ /^\s+ether ([0-9a-f\:]+)/
|
127
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
128
|
+
iface[cint][:addresses][$1] = { "family" => "lladdr" }
|
129
|
+
iface[cint][:encapsulation] = "Ethernet"
|
130
|
+
end
|
131
|
+
if line =~ /^\s+lladdr ([0-9a-f\:]+)\s/
|
132
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
133
|
+
iface[cint][:addresses][$1] = { "family" => "lladdr" }
|
134
|
+
end
|
135
|
+
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask 0x(([0-9a-f]){1,8})\s*$/
|
136
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
137
|
+
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf('%2x'*4)*"."}
|
138
|
+
end
|
139
|
+
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask 0x(([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
|
140
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
141
|
+
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => $2.scanf('%2x'*4)*".", "broadcast" => $4 }
|
142
|
+
end
|
143
|
+
if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+)\s*/
|
144
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
145
|
+
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 , "scope" => scope_lookup($1) }
|
146
|
+
end
|
147
|
+
if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+) scopeid 0x([a-f0-9]+)/
|
148
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
149
|
+
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 , "scope" => scope_lookup($1) }
|
150
|
+
end
|
151
|
+
if line =~ /^\s+media: ((\w+)|(\w+ [a-zA-Z0-9\-\<\>]+)) status: (\w+)/
|
152
|
+
iface[cint][:media] = Mash.new unless iface[cint][:media]
|
153
|
+
iface[cint][:media][:selected] = parse_media($1)
|
154
|
+
iface[cint][:status] = $4
|
155
|
+
end
|
156
|
+
if line =~ /^\s+supported media: (.*)/
|
157
|
+
iface[cint][:media] = Mash.new unless iface[cint][:media]
|
158
|
+
iface[cint][:media][:supported] = parse_media($1)
|
159
|
+
end
|
151
160
|
end
|
152
|
-
end
|
153
|
-
end
|
154
161
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
162
|
+
so = shell_out("arp -an")
|
163
|
+
so.stdout.lines do |line|
|
164
|
+
if line =~ /^\S+ \((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([a-zA-Z0-9\.\:\-]+).*\[(\w+)\]/
|
165
|
+
# MAC addr really should be normalized to include all the zeroes.
|
166
|
+
next if iface[$3].nil? # this should never happen
|
167
|
+
iface[$3][:arp] = Mash.new unless iface[$3][:arp]
|
168
|
+
iface[$3][:arp][$1] = $2
|
169
|
+
end
|
163
170
|
end
|
164
|
-
end
|
165
|
-
end
|
166
171
|
|
167
|
-
settings = Mash.new
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
172
|
+
settings = Mash.new
|
173
|
+
so = shell_out("sysctl net")
|
174
|
+
so.stdout.lines do |line|
|
175
|
+
if line =~ /^([a-zA-Z0-9\.\_]+)\: (.*)/
|
176
|
+
# should normalize names between platforms for the same settings.
|
177
|
+
settings[$1] = $2 unless excluded_setting?($1)
|
178
|
+
end
|
174
179
|
end
|
175
|
-
end
|
176
|
-
end
|
177
180
|
|
178
|
-
network[:settings] = settings
|
179
|
-
network[:interfaces] = iface
|
180
|
-
|
181
|
-
net_counters = Mash.new
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
181
|
+
network[:settings] = settings
|
182
|
+
network[:interfaces] = iface
|
183
|
+
|
184
|
+
net_counters = Mash.new
|
185
|
+
so = shell_out("netstat -i -d -l -b -n")
|
186
|
+
so.stdout.lines do |line|
|
187
|
+
if line =~ /^([a-zA-Z0-9\.\:\-\*]+)\s+\d+\s+\<[a-zA-Z0-9\#]+\>\s+([a-f0-9\:]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ ||
|
188
|
+
line =~ /^([a-zA-Z0-9\.\:\-\*]+)\s+\d+\s+\<[a-zA-Z0-9\#]+\>(\s+)(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
189
|
+
ifname = locate_interface(iface, $1, $2)
|
190
|
+
next if iface[ifname].nil? # this shouldn't happen, but just in case
|
191
|
+
net_counters[ifname] = Mash.new unless net_counters[ifname]
|
192
|
+
net_counters[ifname] = { :rx => { :bytes => $5, :packets => $3, :errors => $4, :drop => 0, :overrun => 0, :frame => 0, :compressed => 0, :multicast => 0 },
|
193
|
+
:tx => { :bytes => $8, :packets => $6, :errors => $7, :drop => 0, :overrun => 0, :collisions => $9, :carrier => 0, :compressed => 0 }
|
194
|
+
}
|
195
|
+
end
|
193
196
|
end
|
197
|
+
|
198
|
+
counters[:network][:interfaces] = net_counters
|
194
199
|
end
|
195
200
|
end
|
196
|
-
|
197
|
-
counters[:network][:interfaces] = net_counters
|
@@ -16,23 +16,25 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Platform) do
|
20
|
+
provides "platform", "platform_version", "platform_build", "platform_family"
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
collect_data(:darwin) do
|
23
|
+
so = shell_out("#{ Ohai.abs_path( "/usr/bin/sw_vers" )}")
|
24
|
+
so.stdout.lines do |line|
|
25
|
+
case line
|
26
|
+
when /^ProductName:\s+(.+)$/
|
27
|
+
macname = $1
|
28
|
+
macname.downcase!
|
29
|
+
macname.gsub!(" ", "_")
|
30
|
+
platform macname
|
31
|
+
when /^ProductVersion:\s+(.+)$/
|
32
|
+
platform_version $1
|
33
|
+
when /^BuildVersion:\s+(.+)$/
|
34
|
+
platform_build $1
|
35
|
+
end
|
34
36
|
end
|
37
|
+
|
38
|
+
platform_family "mac_os_x"
|
35
39
|
end
|
36
40
|
end
|
37
|
-
|
38
|
-
platform_family "mac_os_x"
|