ohai 14.5.4 → 14.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ohai/application.rb +19 -0
- data/lib/ohai/exception.rb +1 -0
- data/lib/ohai/hints.rb +5 -0
- data/lib/ohai/log.rb +2 -0
- data/lib/ohai/plugins/cpu.rb +416 -0
- data/lib/ohai/plugins/darwin/hardware.rb +1 -7
- data/lib/ohai/plugins/darwin/system_profiler.rb +19 -19
- data/lib/ohai/plugins/filesystem.rb +326 -115
- data/lib/ohai/plugins/linux/platform.rb +1 -1
- data/lib/ohai/plugins/os.rb +16 -0
- data/lib/ohai/system.rb +12 -2
- data/lib/ohai/version.rb +1 -1
- data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
- data/spec/unit/plugins/aix/filesystem_spec.rb +23 -1
- data/spec/unit/plugins/darwin/cpu_spec.rb +3 -3
- data/spec/unit/plugins/freebsd/cpu_spec.rb +2 -2
- data/spec/unit/plugins/linux/cpu_spec.rb +3 -3
- data/spec/unit/plugins/linux/platform_spec.rb +2 -1
- data/spec/unit/plugins/os_spec.rb +33 -0
- data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
- data/spec/unit/plugins/solaris2/filesystem.rb +355 -32
- data/spec/unit/plugins/windows/cpu_spec.rb +1 -1
- metadata +3 -18
- data/lib/ohai/plugins/aix/cpu.rb +0 -64
- data/lib/ohai/plugins/aix/filesystem.rb +0 -90
- data/lib/ohai/plugins/aix/os.rb +0 -30
- data/lib/ohai/plugins/darwin/cpu.rb +0 -50
- data/lib/ohai/plugins/dragonflybsd/cpu.rb +0 -58
- data/lib/ohai/plugins/dragonflybsd/os.rb +0 -31
- data/lib/ohai/plugins/freebsd/cpu.rb +0 -70
- data/lib/ohai/plugins/freebsd/os.rb +0 -32
- data/lib/ohai/plugins/linux/cpu.rb +0 -120
- data/lib/ohai/plugins/netbsd/cpu.rb +0 -50
- data/lib/ohai/plugins/openbsd/cpu.rb +0 -43
- data/lib/ohai/plugins/solaris2/cpu.rb +0 -70
- data/lib/ohai/plugins/solaris2/filesystem.rb +0 -106
- data/lib/ohai/plugins/windows/cpu.rb +0 -59
- data/spec/unit/plugins/aix/os_spec.rb +0 -35
- data/spec/unit/plugins/freebsd/os_spec.rb +0 -32
@@ -34,13 +34,7 @@ Ohai.plugin(:Hardware) do
|
|
34
34
|
next
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
require "plist"
|
39
|
-
rescue LoadError => e
|
40
|
-
# In case the plist gem isn't present, skip this plugin.
|
41
|
-
logger.trace("Plugin Hardware: Can't load gem: #{e}. Cannot continue.")
|
42
|
-
next
|
43
|
-
end
|
37
|
+
require "plist"
|
44
38
|
|
45
39
|
hw_hash = system_profiler("SPHardwareDataType")
|
46
40
|
hw_hash[0]["_items"][0].delete("_name")
|
@@ -20,13 +20,12 @@ Ohai.plugin(:SystemProfile) do
|
|
20
20
|
provides "system_profile"
|
21
21
|
|
22
22
|
collect_data(:darwin) do
|
23
|
-
|
24
|
-
require "plist"
|
23
|
+
require "plist"
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
system_profile Array.new
|
26
|
+
items = Array.new
|
27
|
+
detail_level = {
|
28
|
+
"mini" => %w{
|
30
29
|
SPParallelATAData
|
31
30
|
SPAudioData
|
32
31
|
SPBluetoothData
|
@@ -52,21 +51,22 @@ SPThunderboltData
|
|
52
51
|
SPUSBData
|
53
52
|
SPWWANData
|
54
53
|
SPAirPortData},
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
54
|
+
"full" => [
|
55
|
+
"SPHardwareDataType",
|
56
|
+
],
|
57
|
+
}
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
detail_level.each do |level, data_types|
|
60
|
+
so = shell_out("system_profiler -xml -detailLevel #{level} #{data_types.join(' ')}")
|
61
|
+
Plist.parse_xml(so.stdout).each do |e|
|
62
|
+
# delete some bogus timing data and then keep the rest
|
63
|
+
e.delete("_SPCompletionInterval")
|
64
|
+
e.delete("_SPResponseTime")
|
65
|
+
e.delete("_SPCommandLineArguments")
|
66
|
+
items << e
|
65
67
|
end
|
66
|
-
|
67
|
-
system_profile ( items.sort_by { |h| h["_dataType"] } ) # rubocop: disable Lint/ParenthesesAsGroupedExpression
|
68
|
-
rescue LoadError => e
|
69
|
-
logger.trace("Can't load gem: #{e})")
|
70
68
|
end
|
69
|
+
|
70
|
+
system_profile ( items.sort_by { |h| h["_dataType"] } ) # rubocop: disable Lint/ParenthesesAsGroupedExpression
|
71
71
|
end
|
72
72
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Phil Dibowitz <phil@ipom.com>
|
3
3
|
# Author:: Adam Jacob <adam@chef.io>
|
4
|
+
# Author:: Kurt Yoder (ktyopscode@yoderhome.com)
|
5
|
+
# Author:: Deepali Jagtap (<deepali.jagtap@clogeny.com>)
|
6
|
+
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
7
|
+
# Author:: Isa Farnik (<isa@chef.io>)
|
8
|
+
# Author:: James Gartrell (<jgartrel@gmail.com>)
|
4
9
|
# Copyright:: Copyright (c) 2008-2017 Chef Software, Inc.
|
5
10
|
# Copyright:: Copyright (c) 2015 Facebook, Inc.
|
6
11
|
# License:: Apache License, Version 2.0
|
@@ -99,27 +104,58 @@ Ohai.plugin(:Filesystem) do
|
|
99
104
|
view
|
100
105
|
end
|
101
106
|
|
107
|
+
def generate_deprecated_solaris_view(fs, old_zfs)
|
108
|
+
view = generate_deprecated_view(fs)
|
109
|
+
old_zfs.each do |fsname, attributes|
|
110
|
+
view[fsname] ||= Mash.new
|
111
|
+
view[fsname][:fs_type] = "zfs"
|
112
|
+
view[fsname][:mount] = attributes[:values][:mountpoint] if attributes[:values].key?("mountpoint")
|
113
|
+
view[fsname][:device] = fsname
|
114
|
+
view[fsname][:zfs_values] = attributes[:values]
|
115
|
+
view[fsname][:zfs_sources] = attributes[:sources]
|
116
|
+
# parents will already be here
|
117
|
+
# but we want to nuke "zfs_properties"
|
118
|
+
view[fsname].delete("zfs_properties")
|
119
|
+
end
|
120
|
+
view
|
121
|
+
end
|
122
|
+
|
123
|
+
def parse_common_df(out)
|
124
|
+
fs = {}
|
125
|
+
out.each_line do |line|
|
126
|
+
case line
|
127
|
+
when /^Filesystem\s+1024-blocks/
|
128
|
+
next
|
129
|
+
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
|
130
|
+
key = "#{$1},#{$6}"
|
131
|
+
fs[key] = Mash.new
|
132
|
+
fs[key][:device] = $1
|
133
|
+
fs[key][:kb_size] = $2
|
134
|
+
fs[key][:kb_used] = $3
|
135
|
+
fs[key][:kb_available] = $4
|
136
|
+
fs[key][:percent_used] = $5
|
137
|
+
fs[key][:mount] = $6
|
138
|
+
end
|
139
|
+
end
|
140
|
+
fs
|
141
|
+
end
|
142
|
+
|
143
|
+
def run_with_check(bin, &block)
|
144
|
+
yield
|
145
|
+
rescue Ohai::Exceptions::Exec => e
|
146
|
+
unless Ohai.config[:plugin][:filesystem][:allow_partial_data]
|
147
|
+
raise e
|
148
|
+
end
|
149
|
+
logger.warn("Plugin Filesystem: #{bin} binary is not available. Some data will not be available.")
|
150
|
+
end
|
151
|
+
|
102
152
|
collect_data(:linux) do
|
103
153
|
fs = Mash.new
|
104
154
|
|
105
155
|
# Grab filesystem data from df
|
106
|
-
|
156
|
+
run_with_check("df") do
|
107
157
|
so = shell_out("df -P")
|
108
|
-
so.stdout
|
109
|
-
case line
|
110
|
-
when /^Filesystem\s+1024-blocks/
|
111
|
-
next
|
112
|
-
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
|
113
|
-
key = "#{$1},#{$6}"
|
114
|
-
fs[key] = Mash.new
|
115
|
-
fs[key][:device] = $1
|
116
|
-
fs[key][:kb_size] = $2
|
117
|
-
fs[key][:kb_used] = $3
|
118
|
-
fs[key][:kb_available] = $4
|
119
|
-
fs[key][:percent_used] = $5
|
120
|
-
fs[key][:mount] = $6
|
121
|
-
end
|
122
|
-
end
|
158
|
+
fs.merge!(parse_common_df(so.stdout))
|
123
159
|
|
124
160
|
# Grab filesystem inode data from df
|
125
161
|
so = shell_out("df -iP")
|
@@ -138,15 +174,10 @@ Ohai.plugin(:Filesystem) do
|
|
138
174
|
fs[key][:mount] = $6
|
139
175
|
end
|
140
176
|
end
|
141
|
-
rescue Ohai::Exceptions::Exec => e
|
142
|
-
unless Ohai.config[:plugin][:filesystem][:allow_partial_data]
|
143
|
-
raise e
|
144
|
-
end
|
145
|
-
logger.warn("Plugin Filesystem: df binary is not available. Some data will not be available.")
|
146
177
|
end
|
147
178
|
|
148
179
|
# Grab mount information from /bin/mount
|
149
|
-
|
180
|
+
run_with_check("mount") do
|
150
181
|
so = shell_out("mount")
|
151
182
|
so.stdout.each_line do |line|
|
152
183
|
if line =~ /^(.+?) on (.+?) type (.+?) \((.+?)\)$/
|
@@ -158,11 +189,6 @@ Ohai.plugin(:Filesystem) do
|
|
158
189
|
fs[key][:mount_options] = $4.split(",")
|
159
190
|
end
|
160
191
|
end
|
161
|
-
rescue Ohai::Exceptions::Exec
|
162
|
-
unless Ohai.config[:plugin][:filesystem][:allow_partial_data]
|
163
|
-
raise e
|
164
|
-
end
|
165
|
-
logger.warn("Plugin Filesystem: mount binary is not available. Some data will not be available.")
|
166
192
|
end
|
167
193
|
|
168
194
|
# We used to try to decide if we wanted to run lsblk or blkid
|
@@ -187,28 +213,30 @@ Ohai.plugin(:Filesystem) do
|
|
187
213
|
# setting the timeout here for `lsblk` and `blkid` commands to 60
|
188
214
|
# this is to allow machines with large amounts of attached LUNs
|
189
215
|
# to respond back to the command successfully
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
216
|
+
run_with_check(cmdtype) do
|
217
|
+
so = shell_out(cmd, timeout: 60)
|
218
|
+
so.stdout.each_line do |line|
|
219
|
+
parsed = parse_line(line, cmdtype)
|
220
|
+
next if parsed.nil?
|
221
|
+
# lsblk lists each device once, so we need to update all entries
|
222
|
+
# in the hash that are related to this device
|
223
|
+
keys_to_update = []
|
224
|
+
fs.each_key do |key|
|
225
|
+
keys_to_update << key if key.start_with?("#{parsed[:dev]},")
|
226
|
+
end
|
200
227
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
228
|
+
if keys_to_update.empty?
|
229
|
+
key = "#{parsed[:dev]},"
|
230
|
+
fs[key] = Mash.new
|
231
|
+
fs[key][:device] = parsed[:dev]
|
232
|
+
keys_to_update << key
|
233
|
+
end
|
207
234
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
235
|
+
keys_to_update.each do |k|
|
236
|
+
[:fs_type, :uuid, :label].each do |subkey|
|
237
|
+
if parsed[subkey] && !parsed[subkey].empty?
|
238
|
+
fs[k][subkey] = parsed[subkey]
|
239
|
+
end
|
212
240
|
end
|
213
241
|
end
|
214
242
|
end
|
@@ -264,51 +292,40 @@ Ohai.plugin(:Filesystem) do
|
|
264
292
|
fs = Mash.new
|
265
293
|
|
266
294
|
# Grab filesystem data from df
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
when /^Filesystem/
|
271
|
-
next
|
272
|
-
when /^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(\S+)$/
|
273
|
-
key = "#{$1},#{$6}"
|
274
|
-
fs[key] = Mash.new
|
275
|
-
fs[key][:device] = $1
|
276
|
-
fs[key][:kb_size] = $2
|
277
|
-
fs[key][:kb_used] = $3
|
278
|
-
fs[key][:kb_available] = $4
|
279
|
-
fs[key][:percent_used] = $5
|
280
|
-
fs[key][:mount] = $6
|
281
|
-
end
|
282
|
-
end
|
295
|
+
run_with_check("df") do
|
296
|
+
so = shell_out("df")
|
297
|
+
fs.merge!(parse_common_df(so.stdout))
|
283
298
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
+
so = shell_out("df -iP")
|
300
|
+
so.stdout.lines do |line|
|
301
|
+
case line
|
302
|
+
when /^Filesystem/ # skip the header
|
303
|
+
next
|
304
|
+
when /^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+(\d+)\s+(\d+)\s+(\d+)%\s+(\S+)$/
|
305
|
+
key = "#{$1},#{$9}"
|
306
|
+
fs[key] ||= Mash.new
|
307
|
+
fs[key][:device] = $1
|
308
|
+
fs[key][:inodes_used] = $6
|
309
|
+
fs[key][:inodes_available] = $7
|
310
|
+
fs[key][:total_inodes] = ($6.to_i + $7.to_i).to_s
|
311
|
+
fs[key][:inodes_percent_used] = $8
|
312
|
+
fs[key][:mount] = $9
|
313
|
+
end
|
299
314
|
end
|
300
315
|
end
|
301
316
|
|
302
317
|
# Grab mount information from mount
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
318
|
+
run_with_check("mount") do
|
319
|
+
so = shell_out("mount -l")
|
320
|
+
so.stdout.lines do |line|
|
321
|
+
if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
|
322
|
+
key = "#{$1},#{$2}"
|
323
|
+
fs[key] ||= Mash.new
|
324
|
+
fs[key][:device] = $1
|
325
|
+
fs[key][:mount] = $2
|
326
|
+
fs[key][:fs_type] = $3
|
327
|
+
fs[key][:mount_options] = $4.split(/,\s*/)
|
328
|
+
end
|
312
329
|
end
|
313
330
|
end
|
314
331
|
|
@@ -333,37 +350,41 @@ Ohai.plugin(:Filesystem) do
|
|
333
350
|
block_size = 0
|
334
351
|
# on new versions of OSX, -i is default, on old versions it's not, so
|
335
352
|
# specifying it gets consistent output
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
353
|
+
run_with_check("df") do
|
354
|
+
so = shell_out("df -i")
|
355
|
+
so.stdout.each_line do |line|
|
356
|
+
case line
|
357
|
+
when /^Filesystem\s+(\d+)-/
|
358
|
+
block_size = $1.to_i
|
359
|
+
next
|
360
|
+
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(\d+)\s+(\d+)\s+(\d+%)\s+(.+)$/
|
361
|
+
key = "#{$1},#{$9}"
|
362
|
+
fs[key] = Mash.new
|
363
|
+
fs[key][:block_size] = block_size
|
364
|
+
fs[key][:device] = $1
|
365
|
+
fs[key][:kb_size] = ($2.to_i / (1024 / block_size)).to_s
|
366
|
+
fs[key][:kb_used] = ($3.to_i / (1024 / block_size)).to_s
|
367
|
+
fs[key][:kb_available] = ($4.to_i / (1024 / block_size)).to_s
|
368
|
+
fs[key][:percent_used] = $5
|
369
|
+
fs[key][:inodes_used] = $6
|
370
|
+
fs[key][:inodes_available] = $7
|
371
|
+
fs[key][:total_inodes] = ($6.to_i + $7.to_i).to_s
|
372
|
+
fs[key][:inodes_percent_used] = $8
|
373
|
+
fs[key][:mount] = $9
|
374
|
+
end
|
356
375
|
end
|
357
376
|
end
|
358
377
|
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
378
|
+
run_with_check("mount") do
|
379
|
+
so = shell_out("mount")
|
380
|
+
so.stdout.lines do |line|
|
381
|
+
if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
|
382
|
+
key = "#{$1},#{$2}"
|
383
|
+
fs[key] = Mash.new unless fs.key?(key)
|
384
|
+
fs[key][:mount] = $2
|
385
|
+
fs[key][:fs_type] = $3
|
386
|
+
fs[key][:mount_options] = $4.split(/,\s*/)
|
387
|
+
end
|
367
388
|
end
|
368
389
|
end
|
369
390
|
|
@@ -378,4 +399,194 @@ Ohai.plugin(:Filesystem) do
|
|
378
399
|
|
379
400
|
filesystem fs_data
|
380
401
|
end
|
402
|
+
|
403
|
+
collect_data(:solaris2) do
|
404
|
+
fs = Mash.new
|
405
|
+
|
406
|
+
# Grab filesystem data from df
|
407
|
+
run_with_check("df") do
|
408
|
+
so = shell_out("df -Pka")
|
409
|
+
fs.merge!(parse_common_df(so.stdout))
|
410
|
+
|
411
|
+
# Grab file system type from df (must be done separately)
|
412
|
+
so = shell_out("df -na")
|
413
|
+
so.stdout.lines do |line|
|
414
|
+
next unless line =~ /^(.+?)\s*: (\S+)\s*$/
|
415
|
+
mount = $1
|
416
|
+
fs.each do |key, fs_attributes|
|
417
|
+
next unless fs_attributes[:mount] == mount
|
418
|
+
fs[key][:fs_type] = $2
|
419
|
+
end
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
# Grab mount information from /bin/mount
|
424
|
+
run_with_check("mount") do
|
425
|
+
so = shell_out("mount")
|
426
|
+
so.stdout.lines do |line|
|
427
|
+
next unless line =~ /^(.+?) on (.+?) (.+?) on (.+?)$/
|
428
|
+
key = "#{$2},#{$1}"
|
429
|
+
fs[key] = Mash.new unless fs.key?(key)
|
430
|
+
fs[key][:mount] = $1
|
431
|
+
fs[key][:mount_time] = $4 # $4 must come before "split", else it becomes nil
|
432
|
+
fs[key][:mount_options] = $3.split("/")
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
# Grab any zfs data from "zfs get"
|
437
|
+
zfs = Mash.new
|
438
|
+
old_zfs = Mash.new
|
439
|
+
zfs_get = "zfs get -p -H all"
|
440
|
+
run_with_check("zfs") do
|
441
|
+
so = shell_out(zfs_get)
|
442
|
+
so.stdout.lines do |line|
|
443
|
+
next unless line =~ /^([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)$/
|
444
|
+
filesystem = $1
|
445
|
+
property = $2
|
446
|
+
value = $3
|
447
|
+
source = $4.chomp
|
448
|
+
zfs[filesystem] ||= Mash.new
|
449
|
+
# if this fs doesn't exist, put in the bare minimum
|
450
|
+
zfs[filesystem][property] = {
|
451
|
+
value: value,
|
452
|
+
source: source,
|
453
|
+
}
|
454
|
+
# needed for old v1 view
|
455
|
+
old_zfs[filesystem] ||= Mash.new
|
456
|
+
old_zfs[filesystem][:values] ||= Mash.new
|
457
|
+
old_zfs[filesystem][:sources] ||= Mash.new
|
458
|
+
old_zfs[filesystem][:values][property] = value
|
459
|
+
old_zfs[filesystem][:values][property] = value
|
460
|
+
old_zfs[filesystem][:sources][property] = source
|
461
|
+
end
|
462
|
+
end
|
463
|
+
|
464
|
+
zfs.each do |fsname, attributes|
|
465
|
+
mountpoint = attributes[:mountpoint][:value] if attributes[:mountpoint]
|
466
|
+
key = "#{fsname},#{mountpoint}"
|
467
|
+
fs[key] ||= Mash.new
|
468
|
+
fs[key][:fs_type] = "zfs"
|
469
|
+
fs[key][:mount] = mountpoint if mountpoint
|
470
|
+
fs[key][:device] = fsname
|
471
|
+
fs[key][:zfs_properties] = attributes
|
472
|
+
# find all zfs parents
|
473
|
+
parents = fsname.split("/")
|
474
|
+
zfs_parents = []
|
475
|
+
(0..parents.length - 1).to_a.each do |parent_index|
|
476
|
+
next_parent = parents[0..parent_index].join("/")
|
477
|
+
zfs_parents.push(next_parent)
|
478
|
+
end
|
479
|
+
zfs_parents.pop
|
480
|
+
fs[key][:zfs_parents] = zfs_parents
|
481
|
+
fs[key][:zfs_zpool] = (zfs_parents.length == 0)
|
482
|
+
end
|
483
|
+
|
484
|
+
# create views
|
485
|
+
by_pair = fs
|
486
|
+
by_device = generate_device_view(fs)
|
487
|
+
by_mountpoint = generate_mountpoint_view(fs)
|
488
|
+
|
489
|
+
fs_data = Mash.new
|
490
|
+
fs_data["by_device"] = by_device
|
491
|
+
fs_data["by_mountpoint"] = by_mountpoint
|
492
|
+
fs_data["by_pair"] = by_pair
|
493
|
+
|
494
|
+
# Set the filesystem data - Solaris didn't do the conversion when everyone
|
495
|
+
# else did, so 15 will have both be the new API and 16 will drop the old API
|
496
|
+
filesystem generate_deprecated_solaris_view(fs, old_zfs)
|
497
|
+
filesystem2 fs_data
|
498
|
+
end
|
499
|
+
|
500
|
+
collect_data(:aix) do
|
501
|
+
def parse_df_or_mount(shell_out)
|
502
|
+
oldie = Mash.new
|
503
|
+
|
504
|
+
shell_out.lines.each do |line|
|
505
|
+
fields = line.split
|
506
|
+
case line
|
507
|
+
# headers and horizontal rules to skip
|
508
|
+
when /^\s*(node|---|^Filesystem\s+1024-blocks)/
|
509
|
+
next
|
510
|
+
# strictly a df entry
|
511
|
+
when /^(.+?)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+)\s+([0-9-]+\%*)\s+(.+)$/
|
512
|
+
if $1 == "Global"
|
513
|
+
dev = "#{$1}:#{$6}"
|
514
|
+
else
|
515
|
+
dev = $1
|
516
|
+
end
|
517
|
+
mountpoint = $6
|
518
|
+
key = "#{dev},#{mountpoint}"
|
519
|
+
oldie[key] ||= Mash.new
|
520
|
+
oldie[key][:kb_size] = $2
|
521
|
+
oldie[key][:kb_used] = $3
|
522
|
+
oldie[key][:kb_available] = $4
|
523
|
+
oldie[key][:percent_used] = $5
|
524
|
+
oldie[key][:mount] = mountpoint
|
525
|
+
oldie[key][:device] = dev
|
526
|
+
# an entry starting with 'G' or / (E.G. /tmp or /var)
|
527
|
+
when /^\s*(G.*?|\/\w)/
|
528
|
+
if fields[0] == "Global"
|
529
|
+
dev = fields[0] + ":" + fields[1]
|
530
|
+
else
|
531
|
+
dev = fields[0]
|
532
|
+
end
|
533
|
+
mountpoint = fields[1]
|
534
|
+
key = "#{dev},#{mountpoint}"
|
535
|
+
oldie[key] ||= Mash.new
|
536
|
+
oldie[key][:mount] = mountpoint
|
537
|
+
oldie[key][:fs_type] = fields[2]
|
538
|
+
oldie[key][:mount_options] = fields[6].split(",")
|
539
|
+
oldie[key][:device] = dev
|
540
|
+
# entries occupying the 'Node' column parsed here
|
541
|
+
else
|
542
|
+
dev = fields[0] + ":" + fields[1]
|
543
|
+
mountpoint = fields[2]
|
544
|
+
key = "#{dev},#{mountpoint}"
|
545
|
+
oldie[key] ||= Mash.new
|
546
|
+
oldie[key][:mount] = mountpoint
|
547
|
+
oldie[key][:device] = dev
|
548
|
+
oldie[key][:fs_type] = fields[3]
|
549
|
+
oldie[key][:mount_options] = fields[7].split(",")
|
550
|
+
end
|
551
|
+
end
|
552
|
+
oldie
|
553
|
+
end
|
554
|
+
|
555
|
+
def collect_old_version(shell_outs)
|
556
|
+
mount_hash = parse_df_or_mount shell_outs[:mount]
|
557
|
+
df_hash = parse_df_or_mount shell_outs[:df_Pk]
|
558
|
+
|
559
|
+
mount_hash.each do |key, hash|
|
560
|
+
df_hash[key].merge!(hash) if df_hash.key?(key)
|
561
|
+
end
|
562
|
+
|
563
|
+
mount_hash.merge(df_hash)
|
564
|
+
end
|
565
|
+
|
566
|
+
# Cache the command output
|
567
|
+
shell_outs = Mash.new
|
568
|
+
|
569
|
+
run_with_check("mount") do
|
570
|
+
shell_outs[:mount] = shell_out("mount").stdout
|
571
|
+
end
|
572
|
+
|
573
|
+
run_with_check("df") do
|
574
|
+
shell_outs[:df_Pk] = shell_out("df -Pk").stdout
|
575
|
+
end
|
576
|
+
|
577
|
+
fs = collect_old_version(shell_outs)
|
578
|
+
by_pair = fs
|
579
|
+
by_device = generate_device_view(fs)
|
580
|
+
by_mountpoint = generate_mountpoint_view(fs)
|
581
|
+
|
582
|
+
fs_data = Mash.new
|
583
|
+
fs_data["by_device"] = by_device
|
584
|
+
fs_data["by_mountpoint"] = by_mountpoint
|
585
|
+
fs_data["by_pair"] = by_pair
|
586
|
+
|
587
|
+
# Set the filesystem data - AIX didn't do the conversion when everyone
|
588
|
+
# else did, so 15 will have both be the new API and 16 will drop the old API
|
589
|
+
filesystem generate_deprecated_view(fs)
|
590
|
+
filesystem2 fs_data
|
591
|
+
end
|
381
592
|
end
|