genesis_collector 0.1.27 → 0.1.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/handler/genesis.rb +1 -0
- data/lib/genesis_collector/collector.rb +20 -7
- data/lib/genesis_collector/disks.rb +5 -0
- data/lib/genesis_collector/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd8f39a8d1af3d60b93b660d40ec8a2a892137e7
|
4
|
+
data.tar.gz: 29b7807e760154ddee6e6c9eb049054ba9e616cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e93499cfc55c3f2a87529124f173b64c583ad8a26d8683caa1bdd7e634911a95268afd7ac047c9a6858e7493e6bc1973abe54f6bed8eb6357e12fa15c3fd4a21
|
7
|
+
data.tar.gz: bc936f4b2eead68e95e7ed803dbfef82abd11a71f1f651a992668c71dd2a098a07b53d38d312de1a16a84b66ddb4b276a0bdb8b230f2ef1ecb9f5083a627a2a3
|
data/lib/chef/handler/genesis.rb
CHANGED
@@ -23,6 +23,7 @@ class Chef
|
|
23
23
|
@bugsnag_config.app_version = GenesisCollector::VERSION
|
24
24
|
@bugsnag_config.project_root = File.expand_path('../../..', File.dirname(__FILE__))
|
25
25
|
@bugsnag_config.release_stage = run_context.node.chef_environment
|
26
|
+
@config[:error_handler] = ->(e) { Bugsnag::Notification.new(e, @bugsnag_config).deliver }
|
26
27
|
end
|
27
28
|
prepare_report
|
28
29
|
send_report
|
@@ -27,13 +27,13 @@ module GenesisCollector
|
|
27
27
|
|
28
28
|
def collect!
|
29
29
|
@sku = get_sku
|
30
|
-
collect_basic_data
|
31
|
-
collect_chef
|
32
|
-
collect_ipmi
|
33
|
-
collect_network_interfaces
|
34
|
-
collect_disks
|
35
|
-
collect_cpus
|
36
|
-
collect_memories
|
30
|
+
safely { collect_basic_data }
|
31
|
+
safely { collect_chef }
|
32
|
+
safely { collect_ipmi }
|
33
|
+
safely { collect_network_interfaces }
|
34
|
+
safely { collect_disks }
|
35
|
+
safely { collect_cpus }
|
36
|
+
safely { collect_memories }
|
37
37
|
@payload
|
38
38
|
end
|
39
39
|
|
@@ -114,6 +114,13 @@ module GenesisCollector
|
|
114
114
|
|
115
115
|
private
|
116
116
|
|
117
|
+
def safely
|
118
|
+
yield
|
119
|
+
rescue StandardError => ex
|
120
|
+
STDERR.puts ex.message
|
121
|
+
@config[:error_handler].call(ex) if @config[:error_handler]
|
122
|
+
end
|
123
|
+
|
117
124
|
def shellout_with_timeout(command, timeout = 2)
|
118
125
|
response = `timeout #{timeout} #{command}`
|
119
126
|
unless $CHILD_STATUS.success?
|
@@ -173,6 +180,8 @@ module GenesisCollector
|
|
173
180
|
'UKN'
|
174
181
|
end
|
175
182
|
"#{manufacturer}-#{serial}".gsub('.','') # dells
|
183
|
+
rescue StandardError => ex
|
184
|
+
raise "Unable to deterimine SKU: #{ex.message}"
|
176
185
|
end
|
177
186
|
|
178
187
|
def read_dmi(key)
|
@@ -186,5 +195,9 @@ module GenesisCollector
|
|
186
195
|
return nil unless ('A'..'Z').include?(value)
|
187
196
|
value.empty? ? nil : value
|
188
197
|
end
|
198
|
+
|
199
|
+
def ensure_command(command)
|
200
|
+
!`which #{command}`.empty? || raise("#{command} missing!")
|
201
|
+
end
|
189
202
|
end
|
190
203
|
end
|
@@ -2,6 +2,7 @@ module GenesisCollector
|
|
2
2
|
module Disks
|
3
3
|
|
4
4
|
def collect_disks
|
5
|
+
ensure_command('smartctl')
|
5
6
|
@payload[:disks] = enumerate_disks
|
6
7
|
@payload[:disks].each do |d|
|
7
8
|
info = get_disk_info(d.delete(:smartctl_cmd))
|
@@ -13,6 +14,10 @@ module GenesisCollector
|
|
13
14
|
d[:slot] = get_scsi_slot(d[:dev]) if d[:dev] =~ /^\/dev\/sd/
|
14
15
|
end
|
15
16
|
@payload[:disks].delete_if { |d| d[:serial_number].nil? }
|
17
|
+
rescue StandardError => ex
|
18
|
+
# Just to be sure we don't send partial data
|
19
|
+
@payload.delete(:disks)
|
20
|
+
raise ex
|
16
21
|
end
|
17
22
|
|
18
23
|
private
|