enterprise-ohai 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/enterprise/ohai/plugins/linux/disk.rb +30 -5
- metadata +4 -4
@@ -20,11 +20,36 @@ by_path_root = '/dev/disk/by-path'
|
|
20
20
|
by_label_root = '/dev/disk/by-label'
|
21
21
|
by_uuid_root = '/dev/disk/by-uuid'
|
22
22
|
|
23
|
+
%x{parted --list --script}.split("\n\n\n").each do |section|
|
24
|
+
path, headers, info = nil, nil, Mash.new
|
25
|
+
|
26
|
+
section.split("\n").each do |line|
|
27
|
+
case line
|
28
|
+
when %r{^Model: (.*)$} then info[:model] = $1
|
29
|
+
when %r{^Disk (.*): (.*)$} then path, info[:size] = $1, $2
|
30
|
+
when %r{^Number\s+} then headers = line.split(/\s{2,}/).map {|h| h.downcase.gsub(/\W/, '_') }
|
31
|
+
when %r{^ \d+} then
|
32
|
+
next if headers.nil?
|
33
|
+
keys = headers.map {|h| h.downcase.gsub(/\W/, '_') }
|
34
|
+
values = line.split
|
35
|
+
|
36
|
+
partition_info = keys.zip(values).inject(Mash.new) do |m, (k,v)|
|
37
|
+
m.update(k => v)
|
38
|
+
end
|
39
|
+
|
40
|
+
(info[:partitions] ||= []) << partition_info
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
(disks[path] ||= Mash.new).merge!(info)
|
45
|
+
end
|
46
|
+
|
23
47
|
Dir.glob(File.join(by_path_root, '*')).each do |disk_name_link|
|
24
48
|
disk_name = File.basename(disk_name_link)
|
25
49
|
path = disk_path(disk_name_link)
|
26
50
|
|
27
|
-
disks[path]
|
51
|
+
next unless disks[path]
|
52
|
+
|
28
53
|
disks[path][:name] = disk_name
|
29
54
|
end
|
30
55
|
|
@@ -32,7 +57,8 @@ Dir.glob(File.join(by_label_root, '*')).each do |disk_label_link|
|
|
32
57
|
disk_label = File.basename(disk_label_link)
|
33
58
|
path = disk_path(File.join(by_label_root, disk_label))
|
34
59
|
|
35
|
-
disks[path]
|
60
|
+
next unless disks[path]
|
61
|
+
|
36
62
|
disks[path][:label] = disk_label
|
37
63
|
end
|
38
64
|
|
@@ -40,15 +66,14 @@ Dir.glob(File.join(by_uuid_root, '*')).each do |disk_uuid_link|
|
|
40
66
|
disk_uuid = File.basename(disk_uuid_link)
|
41
67
|
path = disk_path(File.join(by_uuid_root, disk_uuid))
|
42
68
|
|
43
|
-
disks[path]
|
69
|
+
next unless disks[path]
|
70
|
+
|
44
71
|
disks[path][:uuid] = disk_uuid
|
45
72
|
end
|
46
73
|
|
47
74
|
disks.keys.each do |device|
|
48
75
|
disks[device].update(filesystem[device]) if filesystem[device]
|
49
76
|
disks[device].update(:swap => true) if swap[device]
|
50
|
-
|
51
|
-
disks[device].update(:size => disk_size(device))
|
52
77
|
end
|
53
78
|
|
54
79
|
disk disks
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enterprise-ohai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- GitHub
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-08 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|