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,37 +16,42 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:CPU) do
|
20
|
+
provides "cpu"
|
20
21
|
|
21
|
-
|
22
|
-
#
|
23
|
-
#
|
24
|
-
|
22
|
+
collect_data(:freebsd) do
|
23
|
+
# all dmesg output for smp I can find only provides info about a single processor
|
24
|
+
# identical processors is probably a hardware requirement so we'll duplicate data for each cpu
|
25
|
+
# old examples: http://www.bnv-bamberg.de/home/ba3294/smp/rbuild/index.htm
|
26
|
+
cpuinfo = Mash.new
|
25
27
|
|
26
|
-
# /var/run/dmesg.boot
|
27
|
-
#CPU: QEMU Virtual CPU version 0.9.1 (1862.02-MHz 686-class CPU)
|
28
|
-
# Origin = "GenuineIntel" Id = 0x623 Stepping = 3
|
29
|
-
# Features=0x78bfbfd<FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2>
|
30
|
-
# Features2=0x80000001<SSE3,<b31>>
|
28
|
+
# /var/run/dmesg.boot
|
29
|
+
#CPU: QEMU Virtual CPU version 0.9.1 (1862.02-MHz 686-class CPU)
|
30
|
+
# Origin = "GenuineIntel" Id = 0x623 Stepping = 3
|
31
|
+
# Features=0x78bfbfd<FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2>
|
32
|
+
# Features2=0x80000001<SSE3,<b31>>
|
31
33
|
|
32
|
-
File.open("/var/run/dmesg.boot").each do |line|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
34
|
+
File.open("/var/run/dmesg.boot").each do |line|
|
35
|
+
case line
|
36
|
+
when /CPU:\s+(.+) \(([\d.]+).+\)/
|
37
|
+
cpuinfo["model_name"] = $1
|
38
|
+
cpuinfo["mhz"] = $2
|
39
|
+
when /Origin = "(.+)"\s+Id = (.+)\s+Stepping = (.+)/
|
40
|
+
cpuinfo["vendor_id"] = $1
|
41
|
+
cpuinfo["stepping"] = $3
|
42
|
+
# These _should_ match /AMD Features2?/ lines as well
|
43
|
+
when /Features=.+<(.+)>/
|
44
|
+
cpuinfo["flags"] = $1.downcase.split(',')
|
45
|
+
# Features2=0x80000001<SSE3,<b31>>
|
46
|
+
when /Features2=[a-f\dx]+<(.+)>/
|
47
|
+
cpuinfo["flags"].concat($1.downcase.split(','))
|
48
|
+
when /Logical CPUs per core: (\d+)/
|
49
|
+
cpuinfo["cores"] = $1
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
cpu cpuinfo
|
54
|
+
so = shell_out("sysctl -n hw.ncpu")
|
55
|
+
cpu[:total] = so.stdout.split($/)[0]
|
48
56
|
end
|
49
57
|
end
|
50
|
-
|
51
|
-
cpu cpuinfo
|
52
|
-
cpu[:total] = from("sysctl -n hw.ncpu")
|
@@ -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(:freebsd) do
|
23
|
+
fs = Mash.new
|
22
24
|
|
23
|
-
# Grab filesystem data from df
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
38
40
|
end
|
39
|
-
end
|
40
|
-
end
|
41
41
|
|
42
|
-
# Grab mount information from mount
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
52
|
end
|
53
|
+
|
54
|
+
# Set the filesystem data
|
55
|
+
filesystem fs
|
53
56
|
end
|
54
57
|
end
|
55
|
-
|
56
|
-
# Set the filesystem data
|
57
|
-
filesystem fs
|
@@ -16,34 +16,44 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Memory) do
|
20
|
+
provides "memory", "memory/swap"
|
20
21
|
|
21
|
-
|
22
|
-
memory
|
22
|
+
collect_data(:freebsd) do
|
23
|
+
memory Mash.new
|
24
|
+
memory[:swap] = Mash.new
|
23
25
|
|
24
|
-
# /usr/src/sys/sys/vmmeter.h
|
25
|
-
|
26
|
-
memory[:
|
27
|
-
|
28
|
-
memory[:
|
29
|
-
memory[:
|
30
|
-
|
31
|
-
memory[:
|
32
|
-
|
33
|
-
memory[:
|
26
|
+
# /usr/src/sys/sys/vmmeter.h
|
27
|
+
so = shell_out("sysctl -n vm.stats.vm.v_page_size")
|
28
|
+
memory[:page_size] = so.stdout.split($/)[0]
|
29
|
+
so = shell_out("sysctl -n vm.stats.vm.v_page_count")
|
30
|
+
memory[:page_count] = so.stdout.split($/)[0]
|
31
|
+
memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
|
32
|
+
so = shell_out("sysctl -n vm.stats.vm.v_free_count")
|
33
|
+
memory[:free] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
|
34
|
+
so = shell_out("sysctl -n vm.status.vm.v_active_count")
|
35
|
+
memory[:active] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
|
36
|
+
so = shell_out("sysctl -n vm.status.vm.v_inactive_count")
|
37
|
+
memory[:inactive] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
|
38
|
+
so = shell_out("sysctl -n vm.stats.vm.v_cache_count")
|
39
|
+
memory[:cache] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
|
40
|
+
so = shell_out("sysctl -n vm.stats.vm.v_wire_count")
|
41
|
+
memory[:wired] = memory[:page_size].to_i * so.stdout.split($/)[0].to_i
|
42
|
+
so = shell_out("sysctl -n vfs.bufspace")
|
43
|
+
memory[:buffers] = so.stdout.split($/)[0]
|
34
44
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
so = shell_out("swapinfo")
|
46
|
+
so.stdout.lines do |line|
|
47
|
+
# Device 1K-blocks Used Avail Capacity
|
48
|
+
# /dev/ad0s1b 253648 0 253648 0%
|
49
|
+
if line =~ /^([\d\w\/]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\%]+)/
|
50
|
+
mdev = $1
|
51
|
+
memory[:swap][mdev] = Mash.new
|
52
|
+
memory[:swap][mdev][:total] = $2
|
53
|
+
memory[:swap][mdev][:used] = $3
|
54
|
+
memory[:swap][mdev][:free] = $4
|
55
|
+
memory[:swap][mdev][:percent_free] = $5
|
56
|
+
end
|
47
57
|
end
|
48
58
|
end
|
49
59
|
end
|
@@ -16,106 +16,111 @@
|
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
when "interface"
|
27
|
-
network[:default_interface] = $2
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
23
|
+
collect_data(:freebsd) do
|
24
|
+
network Mash.new unless network
|
25
|
+
network[:interfaces] = Mash.new unless network[:interfaces]
|
26
|
+
counters Mash.new unless counters
|
27
|
+
counters[:network] = Mash.new unless counters[:network]
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
iface[cint][:type] = $1
|
42
|
-
iface[cint][:number] = $2
|
29
|
+
so = shell_out("route -n get default")
|
30
|
+
so.stdout.lines do |line|
|
31
|
+
if line =~ /(\w+): ([\w\.]+)/
|
32
|
+
case $1
|
33
|
+
when "gateway"
|
34
|
+
network[:default_gateway] = $2
|
35
|
+
when "interface"
|
36
|
+
network[:default_interface] = $2
|
37
|
+
end
|
43
38
|
end
|
44
39
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
# found a broadcast address
|
58
|
-
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask, "broadcast" => $3 }
|
40
|
+
|
41
|
+
iface = Mash.new
|
42
|
+
so = shell_out("#{ Ohai.abs_path( "/sbin/ifconfig" )} -a")
|
43
|
+
cint = nil
|
44
|
+
so.stdout.lines do |line|
|
45
|
+
if line =~ /^([0-9a-zA-Z\.]+):\s+/
|
46
|
+
cint = $1
|
47
|
+
iface[cint] = Mash.new
|
48
|
+
if cint =~ /^(\w+)(\d+.*)/
|
49
|
+
iface[cint][:type] = $1
|
50
|
+
iface[cint][:number] = $2
|
51
|
+
end
|
59
52
|
end
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
53
|
+
# call the family lladdr to match linux for consistency
|
54
|
+
if line =~ /\s+ether (.+?)\s/
|
55
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
56
|
+
iface[cint][:addresses][$1] = { "family" => "lladdr" }
|
57
|
+
end
|
58
|
+
if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
|
59
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
60
|
+
# convert the netmask to decimal for consistency
|
61
|
+
netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}"
|
62
|
+
if $3.empty?
|
63
|
+
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask }
|
64
|
+
else
|
65
|
+
# found a broadcast address
|
66
|
+
iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask, "broadcast" => $3 }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
if line =~ /\s+inet6 ([a-f0-9\:]+)%?(\w*)\s+prefixlen\s+(\d+)\s*\w*\s*([\da-fx]*)/
|
70
|
+
iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
|
71
|
+
if $4.empty?
|
72
|
+
iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
|
73
|
+
else
|
74
|
+
# found a zone_id / scope
|
75
|
+
iface[cint][:addresses][$1] = { "family" => "inet6", "zoneid" => $2, "prefixlen" => $3, "scopeid" => $4 }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
if line =~ /flags=\d+<(.+)>/
|
79
|
+
flags = $1.split(',')
|
80
|
+
iface[cint][:flags] = flags if flags.length > 0
|
81
|
+
end
|
82
|
+
if line =~ /metric: (\d+) mtu: (\d+)/
|
83
|
+
iface[cint][:metric] = $1
|
84
|
+
iface[cint][:mtu] = $2
|
68
85
|
end
|
69
86
|
end
|
70
|
-
if line =~ /flags=\d+<(.+)>/
|
71
|
-
flags = $1.split(',')
|
72
|
-
iface[cint][:flags] = flags if flags.length > 0
|
73
|
-
end
|
74
|
-
if line =~ /metric: (\d+) mtu: (\d+)/
|
75
|
-
iface[cint][:metric] = $1
|
76
|
-
iface[cint][:mtu] = $2
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
87
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
+
so = shell_out("arp -an")
|
89
|
+
so.stdout.lines do |line|
|
90
|
+
if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
|
91
|
+
next unless iface[$3] # this should never happen
|
92
|
+
iface[$3][:arp] = Mash.new unless iface[$3][:arp]
|
93
|
+
iface[$3][:arp][$1] = $2.downcase
|
94
|
+
end
|
88
95
|
end
|
89
|
-
end
|
90
|
-
end
|
91
96
|
|
92
|
-
network["interfaces"] = iface
|
97
|
+
network["interfaces"] = iface
|
93
98
|
|
94
|
-
net_counters = Mash.new
|
95
|
-
# From netstat(1), not sure of the implications:
|
96
|
-
# Show the state of all network interfaces or a single interface
|
97
|
-
# which have been auto-configured (interfaces statically configured
|
98
|
-
# into a system, but not located at boot time are not shown).
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
99
|
+
net_counters = Mash.new
|
100
|
+
# From netstat(1), not sure of the implications:
|
101
|
+
# Show the state of all network interfaces or a single interface
|
102
|
+
# which have been auto-configured (interfaces statically configured
|
103
|
+
# into a system, but not located at boot time are not shown).
|
104
|
+
so = shell_out("netstat -ibdn")
|
105
|
+
so.stdout.lines do |line|
|
106
|
+
# Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll Drop
|
107
|
+
# ed0 1500 <Link#1> 54:52:00:68:92:85 333604 26 151905886 175472 0 24897542 0 905
|
108
|
+
# $1 $2 $3 $4 $5 $6 $7 $8 $9 $10
|
109
|
+
if line =~ /^([\w\.\*]+)\s+\d+\s+<Link#\d+>\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
|
110
|
+
net_counters[$1] = Mash.new unless net_counters[$1]
|
111
|
+
net_counters[$1]["rx"] = Mash.new unless net_counters[$1]["rx"]
|
112
|
+
net_counters[$1]["tx"] = Mash.new unless net_counters[$1]["tx"]
|
113
|
+
net_counters[$1]["rx"]["packets"] = $3
|
114
|
+
net_counters[$1]["rx"]["errors"] = $4
|
115
|
+
net_counters[$1]["rx"]["bytes"] = $5
|
116
|
+
net_counters[$1]["tx"]["packets"] = $6
|
117
|
+
net_counters[$1]["tx"]["errors"] = $7
|
118
|
+
net_counters[$1]["tx"]["bytes"] = $8
|
119
|
+
net_counters[$1]["tx"]["collisions"] = $9
|
120
|
+
net_counters[$1]["tx"]["dropped"] = $10
|
121
|
+
end
|
117
122
|
end
|
123
|
+
|
124
|
+
counters[:network][:interfaces] = net_counters
|
118
125
|
end
|
119
126
|
end
|
120
|
-
|
121
|
-
counters[:network][:interfaces] = net_counters
|
@@ -16,8 +16,14 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
platform from("uname -s").downcase
|
22
|
-
platform_version from("uname -r")
|
19
|
+
Ohai.plugin(:Platform) do
|
20
|
+
provides "platform", "platform_version", "platform_family"
|
23
21
|
|
22
|
+
collect_data(:freebsd) do
|
23
|
+
so = shell_out("uname -s")
|
24
|
+
platform so.stdout.split($/)[0].downcase
|
25
|
+
so = shell_out("uname -r")
|
26
|
+
platform_version so.stdout.split($/)[0]
|
27
|
+
platform_family "freebsd"
|
28
|
+
end
|
29
|
+
end
|
@@ -16,78 +16,79 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Virtualization) do
|
20
|
+
provides "virtualization"
|
20
21
|
|
21
|
-
|
22
|
+
collect_data(:freebsd) do
|
23
|
+
virtualization Mash.new
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
# detect from modules
|
29
|
-
popen4("/sbin/kldstat") do |pid, stdin, stdout, stderr|
|
30
|
-
stdin.close
|
31
|
-
stdout.each do |line|
|
32
|
-
case line
|
33
|
-
when /vboxdrv/
|
34
|
-
virtualization[:system] = "vbox"
|
35
|
-
virtualization[:role] = "host"
|
36
|
-
when /vboxguest/
|
37
|
-
virtualization[:system] = "vbox"
|
25
|
+
so = shell_out("sysctl -n security.jail.jailed")
|
26
|
+
if so.stdout.split($/)[0].to_i == 1
|
27
|
+
virtualization[:system] = "jail"
|
38
28
|
virtualization[:role] = "guest"
|
39
29
|
end
|
40
|
-
end
|
41
|
-
end
|
42
30
|
|
31
|
+
# detect from modules
|
32
|
+
so = shell_out("#{ Ohai.abs_path( "/sbin/kldstat" )}")
|
33
|
+
so.stdout.lines do |line|
|
34
|
+
case line
|
35
|
+
when /vboxdrv/
|
36
|
+
virtualization[:system] = "vbox"
|
37
|
+
virtualization[:role] = "host"
|
38
|
+
when /vboxguest/
|
39
|
+
virtualization[:system] = "vbox"
|
40
|
+
virtualization[:role] = "guest"
|
41
|
+
end
|
42
|
+
end
|
43
43
|
|
44
|
-
# XXX doesn't work when jail is there but not running (ezjail-admin stop)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
# XXX doesn't work when jail is there but not running (ezjail-admin stop)
|
45
|
+
so = shell_out("jls -n")
|
46
|
+
if ( so.stdout || "" ).lines.count >= 1
|
47
|
+
virtualization[:system] = "jail"
|
48
|
+
virtualization[:role] = "host"
|
49
|
+
end
|
49
50
|
|
50
|
-
# KVM Host support for FreeBSD is in development
|
51
|
-
# http://feanor.sssup.it/~fabio/freebsd/lkvm/
|
51
|
+
# KVM Host support for FreeBSD is in development
|
52
|
+
# http://feanor.sssup.it/~fabio/freebsd/lkvm/
|
52
53
|
|
53
|
-
# Detect KVM/QEMU from cpu, report as KVM
|
54
|
-
# hw.model: QEMU Virtual CPU version 0.9.1
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
# Detect KVM/QEMU from cpu, report as KVM
|
55
|
+
# hw.model: QEMU Virtual CPU version 0.9.1
|
56
|
+
so = shell_out("sysctl -n hw.model")
|
57
|
+
if so.stdout.split($/)[0] =~ /QEMU Virtual CPU/
|
58
|
+
virtualization[:system] = "kvm"
|
59
|
+
virtualization[:role] = "guest"
|
60
|
+
end
|
59
61
|
|
60
|
-
# http://www.dmo.ca/blog/detecting-virtualization-on-linux
|
61
|
-
if File.exists?("/usr/local/sbin/dmidecode")
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
62
|
+
# http://www.dmo.ca/blog/detecting-virtualization-on-linux
|
63
|
+
if File.exists?("/usr/local/sbin/dmidecode")
|
64
|
+
so = shell_out("dmidecode")
|
65
|
+
found_virt_manufacturer = nil
|
66
|
+
found_virt_product = nil
|
67
|
+
so.stdout.lines do |line|
|
68
|
+
case line
|
69
|
+
when /Manufacturer: Microsoft/
|
70
|
+
found_virt_manufacturer = "microsoft"
|
71
|
+
when /Product Name: Virtual Machine/
|
72
|
+
found_virt_product = "microsoft"
|
73
|
+
when /Version: 5.0/
|
74
|
+
if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
|
75
|
+
virtualization[:system] = "virtualpc"
|
76
|
+
virtualization[:role] = "guest"
|
77
|
+
end
|
78
|
+
when /Version: VS2005R2/
|
79
|
+
if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
|
80
|
+
virtualization[:system] = "virtualserver"
|
81
|
+
virtualization[:role] = "guest"
|
82
|
+
end
|
83
|
+
when /Manufacturer: VMware/
|
84
|
+
found_virt_manufacturer = "vmware"
|
85
|
+
when /Product Name: VMware Virtual Platform/
|
86
|
+
if found_virt_manufacturer == "vmware"
|
87
|
+
virtualization[:system] = "vmware"
|
88
|
+
virtualization[:role] = "guest"
|
89
|
+
end
|
88
90
|
end
|
89
91
|
end
|
90
92
|
end
|
91
93
|
end
|
92
94
|
end
|
93
|
-
|