elesai 0.6.9 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -4
- data/lib/elesai/cli.rb +21 -13
- data/lib/elesai/lsi.rb +44 -1
- data/lib/elesai/megacli.rb +275 -26
- data/lib/elesai/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -9,14 +9,18 @@
|
|
9
9
|
where:
|
10
10
|
|
11
11
|
* `<action>` is one of `show` or `check`
|
12
|
-
* `<component>`
|
12
|
+
* `<component>` (for `show` action) is one of
|
13
|
+
* `virtualdrive` (or `vd`)
|
14
|
+
* `physicaldrive` (or `pd`)
|
15
|
+
* `bbu`
|
13
16
|
|
14
17
|
Global options include:
|
15
18
|
|
16
19
|
* `-d`, `--debug`: enable *debug* mode
|
17
20
|
* `-f`, `--fake DIRECTORY`: specifies path to directory containing output of MegaCli invocations:
|
18
|
-
* `ldlist_aall`: output from `MegaCli -pdlist -aall`
|
19
|
-
* `ldpdinfo_aall`: output from `MegaCli -ldpdinfo -aall`
|
21
|
+
* `ldlist_aall`: output from `MegaCli -pdlist -aall -nolog`
|
22
|
+
* `ldpdinfo_aall`: output from `MegaCli -ldpdinfo -aall -nolog`
|
23
|
+
* `adpbbucmd_aall`: output from `MegaCli -adpcbucmd -aall -nolog`
|
20
24
|
* `-m`, `--megacli MEGACLI`: path to `MegaCli` binary (if noth in `$PATH`)
|
21
25
|
* `-a`, `--about`: display general information about `elesai`
|
22
26
|
* `-V`, `--version`: display `elesai`'s version
|
@@ -29,7 +33,7 @@ The `<check>` can have options specific to itself:
|
|
29
33
|
* `-c`, `--config CONFIG`: Path to Senedsa (send_nsca) configuration
|
30
34
|
* `-S`, `--svc_descr SVC_DESCR`: Nagios service description
|
31
35
|
|
32
|
-
*Elesai* uses [Senedsa](https://rubygems.org/gems/senedsa "Senedsa") for Nagios passive check submission, which can use a configuration file to set options.
|
36
|
+
*Elesai* uses [Senedsa](https://rubygems.org/gems/senedsa "Senedsa") for Nagios passive check submission, which can use a configuration file to set options. Additionally, it will invoke `MegaCli` with `sudo` if not run by `root`.
|
33
37
|
|
34
38
|
# Invocations
|
35
39
|
|
data/lib/elesai/cli.rb
CHANGED
@@ -69,7 +69,7 @@ module Elesai
|
|
69
69
|
:show => OptionParser.new do |aopts|
|
70
70
|
aopts.banner = "Usage: #{ID} [options] show <component>"
|
71
71
|
aopts.separator ""
|
72
|
-
aopts.separator " <component> is physicaldisk|pd, virtualdisk|vd"
|
72
|
+
aopts.separator " <component> is physicaldisk|pd, virtualdisk|vd, bbu"
|
73
73
|
end,
|
74
74
|
:check => OptionParser.new do |aopts|
|
75
75
|
aopts.banner = "Usage: #{ID} [options] check [check_options]"
|
@@ -148,6 +148,10 @@ module Elesai
|
|
148
148
|
@lsi.physicaldrives.each do |id,physicaldrive|
|
149
149
|
print "#{physicaldrive}\n"
|
150
150
|
end
|
151
|
+
when 'bbu'
|
152
|
+
@lsi.bbus.each do |bbu|
|
153
|
+
print "#{bbu}\n"
|
154
|
+
end
|
151
155
|
else
|
152
156
|
raise ArgumentError, "invalid component #{component}"
|
153
157
|
end
|
@@ -162,26 +166,35 @@ module Elesai
|
|
162
166
|
drive_plugin_string = "[PD:#{physicaldrive._id}:#{physicaldrive[:size]}:#{physicaldrive[:mediatype]}:#{physicaldrive[:pdtype]}]"
|
163
167
|
unless physicaldrive[:firmwarestate].state == :online or physicaldrive[:firmwarestate].state == :hotspare
|
164
168
|
plugin_output += " #{drive_plugin_string}:#{physicaldrive[:firmwarestate].state}"
|
169
|
+
plugin_status = :critical if physicaldrive[:firmwarestate] == :failed
|
165
170
|
plugin_status = :warning if plugin_status.empty?
|
166
171
|
end
|
167
|
-
unless physicaldrive[:mediaerrorcount].to_i
|
168
|
-
plugin_output += " #{drive_plugin_string}:
|
172
|
+
unless physicaldrive[:mediaerrorcount].to_i < 10
|
173
|
+
plugin_output += " #{drive_plugin_string}:MediaError:#{physicaldrive[:mediaerrorcount]}"
|
169
174
|
plugin_status = :warning if plugin_status.empty?
|
170
175
|
end
|
171
|
-
unless physicaldrive[:predictivefailurecount].to_i
|
172
|
-
plugin_output += " #{drive_plugin_string}:
|
176
|
+
unless physicaldrive[:predictivefailurecount].to_i < 5
|
177
|
+
plugin_output += " #{drive_plugin_string}:PredictiveFailure:#{physicaldrive[:predictivefailurecount]}"
|
173
178
|
plugin_status = :warning if plugin_status.empty?
|
174
179
|
end
|
175
180
|
end
|
176
181
|
|
177
|
-
|
182
|
+
@lsi.virtualdrives.each do |vd|
|
183
|
+
vd_plugin_string = "[VD:#{vd._id}]"
|
184
|
+
unless vd[:state] == :optimal
|
185
|
+
plugin_output += " #{vd_plugin_string}:#{vd[:state]}"
|
186
|
+
plugin_status = :critical
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
plugin_output = " no LSI RAID errors found" if plugin_output.empty? and plugin_status.empty?
|
178
191
|
plugin_status = :ok if plugin_status.empty?
|
179
192
|
|
180
193
|
case @action_options[:monitor]
|
181
194
|
when :nagios
|
182
195
|
case @action_options[:mode]
|
183
196
|
when :active
|
184
|
-
puts "#{plugin_status.to_s.upcase}
|
197
|
+
puts "#{plugin_status.to_s.upcase}:#{plugin_output}"
|
185
198
|
exit SendNsca::STATUS[plugin_status]
|
186
199
|
when :passive
|
187
200
|
sn = SendNsca.new @action_options
|
@@ -202,9 +215,4 @@ module Elesai
|
|
202
215
|
end
|
203
216
|
|
204
217
|
end
|
205
|
-
end
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
218
|
+
end
|
data/lib/elesai/lsi.rb
CHANGED
@@ -2,7 +2,7 @@ module Elesai
|
|
2
2
|
|
3
3
|
class LSIArray
|
4
4
|
|
5
|
-
attr_reader :adapters, :virtualdrives, :physicaldrives, :enclosures
|
5
|
+
attr_reader :adapters, :virtualdrives, :physicaldrives, :bbus, :enclosures
|
6
6
|
|
7
7
|
def initialize(opts)
|
8
8
|
@adapters = []
|
@@ -10,12 +10,15 @@ module Elesai
|
|
10
10
|
@physicaldrives = {}
|
11
11
|
@enclosures = []
|
12
12
|
@spans = []
|
13
|
+
@bbus = []
|
13
14
|
|
14
15
|
case opts[:hint]
|
15
16
|
when :pd,:physicaldrive
|
16
17
|
PDlist_aAll.new.parse!(self,opts)
|
17
18
|
when :vd,:virtualdrive
|
18
19
|
LDPDinfo_aAll.new.parse!(self,opts)
|
20
|
+
when :bbu
|
21
|
+
AdpBbuCmd_aAll.new.parse!(self,opts)
|
19
22
|
else
|
20
23
|
PDlist_aAll.new.parse!(self,opts)
|
21
24
|
LDPDinfo_aAll.new.parse!(self,opts)
|
@@ -35,6 +38,10 @@ module Elesai
|
|
35
38
|
@physicaldrives[pd._id]
|
36
39
|
end
|
37
40
|
|
41
|
+
def add_bbu(bbu)
|
42
|
+
@bbus.push(bbu)
|
43
|
+
end
|
44
|
+
|
38
45
|
def to_s
|
39
46
|
lsiarrayout = "LSI Array\n"
|
40
47
|
@adapters.each do |adapter|
|
@@ -205,5 +212,41 @@ module Elesai
|
|
205
212
|
self[:_virtualdrives]
|
206
213
|
end
|
207
214
|
end
|
215
|
+
|
216
|
+
### BBU
|
217
|
+
|
218
|
+
class BBU < Hash
|
219
|
+
|
220
|
+
class Stub < Hash
|
221
|
+
def inspect
|
222
|
+
"#{self.class}:#{self.__id__}"
|
223
|
+
end
|
224
|
+
end
|
225
|
+
class Status < Stub; end
|
226
|
+
class FirmwareStatus < Stub; end
|
227
|
+
class DesignInfo < Stub; end
|
228
|
+
class Properties < Stub; end
|
229
|
+
class CapacityInfo < Stub; end
|
230
|
+
class GasGaugeStatus < Stub; end
|
231
|
+
|
232
|
+
def initialize
|
233
|
+
self[:status] = Status.new
|
234
|
+
self[:firmwarestatus] = FirmwareStatus.new
|
235
|
+
self[:designinfo] = DesignInfo.new
|
236
|
+
self[:properties] = Properties.new
|
237
|
+
self[:capacityinfo] = CapacityInfo.new
|
238
|
+
self[:gasgaugestatus] = GasGaugeStatus.new
|
239
|
+
self[:capacityinfo][:absolutestateofcharge] = '-'
|
240
|
+
end
|
241
|
+
|
242
|
+
def inspect
|
243
|
+
"#{self.class}:#{self.__id__}"
|
244
|
+
end
|
245
|
+
|
246
|
+
def to_s
|
247
|
+
"[BBU] %-5s %-4s %-11s %3s:%s %s:%s %s:%s %-4s %s" % [self[:batterytype],self[:designinfo][:devicechemistry],self[:firmwarestatus][:chargingstatus],self[:firmwarestatus][:learncycleactive],self[:firmwarestatus][:learncyclestatus],self[:voltage].gsub(/\s/,''),self[:firmwarestatus][:voltage],self[:temperature].gsub(/\s/,''),self[:firmwarestatus][:temperature],self[:capacityinfo][:absolutestateofcharge].gsub(/\s/,''),self[:properties][:nextlearntime]]
|
248
|
+
#puts self[:firmwarestatus].keys
|
249
|
+
end
|
250
|
+
end
|
208
251
|
end
|
209
252
|
end
|
data/lib/elesai/megacli.rb
CHANGED
@@ -12,15 +12,23 @@ module Elesai
|
|
12
12
|
VIRTUALDRIVE_RE = /^Virtual\s+Drive:\s+\d+\s+\((?<key>Target\s+Id):\s+(?<value>\d+)\)/
|
13
13
|
SPAN_RE = /^Span:\s+(?<value>\d+)/
|
14
14
|
PHYSICALDRIVE_RE = /^(?<key>Enclosure\s+Device\s+ID):\s+(?<value>\d+)/
|
15
|
-
ATTRIBUTE_RE = /^(?<key>[A-Za-z0-9()\s#'
|
15
|
+
ATTRIBUTE_RE = /^(?<key>[A-Za-z0-9()\s#'-.&]+)[:|=](?<value>.*)/
|
16
16
|
EXIT_RE = /^Exit Code: /
|
17
17
|
|
18
|
+
BBU_RE = /^BBU status for Adapter:\s+(?<value>\d+)/
|
19
|
+
BBU_FIRMWARESTATUS_RE = /^BBU Firmware Status:/
|
20
|
+
BBU_DESIGNINFO_RE = /^BBU Design Info for Adapter:\s+(?<value>\d+)/
|
21
|
+
BBU_PROPERTIES_RE = /^BBU Properties for Adapter:\s+(?<value>\d+)/
|
22
|
+
BBU_GASGAUGESTATUS_RE = /^GasGuageStatus:/
|
23
|
+
BBU_CAPACITYINFO_RE = /^BBU Capacity Info for Adapter:\s+(?<value>\d+)/
|
24
|
+
|
25
|
+
|
18
26
|
### Context
|
19
27
|
|
20
28
|
class Context
|
21
29
|
|
22
30
|
def initialize(current_state,lsi)
|
23
|
-
current_state.meta[:context] = { :stack => []
|
31
|
+
current_state.meta[:context] = { :stack => [] }
|
24
32
|
@context = current_state.meta[:context]
|
25
33
|
@lsi = lsi
|
26
34
|
@log = Elesai::Logger.instance.log
|
@@ -29,7 +37,7 @@ module Elesai
|
|
29
37
|
def open(component)
|
30
38
|
@log.debug " * Open #{component.inspect}"
|
31
39
|
@context[:stack].push(component)
|
32
|
-
@context[component.
|
40
|
+
@context[component.class] = component
|
33
41
|
@log.debug " + context: #{@context[:stack]}"
|
34
42
|
end
|
35
43
|
|
@@ -42,17 +50,20 @@ module Elesai
|
|
42
50
|
|
43
51
|
def close
|
44
52
|
component = @context[:stack].pop
|
45
|
-
@context[component.
|
53
|
+
@context[component.class] = nil
|
46
54
|
@log.debug " * Close #{component.inspect}"
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
case component
|
56
|
+
when Elesai::LSIArray::PhysicalDrive
|
57
|
+
pd = @lsi.add_physicaldrive(component)
|
58
|
+
pd.add_adapter(adapter)
|
59
|
+
pd.add_virtualdrive(virtualdrive) unless virtualdrive.nil?
|
60
|
+
adapter.add_physicaldrive(pd)
|
61
|
+
when Elesai::LSIArray::VirtualDrive
|
62
|
+
vd = @lsi.add_virtualdrive(component)
|
63
|
+
when Elesai::LSIArray::Adapter
|
64
|
+
@lsi.add_adapter(component)
|
65
|
+
when Elesai::LSIArray::BBU
|
66
|
+
@lsi.add_bbu(component)
|
56
67
|
end
|
57
68
|
@log.debug " + context: #{@context[:stack]}"
|
58
69
|
end
|
@@ -62,19 +73,49 @@ module Elesai
|
|
62
73
|
end
|
63
74
|
|
64
75
|
def adapter
|
65
|
-
@context[
|
76
|
+
@context[Elesai::LSIArray::Adapter]
|
66
77
|
end
|
67
78
|
|
68
79
|
def virtualdrive
|
69
|
-
@context[
|
80
|
+
@context[Elesai::LSIArray::VirtualDrive]
|
70
81
|
end
|
71
82
|
|
72
83
|
def physicaldrive
|
73
|
-
@context[
|
84
|
+
@context[Elesai::LSIArray::PhysicalDrive]
|
85
|
+
end
|
86
|
+
|
87
|
+
def bbu
|
88
|
+
@context[Elesai::LSIArray::BBU]
|
74
89
|
end
|
75
90
|
|
76
91
|
end
|
77
92
|
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
78
119
|
### State Machine Handlers
|
79
120
|
|
80
121
|
# Start
|
@@ -94,9 +135,8 @@ module Elesai
|
|
94
135
|
def on_adapter_entry(old_state, event, *args)
|
95
136
|
@log.debug " [#{current_state}] on_entry: leaving #{old_state}; args: #{args}"
|
96
137
|
|
97
|
-
@context.close unless @context.current.nil? or @context.current
|
138
|
+
@context.close unless @context.current.nil? or @context.current === Elesai::LSIArray::Adapter
|
98
139
|
@context.open args[0]
|
99
|
-
|
100
140
|
end
|
101
141
|
|
102
142
|
def on_adapter_exit(new_state, event, *args)
|
@@ -115,7 +155,7 @@ module Elesai
|
|
115
155
|
@log.debug " [#{current_state}] on_entry: leaving #{old_state}; args: #{args}"
|
116
156
|
|
117
157
|
unless @context.current.nil?
|
118
|
-
if @context.current
|
158
|
+
if @context.current === Elesai::LSIArray::VirtualDrive
|
119
159
|
@context.close
|
120
160
|
end
|
121
161
|
end
|
@@ -152,7 +192,7 @@ module Elesai
|
|
152
192
|
end
|
153
193
|
|
154
194
|
def on_attribute_entry(old_state, event, *args)
|
155
|
-
@log.debug " [#{current_state}] entry: leaving #{old_state}; args: #{args}"
|
195
|
+
@log.debug " [#{current_state}] entry: leaving #{old_state}; args: #{args}; context: #{@context.current.class}"
|
156
196
|
|
157
197
|
|
158
198
|
c = @context.current
|
@@ -185,11 +225,113 @@ module Elesai
|
|
185
225
|
|
186
226
|
def on_attribute_exit(new_state, event, *args)
|
187
227
|
@log.debug " [#{current_state}] exit: entering #{new_state} throught event #{event}; args: #{args}"
|
188
|
-
@context.close if @context.current.
|
228
|
+
@context.close if @context.current.class == Elesai::LSIArray::PhysicalDrive and event != :attribute_line
|
229
|
+
|
230
|
+
@context.flash!(new_state)
|
231
|
+
end
|
232
|
+
|
233
|
+
# BBU
|
234
|
+
|
235
|
+
def bbu_line(bbu,key,value)
|
236
|
+
@log.debug " [#{current_state}] event: bbu_line: new #{bbu.inspect}"
|
237
|
+
bbu[key.to_sym] = value.to_i
|
238
|
+
end
|
239
|
+
|
240
|
+
def on_bbu_entry(old_state, event, *args)
|
241
|
+
@log.debug " [#{current_state}] on_entry: leaving #{old_state}; args: #{args}"
|
242
|
+
@context.open args[0]
|
243
|
+
end
|
244
|
+
|
245
|
+
def on_bbu_exit(new_state, event, *args)
|
246
|
+
@log.debug " [#{current_state}] on_exit: entering #{new_state}; args: #{args}"
|
247
|
+
@context.flash!(new_state)
|
248
|
+
end
|
249
|
+
|
250
|
+
# BBU Firmware Status
|
251
|
+
|
252
|
+
def bbu_firmwarestatus_line
|
253
|
+
@log.debug " [#{current_state}] event: bbu_firmware_line:"
|
254
|
+
end
|
255
|
+
|
256
|
+
def on_bbu_firmwarestatus_entry(old_state, event, *args)
|
257
|
+
@log.debug " [#{current_state}] on_entry: leaving #{old_state}; args: #{args}"
|
258
|
+
@context.open @context.current[:firmwarestatus]
|
259
|
+
end
|
260
|
+
|
261
|
+
def on_bbu_firmwarestatus_exit(new_state, event, *args)
|
262
|
+
@log.debug " [#{current_state}] on_exit: entering #{new_state}; args: #{args}"
|
263
|
+
@context.flash!(new_state)
|
264
|
+
end
|
265
|
+
|
266
|
+
# BBU DesignInfo Status
|
267
|
+
|
268
|
+
def bbu_designinfo_line
|
269
|
+
@log.debug " [#{current_state}] event: bbu_designinfo_line:"
|
270
|
+
end
|
271
|
+
|
272
|
+
def on_bbu_designinfo_entry(old_state, event, *args)
|
273
|
+
@log.debug " [#{current_state}] on_entry: leaving #{old_state}; args: #{args}"
|
274
|
+
@context.close
|
275
|
+
@context.open @context.current[:designinfo]
|
276
|
+
end
|
277
|
+
|
278
|
+
def on_bbu_designinfo_exit(new_state, event, *args)
|
279
|
+
@log.debug " [#{current_state}] on_exit: entering #{new_state}; args: #{args}"
|
280
|
+
@context.flash!(new_state)
|
281
|
+
end
|
282
|
+
|
283
|
+
# BBU Properties Status
|
284
|
+
|
285
|
+
def bbu_properties_line
|
286
|
+
@log.debug " [#{current_state}] event: bbu_designinfo_line:"
|
287
|
+
end
|
288
|
+
|
289
|
+
def on_bbu_properties_entry(old_state, event, *args)
|
290
|
+
@log.debug " [#{current_state}] on_entry: leaving #{old_state}; args: #{args}"
|
291
|
+
@context.close
|
292
|
+
@context.open @context.current[:properties]
|
293
|
+
end
|
294
|
+
|
295
|
+
def on_bbu_properties_exit(new_state, event, *args)
|
296
|
+
@log.debug " [#{current_state}] on_exit: entering #{new_state}; args: #{args}"
|
297
|
+
@context.flash!(new_state)
|
298
|
+
end
|
299
|
+
|
300
|
+
# BBU GasGuage Status
|
301
|
+
|
302
|
+
def bbu_gasgaugestatus_line
|
303
|
+
@log.debug " [#{current_state}] event: bbu_gasgaugestatus_line:"
|
304
|
+
end
|
305
|
+
|
306
|
+
def on_bbu_gasgaugestatus_entry(old_state, event, *args)
|
307
|
+
@log.debug " [#{current_state}] on_entry: leaving #{old_state}; args: #{args}"
|
308
|
+
@context.close
|
309
|
+
@context.open @context.current[:gasgaugestatus]
|
310
|
+
end
|
311
|
+
|
312
|
+
def on_bbu_gasgaugestatus_exit(new_state, event, *args)
|
313
|
+
@log.debug " [#{current_state}] on_exit: entering #{new_state}; args: #{args}"
|
314
|
+
@context.flash!(new_state)
|
315
|
+
end
|
316
|
+
|
317
|
+
# BBU Capacity Info
|
318
|
+
|
319
|
+
def bbu_capacityinfo_line
|
320
|
+
@log.debug " [#{current_state}] event: bbu_capacityinfo_line:"
|
321
|
+
end
|
322
|
+
|
323
|
+
def on_bbu_capacityinfo_entry(old_state, event, *args)
|
324
|
+
@log.debug " [#{current_state}] on_entry: leaving #{old_state}; args: #{args}"
|
325
|
+
@context.close
|
326
|
+
@context.open @context.current[:capacityinfo]
|
327
|
+
end
|
189
328
|
|
329
|
+
def on_bbu_capacityinfo_exit(new_state, event, *args)
|
330
|
+
@log.debug " [#{current_state}] on_exit: entering #{new_state}; args: #{args}"
|
190
331
|
@context.flash!(new_state)
|
191
332
|
end
|
192
333
|
|
334
|
+
|
193
335
|
# Exit
|
194
336
|
|
195
337
|
def exit_line
|
@@ -203,6 +345,17 @@ module Elesai
|
|
203
345
|
end
|
204
346
|
end
|
205
347
|
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
206
359
|
### Regular Expression Match Handlers
|
207
360
|
|
208
361
|
# Adapter
|
@@ -241,6 +394,40 @@ module Elesai
|
|
241
394
|
attribute_line!(key,value)
|
242
395
|
end
|
243
396
|
|
397
|
+
# BBU
|
398
|
+
def bbu_match(match)
|
399
|
+
@log.debug "BBU! #{match.string}"
|
400
|
+
key = 'id'
|
401
|
+
value = match[:value]
|
402
|
+
adapter_line(LSIArray::Adapter.new,key,value)
|
403
|
+
bbu_line!(LSIArray::BBU.new,key,value)
|
404
|
+
end
|
405
|
+
|
406
|
+
def bbu_firmwarestatus_match(match)
|
407
|
+
@log.debug "BBU FIRMWARE! #{match.string}"
|
408
|
+
bbu_firmwarestatus_line!
|
409
|
+
end
|
410
|
+
|
411
|
+
def bbu_designinfo_match(match)
|
412
|
+
@log.debug "BBU DESIGN INFO! #{match.string}"
|
413
|
+
bbu_designinfo_line!
|
414
|
+
end
|
415
|
+
|
416
|
+
def bbu_properties_match(match)
|
417
|
+
@log.debug "BBU PROPERTIES! #{match.string}"
|
418
|
+
bbu_properties_line!
|
419
|
+
end
|
420
|
+
|
421
|
+
def bbu_capacityinfo_match(match)
|
422
|
+
@log.debug "BBU CAPACITY INFO! #{match.string}"
|
423
|
+
bbu_capacityinfo_line!
|
424
|
+
end
|
425
|
+
|
426
|
+
def bbu_gasgaugestatus_match(match)
|
427
|
+
@log.debug "BBU GAS GUAGE STATUS! #{match.string}"
|
428
|
+
bbu_gasgaugestatus_line!
|
429
|
+
end
|
430
|
+
|
244
431
|
# Exit
|
245
432
|
|
246
433
|
def exit_match(match)
|
@@ -262,6 +449,7 @@ module Elesai
|
|
262
449
|
if opts[:fake].start_with? '-'
|
263
450
|
megacli = opts[:megacli].nil? ? "Megacli" : opts[:megacli]
|
264
451
|
command = "#{megacli} #{opts[:fake]} -nolog"
|
452
|
+
command = Process.uid == 0 ? command : "sudo " << command
|
265
453
|
output, stderr_str, status = Open3.capture3(command)
|
266
454
|
raise RuntimeError, stderr_str unless status.exitstatus == 0
|
267
455
|
else
|
@@ -274,11 +462,17 @@ module Elesai
|
|
274
462
|
next if line == ''
|
275
463
|
|
276
464
|
case line
|
277
|
-
when ADAPTER_RE
|
278
|
-
when
|
279
|
-
when
|
280
|
-
when
|
281
|
-
when
|
465
|
+
when ADAPTER_RE then adapter_match(ADAPTER_RE.match(line))
|
466
|
+
when BBU_RE then bbu_match(BBU_RE.match(line))
|
467
|
+
when VIRTUALDRIVE_RE then virtualdrive_match(VIRTUALDRIVE_RE.match(line))
|
468
|
+
when PHYSICALDRIVE_RE then physicaldrive_match(PHYSICALDRIVE_RE.match(line))
|
469
|
+
when BBU_FIRMWARESTATUS_RE then bbu_firmwarestatus_match(BBU_FIRMWARESTATUS_RE.match(line))
|
470
|
+
when BBU_DESIGNINFO_RE then bbu_designinfo_match(BBU_DESIGNINFO_RE.match(line))
|
471
|
+
when BBU_PROPERTIES_RE then bbu_properties_match(BBU_PROPERTIES_RE.match(line))
|
472
|
+
when BBU_CAPACITYINFO_RE then bbu_capacityinfo_match(BBU_CAPACITYINFO_RE.match(line))
|
473
|
+
when BBU_GASGAUGESTATUS_RE then bbu_gasgaugestatus_match(BBU_GASGAUGESTATUS_RE.match(line))
|
474
|
+
when EXIT_RE then exit_match(EXIT_RE.match(line))
|
475
|
+
when ATTRIBUTE_RE then attribute_match(ATTRIBUTE_RE.match(line))
|
282
476
|
else raise StandardError, "cannot parse '#{line}'"
|
283
477
|
end
|
284
478
|
|
@@ -388,5 +582,60 @@ module Elesai
|
|
388
582
|
|
389
583
|
end
|
390
584
|
|
585
|
+
class AdpBbuCmd_aAll < Megacli
|
586
|
+
|
587
|
+
def parse!(lsi,opts)
|
588
|
+
fake = opts[:fake].nil? ? "-AdpBbuCmd -aAll" : File.join(opts[:fake],"adpbbucmd_aall")
|
589
|
+
super lsi, :fake => fake, :megacli => opts[:megacli]
|
590
|
+
end
|
591
|
+
|
592
|
+
workflow do
|
593
|
+
|
594
|
+
state :start do
|
595
|
+
event :bbu_line, :transitions_to => :bbu
|
596
|
+
event :exit_line, :transitions_to => :exit
|
597
|
+
end
|
598
|
+
|
599
|
+
state :bbu do
|
600
|
+
event :attribute_line, :transitions_to => :attribute
|
601
|
+
event :bbu_firmwarestatus_line, :transitions_to => :bbu_firmwarestatus
|
602
|
+
end
|
603
|
+
|
604
|
+
state :bbu_firmwarestatus do
|
605
|
+
event :attribute_line, :transitions_to => :attribute
|
606
|
+
end
|
607
|
+
|
608
|
+
state :bbu_capacityinfo do
|
609
|
+
event :attribute_line, :transitions_to => :attribute
|
610
|
+
end
|
611
|
+
|
612
|
+
state :bbu_designinfo do
|
613
|
+
event :attribute_line, :transitions_to => :attribute
|
614
|
+
end
|
615
|
+
|
616
|
+
state :bbu_gasgaugestatus do
|
617
|
+
event :attribute_line, :transitions_to => :attribute
|
618
|
+
end
|
619
|
+
|
620
|
+
state :bbu_properties do
|
621
|
+
event :attribute_line, :transitions_to => :attribute
|
622
|
+
event :exit_line, :transitions_to => :exit
|
623
|
+
end
|
624
|
+
|
625
|
+
state :attribute do
|
626
|
+
event :attribute_line, :transitions_to => :attribute
|
627
|
+
event :bbu_firmwarestatus_line, :transitions_to => :bbu_firmwarestatus
|
628
|
+
event :bbu_designinfo_line, :transitions_to => :bbu_designinfo
|
629
|
+
event :bbu_properties_line, :transitions_to => :bbu_properties
|
630
|
+
event :bbu_gasgaugestatus_line, :transitions_to => :bbu_gasgaugestatus
|
631
|
+
event :bbu_capacityinfo_line, :transitions_to => :bbu_capacityinfo
|
632
|
+
event :exit_line, :transitions_to => :exit
|
633
|
+
end
|
634
|
+
|
635
|
+
state :exit
|
636
|
+
end
|
637
|
+
|
638
|
+
end
|
639
|
+
|
391
640
|
|
392
641
|
end
|
data/lib/elesai/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elesai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: workflow
|