ohai 14.1.0 → 14.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7aaa80eca02eed6b1bf25be0dab653f121320347693d75453dd3591306050aca
4
- data.tar.gz: 62b76f41b745726f29d6a13c8dd5159ee2cd45a3b4742fe5fa64745dc8825a31
3
+ metadata.gz: 2294a9254a6c0e4b3246ca4140573989896111b5abc5359219025753aa613219
4
+ data.tar.gz: 100a7f711cb042d2773f013e01f3219d7d52cfff97889585b8e9b4f0f591786a
5
5
  SHA512:
6
- metadata.gz: 678928cc6387c5613a03c63b1df7c2639a96991c850485096c0162a138cf56285a69eb9c4f4e2fce9d8bab48c8feadef741e2e7cf53b84e4cc980f6a7286a4ee
7
- data.tar.gz: 633ba5a734a9e497593276781c53fb802096d2f1164c64896b78837615fb4f8ca9d7363b59029c06b28bf36bf92a472a84a2742d3890bbf6a23d6ad80f0c7e37
6
+ metadata.gz: 1fb35d4bcd12a53bf42bc59e704d2889f7c4023240c69c8d881616cdc792f8ab64d4686ec88ab8d0abb6eef29eb3628a76f66865d0f82d7f8b2028750603f205
7
+ data.tar.gz: 03fa1c1404d4f96f027d3c5c289ed22484ceac6cca2679e87acc1f867ff9a55b7197ea40ad0c98f054f2a1630ce00b313ccf03559d084027fd1cde31676b4e4b
@@ -90,6 +90,15 @@ Ohai.plugin(:Filesystem) do
90
90
  view
91
91
  end
92
92
 
93
+ def generate_deprecated_view(fs)
94
+ view = generate_device_view(fs)
95
+ view.each do |device, entry|
96
+ view[device][:mount] = entry[:mounts].first
97
+ view[device].delete(:mounts)
98
+ end
99
+ view
100
+ end
101
+
93
102
  collect_data(:linux) do
94
103
  fs = Mash.new
95
104
 
@@ -250,4 +259,123 @@ Ohai.plugin(:Filesystem) do
250
259
  # Set the filesystem data
251
260
  filesystem fs_data
252
261
  end
262
+
263
+ collect_data(:freebsd, :openbsd, :netbsd, :dragonflybsd) do
264
+ fs = Mash.new
265
+
266
+ # Grab filesystem data from df
267
+ so = shell_out("df")
268
+ so.stdout.lines do |line|
269
+ case line
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
283
+
284
+ # inode parsing from 'df -iP'
285
+ so = shell_out("df -iP")
286
+ so.stdout.lines do |line|
287
+ case line
288
+ when /^Filesystem/ # skip the header
289
+ next
290
+ when /^(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+(\d+)\s+(\d+)\s+(\d+)%\s+(\S+)$/
291
+ key = "#{$1},#{$9}"
292
+ fs[key] ||= Mash.new
293
+ fs[key][:device] = $1
294
+ fs[key][:inodes_used] = $6
295
+ fs[key][:inodes_available] = $7
296
+ fs[key][:total_inodes] = ($6.to_i + $7.to_i).to_s
297
+ fs[key][:inodes_percent_used] = $8
298
+ fs[key][:mount] = $9
299
+ end
300
+ end
301
+
302
+ # Grab mount information from mount
303
+ so = shell_out("mount -l")
304
+ so.stdout.lines do |line|
305
+ if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
306
+ key = "#{$1},#{$2}"
307
+ fs[key] ||= Mash.new
308
+ fs[key][:device] = $1
309
+ fs[key][:mount] = $2
310
+ fs[key][:fs_type] = $3
311
+ fs[key][:mount_options] = $4.split(/,\s*/)
312
+ end
313
+ end
314
+
315
+ # create views
316
+ by_pair = fs
317
+ by_device = generate_device_view(fs)
318
+ by_mountpoint = generate_mountpoint_view(fs)
319
+
320
+ fs_data = Mash.new
321
+ fs_data["by_device"] = by_device
322
+ fs_data["by_mountpoint"] = by_mountpoint
323
+ fs_data["by_pair"] = by_pair
324
+
325
+ # Set the filesystem data - BSD didn't do the conversion when everyone else
326
+ # did, so 15 will have both be the new API and 16 will drop the old API
327
+ filesystem generate_deprecated_view(fs)
328
+ filesystem2 fs_data
329
+ end
330
+
331
+ collect_data(:darwin) do
332
+ fs = Mash.new
333
+ block_size = 0
334
+ # on new versions of OSX, -i is default, on old versions it's not, so
335
+ # specifying it gets consistent output
336
+ so = shell_out("df -i")
337
+ so.stdout.each_line do |line|
338
+ case line
339
+ when /^Filesystem\s+(\d+)-/
340
+ block_size = $1.to_i
341
+ next
342
+ when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(\d+)\s+(\d+)\s+(\d+%)\s+(.+)$/
343
+ key = "#{$1},#{$9}"
344
+ fs[key] = Mash.new
345
+ fs[key][:block_size] = block_size
346
+ fs[key][:device] = $1
347
+ fs[key][:kb_size] = ($2.to_i / (1024 / block_size)).to_s
348
+ fs[key][:kb_used] = ($3.to_i / (1024 / block_size)).to_s
349
+ fs[key][:kb_available] = ($4.to_i / (1024 / block_size)).to_s
350
+ fs[key][:percent_used] = $5
351
+ fs[key][:inodes_used] = $6
352
+ fs[key][:inodes_available] = $7
353
+ fs[key][:total_inodes] = ($6.to_i + $7.to_i).to_s
354
+ fs[key][:inodes_percent_used] = $8
355
+ fs[key][:mount] = $9
356
+ end
357
+ end
358
+
359
+ so = shell_out("mount")
360
+ so.stdout.lines do |line|
361
+ if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
362
+ key = "#{$1},#{$2}"
363
+ fs[key] = Mash.new unless fs.has_key?(key)
364
+ fs[key][:mount] = $2
365
+ fs[key][:fs_type] = $3
366
+ fs[key][:mount_options] = $4.split(/,\s*/)
367
+ end
368
+ end
369
+
370
+ by_pair = fs
371
+ by_device = generate_device_view(fs)
372
+ by_mountpoint = generate_mountpoint_view(fs)
373
+
374
+ fs_data = Mash.new
375
+ fs_data["by_device"] = by_device
376
+ fs_data["by_mountpoint"] = by_mountpoint
377
+ fs_data["by_pair"] = by_pair
378
+
379
+ filesystem fs_data
380
+ end
253
381
  end
@@ -53,8 +53,8 @@ Ohai.plugin(:ShardSeed) do
53
53
  require "digest/md5"
54
54
  Digest::MD5
55
55
  when "sha256"
56
- require "digest/sha2"
57
- Digest::SHA256
56
+ require "openssl/digest"
57
+ OpenSSL::Digest::SHA256
58
58
  end
59
59
  end
60
60
 
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Ohai
20
20
  OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
21
- VERSION = "14.1.0"
21
+ VERSION = "14.1.2"
22
22
  end
@@ -20,7 +20,7 @@
20
20
  require_relative "../../../spec_helper.rb"
21
21
 
22
22
  describe Ohai::System, "BSD filesystem plugin" do
23
- let(:plugin) { get_plugin("bsd/filesystem") }
23
+ let(:plugin) { get_plugin("filesystem") }
24
24
  before(:each) do
25
25
  allow(plugin).to receive(:collect_os).and_return(:freebsd)
26
26
 
@@ -55,41 +55,49 @@ DFi
55
55
  it "should set kb_size to value from df" do
56
56
  plugin.run
57
57
  expect(plugin[:filesystem]["/dev/ada0p2"][:kb_size]).to eq("9637788")
58
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_size]).to eq("9637788")
58
59
  end
59
60
 
60
61
  it "should set kb_used to value from df" do
61
62
  plugin.run
62
63
  expect(plugin[:filesystem]["/dev/ada0p2"][:kb_used]).to eq("3313504")
64
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_used]).to eq("3313504")
63
65
  end
64
66
 
65
67
  it "should set kb_available to value from df" do
66
68
  plugin.run
67
69
  expect(plugin[:filesystem]["/dev/ada0p2"][:kb_available]).to eq("5553264")
70
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:kb_available]).to eq("5553264")
68
71
  end
69
72
 
70
73
  it "should set percent_used to value from df" do
71
74
  plugin.run
72
75
  expect(plugin[:filesystem]["/dev/ada0p2"][:percent_used]).to eq("37%")
76
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:percent_used]).to eq("37%")
73
77
  end
74
78
 
75
79
  it "should set mount to value from df" do
76
80
  plugin.run
77
81
  expect(plugin[:filesystem]["/dev/ada0p2"][:mount]).to eq("/")
82
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount]).to eq("/")
78
83
  end
79
84
 
80
85
  it "should set total_inodes to value from df -iP" do
81
86
  plugin.run
82
87
  expect(plugin[:filesystem]["/dev/ada0p2"][:total_inodes]).to eq("1043326")
88
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:total_inodes]).to eq("1043326")
83
89
  end
84
90
 
85
91
  it "should set inodes_used to value from df -iP" do
86
92
  plugin.run
87
93
  expect(plugin[:filesystem]["/dev/ada0p2"][:inodes_used]).to eq("252576")
94
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:inodes_used]).to eq("252576")
88
95
  end
89
96
 
90
97
  it "should set inodes_available to value from df -iP" do
91
98
  plugin.run
92
99
  expect(plugin[:filesystem]["/dev/ada0p2"][:inodes_available]).to eq("790750")
100
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:inodes_available]).to eq("790750")
93
101
  end
94
102
  end
95
103
 
@@ -110,16 +118,19 @@ MOUNT
110
118
  it "should set mount to value from mount" do
111
119
  plugin.run
112
120
  expect(plugin[:filesystem]["/dev/ada0p2"][:mount]).to eq("/")
121
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount]).to eq("/")
113
122
  end
114
123
 
115
124
  it "should set fs_type to value from mount" do
116
125
  plugin.run
117
126
  expect(plugin[:filesystem]["/dev/ada0p2"][:fs_type]).to eq("ufs")
127
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:fs_type]).to eq("ufs")
118
128
  end
119
129
 
120
130
  it "should set mount_options to an array of values from mount" do
121
131
  plugin.run
122
132
  expect(plugin[:filesystem]["/dev/ada0p2"][:mount_options]).to eq(["local", "journaled soft-updates"])
133
+ expect(plugin[:filesystem2]["by_pair"]["/dev/ada0p2,/"][:mount_options]).to eq(["local", "journaled soft-updates"])
123
134
  end
124
135
  end
125
136
 
@@ -19,7 +19,7 @@
19
19
  require_relative "../../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "darwin filesystem plugin" do
22
- let(:plugin) { get_plugin("darwin/filesystem") }
22
+ let(:plugin) { get_plugin("filesystem") }
23
23
  before(:each) do
24
24
  allow(plugin).to receive(:collect_os).and_return(:darwin)
25
25
 
@@ -19,7 +19,7 @@
19
19
  require_relative "../../../spec_helper.rb"
20
20
 
21
21
  describe Ohai::System, "Linux filesystem plugin" do
22
- let(:plugin) { get_plugin("linux/filesystem") }
22
+ let(:plugin) { get_plugin("filesystem") }
23
23
  before(:each) do
24
24
  allow(plugin).to receive(:collect_os).and_return(:linux)
25
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.1.0
4
+ version: 14.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-04 00:00:00.000000000 Z
11
+ date: 2018-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -226,14 +226,12 @@ files:
226
226
  - lib/ohai/plugins/aix/uptime.rb
227
227
  - lib/ohai/plugins/aix/virtualization.rb
228
228
  - lib/ohai/plugins/azure.rb
229
- - lib/ohai/plugins/bsd/filesystem.rb
230
229
  - lib/ohai/plugins/bsd/virtualization.rb
231
230
  - lib/ohai/plugins/c.rb
232
231
  - lib/ohai/plugins/chef.rb
233
232
  - lib/ohai/plugins/cloud.rb
234
233
  - lib/ohai/plugins/command.rb
235
234
  - lib/ohai/plugins/darwin/cpu.rb
236
- - lib/ohai/plugins/darwin/filesystem.rb
237
235
  - lib/ohai/plugins/darwin/hardware.rb
238
236
  - lib/ohai/plugins/darwin/memory.rb
239
237
  - lib/ohai/plugins/darwin/network.rb
@@ -252,6 +250,7 @@ files:
252
250
  - lib/ohai/plugins/elixir.rb
253
251
  - lib/ohai/plugins/erlang.rb
254
252
  - lib/ohai/plugins/eucalyptus.rb
253
+ - lib/ohai/plugins/filesystem.rb
255
254
  - lib/ohai/plugins/freebsd/cpu.rb
256
255
  - lib/ohai/plugins/freebsd/memory.rb
257
256
  - lib/ohai/plugins/freebsd/network.rb
@@ -272,7 +271,6 @@ files:
272
271
  - lib/ohai/plugins/linode.rb
273
272
  - lib/ohai/plugins/linux/block_device.rb
274
273
  - lib/ohai/plugins/linux/cpu.rb
275
- - lib/ohai/plugins/linux/filesystem.rb
276
274
  - lib/ohai/plugins/linux/fips.rb
277
275
  - lib/ohai/plugins/linux/hostnamectl.rb
278
276
  - lib/ohai/plugins/linux/lsb.rb
@@ -1,75 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Author:: Tim Smith (<tsmith@chef.io>)
4
- # Copyright:: Copyright (c) 2008-2016 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(:Filesystem) do
21
- provides "filesystem"
22
-
23
- collect_data(:freebsd, :openbsd, :netbsd, :dragonflybsd) do
24
- fs = Mash.new
25
-
26
- # Grab filesystem data from df
27
- so = shell_out("df")
28
- so.stdout.lines do |line|
29
- case line
30
- when /^Filesystem/
31
- next
32
- when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
33
- filesystem = $1
34
- fs[filesystem] = Mash.new
35
- fs[filesystem][:kb_size] = $2
36
- fs[filesystem][:kb_used] = $3
37
- fs[filesystem][:kb_available] = $4
38
- fs[filesystem][:percent_used] = $5
39
- fs[filesystem][:mount] = $6
40
- end
41
- end
42
-
43
- # inode parsing from 'df -iP'
44
- so = shell_out("df -iP")
45
- so.stdout.lines do |line|
46
- case line
47
- when /^Filesystem/ # skip the header
48
- next
49
- when /^(.+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\%\s+(\d+)\s+(\d+)\s+(\d+)%(.+)$/
50
- filesystem = $1.strip
51
- fs[filesystem] ||= Mash.new
52
- fs[filesystem][:inodes_used] = $6
53
- fs[filesystem][:inodes_available] = $7
54
- fs[filesystem][:total_inodes] = ($6.to_i + $7.to_i).to_s
55
- fs[filesystem][:inodes_percent_used] = $8
56
- fs[filesystem][:mount] = $9.strip
57
- end
58
- end
59
-
60
- # Grab mount information from mount
61
- so = shell_out("mount -l")
62
- so.stdout.lines do |line|
63
- if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
64
- filesystem = $1
65
- fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
66
- fs[filesystem][:mount] = $2
67
- fs[filesystem][:fs_type] = $3
68
- fs[filesystem][:mount_options] = $4.split(/,\s*/)
69
- end
70
- end
71
-
72
- # Set the filesystem data
73
- filesystem fs
74
- end
75
- end
@@ -1,107 +0,0 @@
1
- #
2
- # Author:: Phil Dibowitz (<phil@ipom.com>)
3
- # Author:: Benjamin Black (<bb@chef.io>)
4
- # Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
5
- # Copyright:: Copyright (c) 2015 Facebook, Inc.
6
- # License:: Apache License, Version 2.0
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
-
21
- Ohai.plugin(:Filesystem) do
22
- provides "filesystem"
23
-
24
- def generate_device_view(fs)
25
- view = {}
26
- fs.each_value do |entry|
27
- view[entry[:device]] = Mash.new unless view[entry[:device]]
28
- entry.each do |key, val|
29
- next if %w{device mount}.include?(key)
30
- view[entry[:device]][key] = val
31
- end
32
- if entry[:mount]
33
- view[entry[:device]][:mounts] = [] unless view[entry[:device]][:mounts]
34
- view[entry[:device]][:mounts] << entry[:mount]
35
- end
36
- end
37
- view
38
- end
39
-
40
- def generate_mountpoint_view(fs)
41
- view = {}
42
- fs.each_value do |entry|
43
- next unless entry[:mount]
44
- view[entry[:mount]] = Mash.new unless view[entry[:mount]]
45
- entry.each do |key, val|
46
- next if %w{mount device}.include?(key)
47
- view[entry[:mount]][key] = val
48
- end
49
- if entry[:device]
50
- view[entry[:mount]][:devices] = [] unless view[entry[:mount]][:devices]
51
- view[entry[:mount]][:devices] << entry[:device]
52
- end
53
- end
54
- view
55
- end
56
-
57
- collect_data(:darwin) do
58
- fs = Mash.new
59
- block_size = 0
60
- # on new versions of OSX, -i is default, on old versions it's not, so
61
- # specifying it gets consistent output
62
- so = shell_out("df -i")
63
- so.stdout.each_line do |line|
64
- case line
65
- when /^Filesystem\s+(\d+)-/
66
- block_size = $1.to_i
67
- next
68
- when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(\d+)\s+(\d+)\s+(\d+%)\s+(.+)$/
69
- key = "#{$1},#{$9}"
70
- fs[key] = Mash.new
71
- fs[key][:block_size] = block_size
72
- fs[key][:device] = $1
73
- fs[key][:kb_size] = ($2.to_i / (1024 / block_size)).to_s
74
- fs[key][:kb_used] = ($3.to_i / (1024 / block_size)).to_s
75
- fs[key][:kb_available] = ($4.to_i / (1024 / block_size)).to_s
76
- fs[key][:percent_used] = $5
77
- fs[key][:inodes_used] = $6
78
- fs[key][:inodes_available] = $7
79
- fs[key][:total_inodes] = ($6.to_i + $7.to_i).to_s
80
- fs[key][:inodes_percent_used] = $8
81
- fs[key][:mount] = $9
82
- end
83
- end
84
-
85
- so = shell_out("mount")
86
- so.stdout.lines do |line|
87
- if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
88
- key = "#{$1},#{$2}"
89
- fs[key] = Mash.new unless fs.has_key?(key)
90
- fs[key][:mount] = $2
91
- fs[key][:fs_type] = $3
92
- fs[key][:mount_options] = $4.split(/,\s*/)
93
- end
94
- end
95
-
96
- by_pair = fs
97
- by_device = generate_device_view(fs)
98
- by_mountpoint = generate_mountpoint_view(fs)
99
-
100
- fs_data = Mash.new
101
- fs_data["by_device"] = by_device
102
- fs_data["by_mountpoint"] = by_mountpoint
103
- fs_data["by_pair"] = by_pair
104
-
105
- filesystem fs_data
106
- end
107
- end