ohai 18.2.6 → 19.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +28 -28
- data/LICENSE +201 -201
- data/bin/ohai +25 -25
- data/lib/ohai/application.rb +189 -189
- data/lib/ohai/common/dmi.rb +167 -167
- data/lib/ohai/config.rb +51 -51
- data/lib/ohai/dsl/plugin/versionvii.rb +203 -203
- data/lib/ohai/dsl/plugin.rb +232 -232
- data/lib/ohai/dsl.rb +22 -22
- data/lib/ohai/exception.rb +36 -36
- data/lib/ohai/hints.rb +68 -68
- data/lib/ohai/loader.rb +178 -178
- data/lib/ohai/log.rb +34 -34
- data/lib/ohai/mash.rb +22 -22
- data/lib/ohai/mixin/alibaba_metadata.rb +83 -83
- data/lib/ohai/mixin/azure_metadata.rb +105 -105
- data/lib/ohai/mixin/chef_utils_wiring.rb +52 -52
- data/lib/ohai/mixin/command.rb +4 -4
- data/lib/ohai/mixin/constant_helper.rb +55 -55
- data/lib/ohai/mixin/dmi_decode.rb +54 -54
- data/lib/ohai/mixin/do_metadata.rb +48 -48
- data/lib/ohai/mixin/ec2_metadata.rb +264 -270
- data/lib/ohai/mixin/gce_metadata.rb +79 -79
- data/lib/ohai/mixin/http_helper.rb +64 -64
- data/lib/ohai/mixin/json_helper.rb +36 -36
- data/lib/ohai/mixin/network_helper.rb +92 -92
- data/lib/ohai/mixin/oci_metadata.rb +60 -60
- data/lib/ohai/mixin/os.rb +128 -128
- data/lib/ohai/mixin/scaleway_metadata.rb +51 -51
- data/lib/ohai/mixin/seconds_to_human.rb +52 -52
- data/lib/ohai/mixin/shell_out.rb +51 -51
- data/lib/ohai/mixin/softlayer_metadata.rb +74 -74
- data/lib/ohai/mixin/string.rb +31 -31
- data/lib/ohai/mixin/train_helpers.rb +36 -36
- data/lib/ohai/mixin/which.rb +39 -39
- data/lib/ohai/plugin_config.rb +47 -47
- data/lib/ohai/plugins/aix/kernel.rb +50 -50
- data/lib/ohai/plugins/aix/memory.rb +37 -37
- data/lib/ohai/plugins/aix/network.rb +142 -142
- data/lib/ohai/plugins/aix/platform.rb +30 -30
- data/lib/ohai/plugins/aix/uptime.rb +54 -54
- data/lib/ohai/plugins/aix/virtualization.rb +154 -154
- data/lib/ohai/plugins/alibaba.rb +72 -72
- data/lib/ohai/plugins/azure.rb +154 -154
- data/lib/ohai/plugins/bsd/virtualization.rb +121 -121
- data/lib/ohai/plugins/c.rb +178 -178
- data/lib/ohai/plugins/chef.rb +50 -50
- data/lib/ohai/plugins/cloud.rb +379 -379
- data/lib/ohai/plugins/command.rb +26 -26
- data/lib/ohai/plugins/cpu.rb +642 -642
- data/lib/ohai/plugins/darwin/hardware.rb +99 -99
- data/lib/ohai/plugins/darwin/memory.rb +62 -62
- data/lib/ohai/plugins/darwin/network.rb +207 -207
- data/lib/ohai/plugins/darwin/platform.rb +40 -40
- data/lib/ohai/plugins/darwin/virtualization.rb +104 -104
- data/lib/ohai/plugins/digital_ocean.rb +67 -67
- data/lib/ohai/plugins/dmi.rb +134 -134
- data/lib/ohai/plugins/docker.rb +58 -58
- data/lib/ohai/plugins/dragonflybsd/memory.rb +60 -60
- data/lib/ohai/plugins/dragonflybsd/network.rb +128 -128
- data/lib/ohai/plugins/dragonflybsd/platform.rb +28 -28
- data/lib/ohai/plugins/ec2.rb +148 -148
- data/lib/ohai/plugins/elixir.rb +36 -36
- data/lib/ohai/plugins/erlang.rb +60 -60
- data/lib/ohai/plugins/eucalyptus.rb +86 -86
- data/lib/ohai/plugins/filesystem.rb +753 -753
- data/lib/ohai/plugins/fips.rb +36 -36
- data/lib/ohai/plugins/freebsd/memory.rb +60 -60
- data/lib/ohai/plugins/freebsd/network.rb +128 -128
- data/lib/ohai/plugins/freebsd/platform.rb +28 -28
- data/lib/ohai/plugins/gce.rb +89 -89
- data/lib/ohai/plugins/go.rb +34 -34
- data/lib/ohai/plugins/groovy.rb +38 -38
- data/lib/ohai/plugins/grub2.rb +40 -40
- data/lib/ohai/plugins/habitat.rb +73 -73
- data/lib/ohai/plugins/haskell.rb +96 -96
- data/lib/ohai/plugins/hostname.rb +133 -133
- data/lib/ohai/plugins/init_package.rb +26 -26
- data/lib/ohai/plugins/java.rb +78 -78
- data/lib/ohai/plugins/kernel.rb +292 -292
- data/lib/ohai/plugins/keys.rb +27 -27
- data/lib/ohai/plugins/languages.rb +26 -26
- data/lib/ohai/plugins/libvirt.rb +114 -114
- data/lib/ohai/plugins/linode.rb +73 -73
- data/lib/ohai/plugins/linux/block_device.rb +48 -48
- data/lib/ohai/plugins/linux/hostnamectl.rb +34 -34
- data/lib/ohai/plugins/linux/interrupts.rb +84 -83
- data/lib/ohai/plugins/linux/ipc.rb +52 -52
- data/lib/ohai/plugins/linux/livepatch.rb +38 -38
- data/lib/ohai/plugins/linux/lsb.rb +46 -46
- data/lib/ohai/plugins/linux/lspci.rb +80 -80
- data/lib/ohai/plugins/linux/machineid.rb +36 -36
- data/lib/ohai/plugins/linux/mdadm.rb +120 -120
- data/lib/ohai/plugins/linux/memory.rb +106 -106
- data/lib/ohai/plugins/linux/network.rb +879 -879
- data/lib/ohai/plugins/linux/os_release.rb +38 -38
- data/lib/ohai/plugins/linux/platform.rb +314 -314
- data/lib/ohai/plugins/linux/selinux.rb +69 -69
- data/lib/ohai/plugins/linux/sessions.rb +54 -54
- data/lib/ohai/plugins/linux/sysctl.rb +39 -39
- data/lib/ohai/plugins/linux/systemd_paths.rb +36 -36
- data/lib/ohai/plugins/linux/tc.rb +61 -61
- data/lib/ohai/plugins/linux/virtualization.rb +300 -300
- data/lib/ohai/plugins/lua.rb +39 -39
- data/lib/ohai/plugins/mono.rb +50 -50
- data/lib/ohai/plugins/netbsd/memory.rb +99 -99
- data/lib/ohai/plugins/netbsd/network.rb +122 -122
- data/lib/ohai/plugins/netbsd/platform.rb +28 -28
- data/lib/ohai/plugins/network.rb +186 -186
- data/lib/ohai/plugins/nodejs.rb +40 -40
- data/lib/ohai/plugins/oci.rb +94 -94
- data/lib/ohai/plugins/ohai.rb +29 -29
- data/lib/ohai/plugins/ohai_time.rb +26 -26
- data/lib/ohai/plugins/openbsd/memory.rb +99 -99
- data/lib/ohai/plugins/openbsd/network.rb +122 -122
- data/lib/ohai/plugins/openbsd/platform.rb +28 -28
- data/lib/ohai/plugins/openstack.rb +84 -84
- data/lib/ohai/plugins/os.rb +55 -55
- data/lib/ohai/plugins/packages.rb +234 -234
- data/lib/ohai/plugins/passwd.rb +104 -104
- data/lib/ohai/plugins/perl.rb +45 -45
- data/lib/ohai/plugins/php.rb +52 -52
- data/lib/ohai/plugins/platform.rb +41 -41
- data/lib/ohai/plugins/powershell.rb +82 -82
- data/lib/ohai/plugins/ps.rb +35 -35
- data/lib/ohai/plugins/python.rb +43 -43
- data/lib/ohai/plugins/rackspace.rb +177 -177
- data/lib/ohai/plugins/root_group.rb +41 -41
- data/lib/ohai/plugins/rpm.rb +121 -121
- data/lib/ohai/plugins/ruby.rb +66 -66
- data/lib/ohai/plugins/rust.rb +34 -34
- data/lib/ohai/plugins/scala.rb +38 -38
- data/lib/ohai/plugins/scaleway.rb +58 -58
- data/lib/ohai/plugins/scsi.rb +52 -52
- data/lib/ohai/plugins/shard.rb +142 -142
- data/lib/ohai/plugins/shells.rb +32 -32
- data/lib/ohai/plugins/softlayer.rb +48 -48
- data/lib/ohai/plugins/solaris2/dmi.rb +191 -191
- data/lib/ohai/plugins/solaris2/memory.rb +32 -32
- data/lib/ohai/plugins/solaris2/network.rb +192 -192
- data/lib/ohai/plugins/solaris2/platform.rb +58 -58
- data/lib/ohai/plugins/solaris2/virtualization.rb +90 -90
- data/lib/ohai/plugins/ssh_host_key.rb +84 -84
- data/lib/ohai/plugins/sysconf.rb +46 -46
- data/lib/ohai/plugins/timezone.rb +45 -45
- data/lib/ohai/plugins/train.rb +35 -35
- data/lib/ohai/plugins/uptime.rb +95 -95
- data/lib/ohai/plugins/virtualbox.rb +197 -197
- data/lib/ohai/plugins/vmware.rb +109 -109
- data/lib/ohai/plugins/windows/dmi.rb +95 -95
- data/lib/ohai/plugins/windows/drivers.rb +52 -52
- data/lib/ohai/plugins/windows/memory.rb +39 -39
- data/lib/ohai/plugins/windows/network.rb +222 -222
- data/lib/ohai/plugins/windows/platform.rb +34 -34
- data/lib/ohai/plugins/windows/system_enclosure.rb +29 -29
- data/lib/ohai/plugins/windows/virtualization.rb +45 -45
- data/lib/ohai/plugins/zpools.rb +94 -94
- data/lib/ohai/provides_map.rb +208 -208
- data/lib/ohai/runner.rb +128 -126
- data/lib/ohai/system.rb +258 -258
- data/lib/ohai/train_transport.rb +29 -29
- data/lib/ohai/util/file_helper.rb +6 -6
- data/lib/ohai/util/ip_helper.rb +56 -56
- data/lib/ohai/util/win32.rb +47 -47
- data/lib/ohai/version.rb +23 -23
- data/lib/ohai.rb +23 -23
- data/ohai.gemspec +35 -35
- metadata +9 -15
@@ -1,36 +1,36 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Davide Cavalca (<dcavalca@fb.com>)
|
4
|
-
# Copyright:: Copyright (c) 2016 Facebook
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
Ohai.plugin(:Machineid) do
|
21
|
-
provides "machine_id"
|
22
|
-
|
23
|
-
collect_data(:linux) do
|
24
|
-
if file_exist?("/etc/machine-id")
|
25
|
-
mid = file_read("/etc/machine-id").chomp
|
26
|
-
elsif file_exist?("/var/lib/dbus/machine-id")
|
27
|
-
mid = file_read("/var/lib/dbus/machine-id").chomp
|
28
|
-
else
|
29
|
-
mid = nil
|
30
|
-
end
|
31
|
-
|
32
|
-
if mid
|
33
|
-
machine_id mid
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Davide Cavalca (<dcavalca@fb.com>)
|
4
|
+
# Copyright:: Copyright (c) 2016 Facebook
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
Ohai.plugin(:Machineid) do
|
21
|
+
provides "machine_id"
|
22
|
+
|
23
|
+
collect_data(:linux) do
|
24
|
+
if file_exist?("/etc/machine-id")
|
25
|
+
mid = file_read("/etc/machine-id").chomp
|
26
|
+
elsif file_exist?("/var/lib/dbus/machine-id")
|
27
|
+
mid = file_read("/var/lib/dbus/machine-id").chomp
|
28
|
+
else
|
29
|
+
mid = nil
|
30
|
+
end
|
31
|
+
|
32
|
+
if mid
|
33
|
+
machine_id mid
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,120 +1,120 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Tim Smith <tsmith@limelight.com>
|
4
|
-
# Author:: Phil Dibowitz <phild@ipomc.com>
|
5
|
-
# Copyright:: Copyright (c) 2013-2014, Limelight Networks, Inc.
|
6
|
-
# Copyright:: Copyright (c) 2017 Facebook, Inc.
|
7
|
-
# Plugin:: mdadm
|
8
|
-
#
|
9
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
-
# you may not use this file except in compliance with the License.
|
11
|
-
# You may obtain a copy of the License at
|
12
|
-
#
|
13
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
-
#
|
15
|
-
# Unless required by applicable law or agreed to in writing, software
|
16
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
-
# See the License for the specific language governing permissions and
|
19
|
-
# limitations under the License.
|
20
|
-
#
|
21
|
-
|
22
|
-
Ohai.plugin(:Mdadm) do
|
23
|
-
provides "mdadm"
|
24
|
-
|
25
|
-
def create_raid_device_mash(stdout)
|
26
|
-
device_mash = Mash.new
|
27
|
-
device_mash[:device_counts] = Mash.new
|
28
|
-
stdout.lines.each do |line|
|
29
|
-
case line
|
30
|
-
when /Version\s+: ([0-9.]+)/
|
31
|
-
device_mash[:version] = Regexp.last_match[1].to_f
|
32
|
-
when /Raid Level\s+: raid([0-9]+)/
|
33
|
-
device_mash[:level] = Regexp.last_match[1].to_i
|
34
|
-
when /Array Size.*\(([0-9.]+)/
|
35
|
-
device_mash[:size] = Regexp.last_match[1].to_f
|
36
|
-
when /State\s+: ([a-z]+)/
|
37
|
-
device_mash[:state] = Regexp.last_match[1]
|
38
|
-
when /UUID\s+: ([0-9a-z:]+)/
|
39
|
-
device_mash[:UUID] = Regexp.last_match[1]
|
40
|
-
when /Total Devices\s+: ([0-9]+)/
|
41
|
-
device_mash[:device_counts][:total] = Regexp.last_match[1].to_i
|
42
|
-
when /Raid Devices\s+: ([0-9]+)/
|
43
|
-
device_mash[:device_counts][:raid] = Regexp.last_match[1].to_i
|
44
|
-
when /Working Devices\s+: ([0-9]+)/
|
45
|
-
device_mash[:device_counts][:working] = Regexp.last_match[1].to_i
|
46
|
-
when /Failed Devices\s+: ([0-9]+)/
|
47
|
-
device_mash[:device_counts][:failed] = Regexp.last_match[1].to_i
|
48
|
-
when /Active Devices\s+: ([0-9]+)/
|
49
|
-
device_mash[:device_counts][:active] = Regexp.last_match[1].to_i
|
50
|
-
when /Spare Devices\s+: ([0-9]+)/
|
51
|
-
device_mash[:device_counts][:spare] = Regexp.last_match[1].to_i
|
52
|
-
end
|
53
|
-
end
|
54
|
-
device_mash
|
55
|
-
end
|
56
|
-
|
57
|
-
collect_data(:linux) do
|
58
|
-
# gather a list of all raid arrays
|
59
|
-
if file_exist?("/proc/mdstat")
|
60
|
-
devices = {}
|
61
|
-
file_open("/proc/mdstat").each do |line|
|
62
|
-
if line =~ /(md[0-9]+)/
|
63
|
-
device = Regexp.last_match[1]
|
64
|
-
pieces = line.split(/\s+/)
|
65
|
-
# there are variable numbers of fields until you hit the raid level
|
66
|
-
# everything after that is members...
|
67
|
-
# unless the array is inactive, in which case you don't get a raid
|
68
|
-
# level.
|
69
|
-
members = pieces.drop_while { |x| !x.start_with?("raid", "inactive") }
|
70
|
-
# and drop that too
|
71
|
-
members.shift unless members.empty?
|
72
|
-
devices[device] = {
|
73
|
-
"active" => [],
|
74
|
-
"spare" => [],
|
75
|
-
"journal" => nil,
|
76
|
-
}
|
77
|
-
members.each do |member|
|
78
|
-
# We want to match the device, and optionally the type
|
79
|
-
# most entries will look like:
|
80
|
-
# sdc1[5]
|
81
|
-
# but some will look like:
|
82
|
-
# sdc1[5](J)
|
83
|
-
# where the format is:
|
84
|
-
# <device>[<number in array>](<type>)
|
85
|
-
# Type can be things like "J" for a journal device, or "S" for
|
86
|
-
# a spare device.
|
87
|
-
m = member.match(/(.+)\[\d+\](?:\((\w)\))?/)
|
88
|
-
member_device = m[1]
|
89
|
-
member_type = m[2]
|
90
|
-
case member_type
|
91
|
-
when "J"
|
92
|
-
devices[device]["journal"] = member_device
|
93
|
-
when "S"
|
94
|
-
devices[device]["spare"] << member_device
|
95
|
-
else
|
96
|
-
devices[device]["active"] << member_device
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
# create the mdadm mash and gather individual information if devices are present
|
103
|
-
unless devices.empty?
|
104
|
-
mdadm Mash.new
|
105
|
-
devices.keys.sort.each do |device|
|
106
|
-
mdadm[device] = Mash.new
|
107
|
-
|
108
|
-
# gather detailed information on the array
|
109
|
-
so = shell_out("mdadm --detail /dev/#{device}")
|
110
|
-
|
111
|
-
# if the mdadm command was successful pass so.stdout to create_raid_device_mash to grab the tidbits we want
|
112
|
-
mdadm[device] = create_raid_device_mash(so.stdout) if so.stdout
|
113
|
-
mdadm[device]["members"] = devices[device]["active"]
|
114
|
-
mdadm[device]["spares"] = devices[device]["spare"]
|
115
|
-
mdadm[device]["journal"] = devices[device]["journal"]
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Tim Smith <tsmith@limelight.com>
|
4
|
+
# Author:: Phil Dibowitz <phild@ipomc.com>
|
5
|
+
# Copyright:: Copyright (c) 2013-2014, Limelight Networks, Inc.
|
6
|
+
# Copyright:: Copyright (c) 2017 Facebook, Inc.
|
7
|
+
# Plugin:: mdadm
|
8
|
+
#
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
+
# you may not use this file except in compliance with the License.
|
11
|
+
# You may obtain a copy of the License at
|
12
|
+
#
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14
|
+
#
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
+
# See the License for the specific language governing permissions and
|
19
|
+
# limitations under the License.
|
20
|
+
#
|
21
|
+
|
22
|
+
Ohai.plugin(:Mdadm) do
|
23
|
+
provides "mdadm"
|
24
|
+
|
25
|
+
def create_raid_device_mash(stdout)
|
26
|
+
device_mash = Mash.new
|
27
|
+
device_mash[:device_counts] = Mash.new
|
28
|
+
stdout.lines.each do |line|
|
29
|
+
case line
|
30
|
+
when /Version\s+: ([0-9.]+)/
|
31
|
+
device_mash[:version] = Regexp.last_match[1].to_f
|
32
|
+
when /Raid Level\s+: raid([0-9]+)/
|
33
|
+
device_mash[:level] = Regexp.last_match[1].to_i
|
34
|
+
when /Array Size.*\(([0-9.]+)/
|
35
|
+
device_mash[:size] = Regexp.last_match[1].to_f
|
36
|
+
when /State\s+: ([a-z]+)/
|
37
|
+
device_mash[:state] = Regexp.last_match[1]
|
38
|
+
when /UUID\s+: ([0-9a-z:]+)/
|
39
|
+
device_mash[:UUID] = Regexp.last_match[1]
|
40
|
+
when /Total Devices\s+: ([0-9]+)/
|
41
|
+
device_mash[:device_counts][:total] = Regexp.last_match[1].to_i
|
42
|
+
when /Raid Devices\s+: ([0-9]+)/
|
43
|
+
device_mash[:device_counts][:raid] = Regexp.last_match[1].to_i
|
44
|
+
when /Working Devices\s+: ([0-9]+)/
|
45
|
+
device_mash[:device_counts][:working] = Regexp.last_match[1].to_i
|
46
|
+
when /Failed Devices\s+: ([0-9]+)/
|
47
|
+
device_mash[:device_counts][:failed] = Regexp.last_match[1].to_i
|
48
|
+
when /Active Devices\s+: ([0-9]+)/
|
49
|
+
device_mash[:device_counts][:active] = Regexp.last_match[1].to_i
|
50
|
+
when /Spare Devices\s+: ([0-9]+)/
|
51
|
+
device_mash[:device_counts][:spare] = Regexp.last_match[1].to_i
|
52
|
+
end
|
53
|
+
end
|
54
|
+
device_mash
|
55
|
+
end
|
56
|
+
|
57
|
+
collect_data(:linux) do
|
58
|
+
# gather a list of all raid arrays
|
59
|
+
if file_exist?("/proc/mdstat")
|
60
|
+
devices = {}
|
61
|
+
file_open("/proc/mdstat").each do |line|
|
62
|
+
if line =~ /(md[0-9]+)/
|
63
|
+
device = Regexp.last_match[1]
|
64
|
+
pieces = line.split(/\s+/)
|
65
|
+
# there are variable numbers of fields until you hit the raid level
|
66
|
+
# everything after that is members...
|
67
|
+
# unless the array is inactive, in which case you don't get a raid
|
68
|
+
# level.
|
69
|
+
members = pieces.drop_while { |x| !x.start_with?("raid", "inactive") }
|
70
|
+
# and drop that too
|
71
|
+
members.shift unless members.empty?
|
72
|
+
devices[device] = {
|
73
|
+
"active" => [],
|
74
|
+
"spare" => [],
|
75
|
+
"journal" => nil,
|
76
|
+
}
|
77
|
+
members.each do |member|
|
78
|
+
# We want to match the device, and optionally the type
|
79
|
+
# most entries will look like:
|
80
|
+
# sdc1[5]
|
81
|
+
# but some will look like:
|
82
|
+
# sdc1[5](J)
|
83
|
+
# where the format is:
|
84
|
+
# <device>[<number in array>](<type>)
|
85
|
+
# Type can be things like "J" for a journal device, or "S" for
|
86
|
+
# a spare device.
|
87
|
+
m = member.match(/(.+)\[\d+\](?:\((\w)\))?/)
|
88
|
+
member_device = m[1]
|
89
|
+
member_type = m[2]
|
90
|
+
case member_type
|
91
|
+
when "J"
|
92
|
+
devices[device]["journal"] = member_device
|
93
|
+
when "S"
|
94
|
+
devices[device]["spare"] << member_device
|
95
|
+
else
|
96
|
+
devices[device]["active"] << member_device
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# create the mdadm mash and gather individual information if devices are present
|
103
|
+
unless devices.empty?
|
104
|
+
mdadm Mash.new
|
105
|
+
devices.keys.sort.each do |device|
|
106
|
+
mdadm[device] = Mash.new
|
107
|
+
|
108
|
+
# gather detailed information on the array
|
109
|
+
so = shell_out("mdadm --detail /dev/#{device}")
|
110
|
+
|
111
|
+
# if the mdadm command was successful pass so.stdout to create_raid_device_mash to grab the tidbits we want
|
112
|
+
mdadm[device] = create_raid_device_mash(so.stdout) if so.stdout
|
113
|
+
mdadm[device]["members"] = devices[device]["active"]
|
114
|
+
mdadm[device]["spares"] = devices[device]["spare"]
|
115
|
+
mdadm[device]["journal"] = devices[device]["journal"]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -1,106 +1,106 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
# Author:: Adam Jacob (<adam@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
Ohai.plugin(:Memory) do
|
21
|
-
provides "memory", "memory/swap"
|
22
|
-
|
23
|
-
collect_data(:linux) do
|
24
|
-
memory Mash.new
|
25
|
-
memory[:swap] = Mash.new
|
26
|
-
memory[:hugepages] = Mash.new
|
27
|
-
memory[:directmap] = Mash.new
|
28
|
-
|
29
|
-
file_open("/proc/meminfo").each do |line|
|
30
|
-
case line
|
31
|
-
when /^MemTotal:\s+(\d+) (.+)/
|
32
|
-
memory[:total] = "#{$1}#{$2}"
|
33
|
-
when /^MemFree:\s+(\d+) (.+)/
|
34
|
-
memory[:free] = "#{$1}#{$2}"
|
35
|
-
when /^MemAvailable:\s+(\d+) (.+)/
|
36
|
-
memory[:available] = "#{$1}#{$2}"
|
37
|
-
when /^Buffers:\s+(\d+) (.+)/
|
38
|
-
memory[:buffers] = "#{$1}#{$2}"
|
39
|
-
when /^Cached:\s+(\d+) (.+)/
|
40
|
-
memory[:cached] = "#{$1}#{$2}"
|
41
|
-
when /^Active:\s+(\d+) (.+)/
|
42
|
-
memory[:active] = "#{$1}#{$2}"
|
43
|
-
when /^Inactive:\s+(\d+) (.+)/
|
44
|
-
memory[:inactive] = "#{$1}#{$2}"
|
45
|
-
when /^HighTotal:\s+(\d+) (.+)/
|
46
|
-
memory[:high_total] = "#{$1}#{$2}"
|
47
|
-
when /^HighFree:\s+(\d+) (.+)/
|
48
|
-
memory[:high_free] = "#{$1}#{$2}"
|
49
|
-
when /^LowTotal:\s+(\d+) (.+)/
|
50
|
-
memory[:low_total] = "#{$1}#{$2}"
|
51
|
-
when /^LowFree:\s+(\d+) (.+)/
|
52
|
-
memory[:low_free] = "#{$1}#{$2}"
|
53
|
-
when /^Dirty:\s+(\d+) (.+)/
|
54
|
-
memory[:dirty] = "#{$1}#{$2}"
|
55
|
-
when /^Writeback:\s+(\d+) (.+)/
|
56
|
-
memory[:writeback] = "#{$1}#{$2}"
|
57
|
-
when /^AnonPages:\s+(\d+) (.+)/
|
58
|
-
memory[:anon_pages] = "#{$1}#{$2}"
|
59
|
-
when /^Mapped:\s+(\d+) (.+)/
|
60
|
-
memory[:mapped] = "#{$1}#{$2}"
|
61
|
-
when /^Slab:\s+(\d+) (.+)/
|
62
|
-
memory[:slab] = "#{$1}#{$2}"
|
63
|
-
when /^SReclaimable:\s+(\d+) (.+)/
|
64
|
-
memory[:slab_reclaimable] = "#{$1}#{$2}"
|
65
|
-
when /^SUnreclaim:\s+(\d+) (.+)/
|
66
|
-
memory[:slab_unreclaim] = "#{$1}#{$2}"
|
67
|
-
when /^PageTables:\s+(\d+) (.+)/
|
68
|
-
memory[:page_tables] = "#{$1}#{$2}"
|
69
|
-
when /^NFS_Unstable:\s+(\d+) (.+)/
|
70
|
-
memory[:nfs_unstable] = "#{$1}#{$2}"
|
71
|
-
when /^Bounce:\s+(\d+) (.+)/
|
72
|
-
memory[:bounce] = "#{$1}#{$2}"
|
73
|
-
when /^CommitLimit:\s+(\d+) (.+)/
|
74
|
-
memory[:commit_limit] = "#{$1}#{$2}"
|
75
|
-
when /^Committed_AS:\s+(\d+) (.+)/
|
76
|
-
memory[:committed_as] = "#{$1}#{$2}"
|
77
|
-
when /^VmallocTotal:\s+(\d+) (.+)/
|
78
|
-
memory[:vmalloc_total] = "#{$1}#{$2}"
|
79
|
-
when /^VmallocUsed:\s+(\d+) (.+)/
|
80
|
-
memory[:vmalloc_used] = "#{$1}#{$2}"
|
81
|
-
when /^VmallocChunk:\s+(\d+) (.+)/
|
82
|
-
memory[:vmalloc_chunk] = "#{$1}#{$2}"
|
83
|
-
when /^SwapCached:\s+(\d+) (.+)/
|
84
|
-
memory[:swap][:cached] = "#{$1}#{$2}"
|
85
|
-
when /^SwapTotal:\s+(\d+) (.+)/
|
86
|
-
memory[:swap][:total] = "#{$1}#{$2}"
|
87
|
-
when /^SwapFree:\s+(\d+) (.+)/
|
88
|
-
memory[:swap][:free] = "#{$1}#{$2}"
|
89
|
-
when /^HugePages_Total:\s+(\d+)/
|
90
|
-
memory[:hugepages][:total] = $1.to_s
|
91
|
-
when /^HugePages_Free:\s+(\d+)/
|
92
|
-
memory[:hugepages][:free] = $1.to_s
|
93
|
-
when /^HugePages_Rsvd:\s+(\d+)/
|
94
|
-
memory[:hugepages][:reserved] = $1.to_s
|
95
|
-
when /^HugePages_Surp:\s+(\d+)/
|
96
|
-
memory[:hugepages][:surplus] = $1.to_s
|
97
|
-
when /^Hugepagesize:\s+(\d+) (.+)/
|
98
|
-
memory[:hugepage_size] = "#{$1}#{$2}"
|
99
|
-
when /^Hugetlb:\s+(\d+) (.+)/
|
100
|
-
memory[:hugetlb] = "#{$1}#{$2}"
|
101
|
-
when /^DirectMap([0-9]+[a-zA-Z]):\s+(\d+) (.+)/
|
102
|
-
memory[:directmap][$1.to_sym] = "#{$2}#{$3}"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Adam Jacob (<adam@chef.io>)
|
4
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
Ohai.plugin(:Memory) do
|
21
|
+
provides "memory", "memory/swap"
|
22
|
+
|
23
|
+
collect_data(:linux) do
|
24
|
+
memory Mash.new
|
25
|
+
memory[:swap] = Mash.new
|
26
|
+
memory[:hugepages] = Mash.new
|
27
|
+
memory[:directmap] = Mash.new
|
28
|
+
|
29
|
+
file_open("/proc/meminfo").each do |line|
|
30
|
+
case line
|
31
|
+
when /^MemTotal:\s+(\d+) (.+)/
|
32
|
+
memory[:total] = "#{$1}#{$2}"
|
33
|
+
when /^MemFree:\s+(\d+) (.+)/
|
34
|
+
memory[:free] = "#{$1}#{$2}"
|
35
|
+
when /^MemAvailable:\s+(\d+) (.+)/
|
36
|
+
memory[:available] = "#{$1}#{$2}"
|
37
|
+
when /^Buffers:\s+(\d+) (.+)/
|
38
|
+
memory[:buffers] = "#{$1}#{$2}"
|
39
|
+
when /^Cached:\s+(\d+) (.+)/
|
40
|
+
memory[:cached] = "#{$1}#{$2}"
|
41
|
+
when /^Active:\s+(\d+) (.+)/
|
42
|
+
memory[:active] = "#{$1}#{$2}"
|
43
|
+
when /^Inactive:\s+(\d+) (.+)/
|
44
|
+
memory[:inactive] = "#{$1}#{$2}"
|
45
|
+
when /^HighTotal:\s+(\d+) (.+)/
|
46
|
+
memory[:high_total] = "#{$1}#{$2}"
|
47
|
+
when /^HighFree:\s+(\d+) (.+)/
|
48
|
+
memory[:high_free] = "#{$1}#{$2}"
|
49
|
+
when /^LowTotal:\s+(\d+) (.+)/
|
50
|
+
memory[:low_total] = "#{$1}#{$2}"
|
51
|
+
when /^LowFree:\s+(\d+) (.+)/
|
52
|
+
memory[:low_free] = "#{$1}#{$2}"
|
53
|
+
when /^Dirty:\s+(\d+) (.+)/
|
54
|
+
memory[:dirty] = "#{$1}#{$2}"
|
55
|
+
when /^Writeback:\s+(\d+) (.+)/
|
56
|
+
memory[:writeback] = "#{$1}#{$2}"
|
57
|
+
when /^AnonPages:\s+(\d+) (.+)/
|
58
|
+
memory[:anon_pages] = "#{$1}#{$2}"
|
59
|
+
when /^Mapped:\s+(\d+) (.+)/
|
60
|
+
memory[:mapped] = "#{$1}#{$2}"
|
61
|
+
when /^Slab:\s+(\d+) (.+)/
|
62
|
+
memory[:slab] = "#{$1}#{$2}"
|
63
|
+
when /^SReclaimable:\s+(\d+) (.+)/
|
64
|
+
memory[:slab_reclaimable] = "#{$1}#{$2}"
|
65
|
+
when /^SUnreclaim:\s+(\d+) (.+)/
|
66
|
+
memory[:slab_unreclaim] = "#{$1}#{$2}"
|
67
|
+
when /^PageTables:\s+(\d+) (.+)/
|
68
|
+
memory[:page_tables] = "#{$1}#{$2}"
|
69
|
+
when /^NFS_Unstable:\s+(\d+) (.+)/
|
70
|
+
memory[:nfs_unstable] = "#{$1}#{$2}"
|
71
|
+
when /^Bounce:\s+(\d+) (.+)/
|
72
|
+
memory[:bounce] = "#{$1}#{$2}"
|
73
|
+
when /^CommitLimit:\s+(\d+) (.+)/
|
74
|
+
memory[:commit_limit] = "#{$1}#{$2}"
|
75
|
+
when /^Committed_AS:\s+(\d+) (.+)/
|
76
|
+
memory[:committed_as] = "#{$1}#{$2}"
|
77
|
+
when /^VmallocTotal:\s+(\d+) (.+)/
|
78
|
+
memory[:vmalloc_total] = "#{$1}#{$2}"
|
79
|
+
when /^VmallocUsed:\s+(\d+) (.+)/
|
80
|
+
memory[:vmalloc_used] = "#{$1}#{$2}"
|
81
|
+
when /^VmallocChunk:\s+(\d+) (.+)/
|
82
|
+
memory[:vmalloc_chunk] = "#{$1}#{$2}"
|
83
|
+
when /^SwapCached:\s+(\d+) (.+)/
|
84
|
+
memory[:swap][:cached] = "#{$1}#{$2}"
|
85
|
+
when /^SwapTotal:\s+(\d+) (.+)/
|
86
|
+
memory[:swap][:total] = "#{$1}#{$2}"
|
87
|
+
when /^SwapFree:\s+(\d+) (.+)/
|
88
|
+
memory[:swap][:free] = "#{$1}#{$2}"
|
89
|
+
when /^HugePages_Total:\s+(\d+)/
|
90
|
+
memory[:hugepages][:total] = $1.to_s
|
91
|
+
when /^HugePages_Free:\s+(\d+)/
|
92
|
+
memory[:hugepages][:free] = $1.to_s
|
93
|
+
when /^HugePages_Rsvd:\s+(\d+)/
|
94
|
+
memory[:hugepages][:reserved] = $1.to_s
|
95
|
+
when /^HugePages_Surp:\s+(\d+)/
|
96
|
+
memory[:hugepages][:surplus] = $1.to_s
|
97
|
+
when /^Hugepagesize:\s+(\d+) (.+)/
|
98
|
+
memory[:hugepage_size] = "#{$1}#{$2}"
|
99
|
+
when /^Hugetlb:\s+(\d+) (.+)/
|
100
|
+
memory[:hugetlb] = "#{$1}#{$2}"
|
101
|
+
when /^DirectMap([0-9]+[a-zA-Z]):\s+(\d+) (.+)/
|
102
|
+
memory[:directmap][$1.to_sym] = "#{$2}#{$3}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|