rtdi 1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +9 -0
- data/bin/dashing +9 -0
- data/javascripts/batman.jquery.js +163 -0
- data/javascripts/batman.js +13680 -0
- data/javascripts/dashing.coffee +125 -0
- data/javascripts/es5-shim.js +1021 -0
- data/javascripts/jquery.js +4 -0
- data/lib/dashing.rb +6 -0
- data/lib/dashing/app.rb +178 -0
- data/lib/dashing/cli.rb +109 -0
- data/lib/dashing/downloader.rb +18 -0
- data/lib/rtdi.rb +6 -0
- data/lib/rtdi/socket.rb +39 -0
- data/lib/rtdi/start.rb +170 -0
- data/lib/rtdi/status.rb +476 -0
- data/templates/dashboard/%name%.erb.tt +7 -0
- data/templates/job/%name%.rb +4 -0
- data/templates/project/.gitignore +2 -0
- data/templates/project/Gemfile +7 -0
- data/templates/project/README.md +1 -0
- data/templates/project/assets/favicon.ico +0 -0
- data/templates/project/assets/fonts/fontawesome-webfont.eot +0 -0
- data/templates/project/assets/fonts/fontawesome-webfont.svg +255 -0
- data/templates/project/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/templates/project/assets/fonts/fontawesome-webfont.woff +0 -0
- data/templates/project/assets/images/favicon.ico +0 -0
- data/templates/project/assets/images/itslogo.png +0 -0
- data/templates/project/assets/images/itslogoflur.png +0 -0
- data/templates/project/assets/images/itslogozi207.png +0 -0
- data/templates/project/assets/images/logo.png +0 -0
- data/templates/project/assets/javascripts/application.coffee +42 -0
- data/templates/project/assets/javascripts/cycleDashboard.coffee +523 -0
- data/templates/project/assets/javascripts/d3-3.2.8.js +5 -0
- data/templates/project/assets/javascripts/d3.v2.min.js +4 -0
- data/templates/project/assets/javascripts/dashing.gridster.coffee +37 -0
- data/templates/project/assets/javascripts/gridster/jquery.gridster.js +3263 -0
- data/templates/project/assets/javascripts/gridster/jquery.leanModal.min.js +5 -0
- data/templates/project/assets/javascripts/jquery.knob.js +646 -0
- data/templates/project/assets/javascripts/rickshaw-1.4.3.min.js +2 -0
- data/templates/project/assets/javascripts/rickshaw.min.js +3 -0
- data/templates/project/assets/javascripts/rickshaw.min.js.1 +3 -0
- data/templates/project/assets/javascripts/rickshaw.min.js.bak +2 -0
- data/templates/project/assets/stylesheets/application.scss +342 -0
- data/templates/project/assets/stylesheets/font-awesome.css +313 -0
- data/templates/project/assets/stylesheets/jquery.gridster.css +57 -0
- data/templates/project/config.ru +19 -0
- data/templates/project/dashboards/layout.erb +32 -0
- data/templates/project/dashboards/rtdi_sample.erb +31 -0
- data/templates/project/dashboards/sample.erb +25 -0
- data/templates/project/dashboards/sampletv.erb +56 -0
- data/templates/project/jobs/buzzwords.rb +9 -0
- data/templates/project/jobs/convergence.rb +14 -0
- data/templates/project/jobs/rtdi_sample.rb +16 -0
- data/templates/project/jobs/sample.rb +13 -0
- data/templates/project/lib/bsp.csv +16 -0
- data/templates/project/public/404.html +26 -0
- data/templates/project/public/favicon.ico +0 -0
- data/templates/project/widgets/clock/clock.coffee +18 -0
- data/templates/project/widgets/clock/clock.html +2 -0
- data/templates/project/widgets/clock/clock.scss +13 -0
- data/templates/project/widgets/comments/comments.coffee +24 -0
- data/templates/project/widgets/comments/comments.html +7 -0
- data/templates/project/widgets/comments/comments.scss +33 -0
- data/templates/project/widgets/graph/graph.coffee +36 -0
- data/templates/project/widgets/graph/graph.html +5 -0
- data/templates/project/widgets/graph/graph.scss +65 -0
- data/templates/project/widgets/iframe/iframe.coffee +9 -0
- data/templates/project/widgets/iframe/iframe.html +1 -0
- data/templates/project/widgets/iframe/iframe.scss +8 -0
- data/templates/project/widgets/image/image.coffee +9 -0
- data/templates/project/widgets/image/image.html +1 -0
- data/templates/project/widgets/image/image.scss +13 -0
- data/templates/project/widgets/list/list.coffee +34 -0
- data/templates/project/widgets/list/list.html +18 -0
- data/templates/project/widgets/list/list.scss +60 -0
- data/templates/project/widgets/meter/meter.coffee +14 -0
- data/templates/project/widgets/meter/meter.html +7 -0
- data/templates/project/widgets/meter/meter.scss +35 -0
- data/templates/project/widgets/number/number.coffee +24 -0
- data/templates/project/widgets/number/number.html +11 -0
- data/templates/project/widgets/number/number.scss +39 -0
- data/templates/project/widgets/text/text.coffee +1 -0
- data/templates/project/widgets/text/text.html +7 -0
- data/templates/project/widgets/text/text.scss +32 -0
- data/templates/widget/%name%/%name%.coffee.tt +9 -0
- data/templates/widget/%name%/%name%.html +1 -0
- data/templates/widget/%name%/%name%.scss.tt +3 -0
- metadata +392 -0
data/lib/rtdi/status.rb
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
module RTDI
|
|
2
|
+
class Status
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# === Args:
|
|
7
|
+
# +list+::
|
|
8
|
+
# Array with stati
|
|
9
|
+
#
|
|
10
|
+
# === Description:
|
|
11
|
+
# Puts a totalstatus of a array
|
|
12
|
+
#
|
|
13
|
+
# === Return:
|
|
14
|
+
# +status+::
|
|
15
|
+
# Returns a totalstatus of a array
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
def self.stateall(list)
|
|
19
|
+
i = 0
|
|
20
|
+
list.each do |item|
|
|
21
|
+
if item.class.to_s != "Array"
|
|
22
|
+
list[i] = list[i].to_i
|
|
23
|
+
else
|
|
24
|
+
list[i] = list[i][1].to_i
|
|
25
|
+
end
|
|
26
|
+
i += 1
|
|
27
|
+
end
|
|
28
|
+
sorted = bubble(list)
|
|
29
|
+
i = 0
|
|
30
|
+
sorted = case sorted[-1]
|
|
31
|
+
when 0 then "normal"
|
|
32
|
+
when 1 then "unknownack"
|
|
33
|
+
when 2 then "warningack"
|
|
34
|
+
when 3 then "criticalack"
|
|
35
|
+
when 4 then "unknown"
|
|
36
|
+
when 5 then "warning"
|
|
37
|
+
when 6 then "danger"
|
|
38
|
+
end
|
|
39
|
+
return sorted
|
|
40
|
+
end
|
|
41
|
+
#
|
|
42
|
+
# === Args:
|
|
43
|
+
# +list+::
|
|
44
|
+
# array which should be sorted
|
|
45
|
+
#
|
|
46
|
+
# === Description:
|
|
47
|
+
# Sorts a array (DESC)
|
|
48
|
+
#
|
|
49
|
+
# === Return:
|
|
50
|
+
# +list+::
|
|
51
|
+
# Sorted array
|
|
52
|
+
#
|
|
53
|
+
|
|
54
|
+
def self.bubble(list)
|
|
55
|
+
return list if list.class.to_s != "Array"
|
|
56
|
+
return list if list.size <= 1 # already sorted
|
|
57
|
+
swapped = true
|
|
58
|
+
while swapped do
|
|
59
|
+
swapped = false
|
|
60
|
+
0.upto(list.size-2) do |i|
|
|
61
|
+
if list[i] > list[i+1]
|
|
62
|
+
list[i], list[i+1] = list[i+1], list[i] # swap values
|
|
63
|
+
swapped = true
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
list
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
#
|
|
71
|
+
# === Args:
|
|
72
|
+
# +hostgroup+::
|
|
73
|
+
# Objectname of the hostgroup in icinga
|
|
74
|
+
#
|
|
75
|
+
# === Description:
|
|
76
|
+
# Gets all groupmember
|
|
77
|
+
#
|
|
78
|
+
# === Return:
|
|
79
|
+
# +erg+::
|
|
80
|
+
# Returns all groupmember [array]
|
|
81
|
+
#
|
|
82
|
+
|
|
83
|
+
def self.hgm(hostgroup)
|
|
84
|
+
erg = RTDI::IDSocket.request("hostgroups","members","name = #{hostgroup}").split(",")
|
|
85
|
+
return erg
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
#
|
|
89
|
+
# === Args:
|
|
90
|
+
# +servicegroup+::
|
|
91
|
+
# Objectname of the servicegroup in icinga
|
|
92
|
+
#
|
|
93
|
+
# === Description:
|
|
94
|
+
# Gets all groupmember
|
|
95
|
+
#
|
|
96
|
+
# === Return:
|
|
97
|
+
# +erg+::
|
|
98
|
+
# Returns all groupmember [array]
|
|
99
|
+
#
|
|
100
|
+
def self.sgm(servicegroup)
|
|
101
|
+
erg = RTDI::IDSocket.request("servicegroups","members","name = #{servicegroup}").split(",")
|
|
102
|
+
i = 0
|
|
103
|
+
return erg
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
#
|
|
107
|
+
# === Args:
|
|
108
|
+
# +name+::
|
|
109
|
+
# Name in icinga
|
|
110
|
+
# +qa+::
|
|
111
|
+
# type of the object (Hostgroup, Service, Host)
|
|
112
|
+
#
|
|
113
|
+
# === Description:
|
|
114
|
+
# Gets the data from the icinga host
|
|
115
|
+
#
|
|
116
|
+
# === Return:
|
|
117
|
+
# +erg+::
|
|
118
|
+
# Returns a status and the "acknowledgment"
|
|
119
|
+
#
|
|
120
|
+
|
|
121
|
+
def self.get(name,qa)
|
|
122
|
+
begin
|
|
123
|
+
erg = case qa
|
|
124
|
+
when "ssh" then RTDI::IDSocket.request("services","state acknowledged","host_name = #{name}")
|
|
125
|
+
when "hsh" then RTDI::IDSocket.request("hosts","state acknowledged","host_name = #{name}")
|
|
126
|
+
when "hs" then RTDI::IDSocket.request("hosts","state acknowledged","name = #{name}")
|
|
127
|
+
when "ssd" then RTDI::IDSocket.request("services","state acknowledged","display_name = #{name}")
|
|
128
|
+
when "sgi" then RTDI::IDSocket.request("services","state acknowledged","host_name = #{name[0]}","display_name = #{name[1]}")
|
|
129
|
+
end
|
|
130
|
+
if erg.length == 0
|
|
131
|
+
raise 'Das Objekt "' + name.to_s + '" existiert nicht in Icinga!'
|
|
132
|
+
end
|
|
133
|
+
if qa == "ssh" then
|
|
134
|
+
tmp = []
|
|
135
|
+
erg_length = erg.length / 3
|
|
136
|
+
i = 0
|
|
137
|
+
erg_length.downto(0) do |item|
|
|
138
|
+
tmp[item] = erg[i,3]
|
|
139
|
+
i += 3
|
|
140
|
+
end
|
|
141
|
+
erg = tmp[1,erg.length]
|
|
142
|
+
i = 0
|
|
143
|
+
erg.each do |item|
|
|
144
|
+
erg[i] = casestate(item,qa[0])
|
|
145
|
+
i += 1
|
|
146
|
+
end
|
|
147
|
+
erg = bubble(erg)[-1]
|
|
148
|
+
else
|
|
149
|
+
erg = casestate(erg,qa[0])
|
|
150
|
+
end
|
|
151
|
+
rescue Exception => e
|
|
152
|
+
puts "Es ist ein Fehler aufgetreten: " + e.message
|
|
153
|
+
puts "Objekttyp: unknown"
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
#
|
|
158
|
+
# === Args:
|
|
159
|
+
# +value+::
|
|
160
|
+
# A value which should convert
|
|
161
|
+
# +type+::
|
|
162
|
+
# (s)ervice | (h)ost
|
|
163
|
+
#
|
|
164
|
+
# === Description:
|
|
165
|
+
# convert a status + "acknowledged" in a dashing-readable format
|
|
166
|
+
#
|
|
167
|
+
# === Return:
|
|
168
|
+
# +erg+::
|
|
169
|
+
# Returns the status
|
|
170
|
+
#
|
|
171
|
+
|
|
172
|
+
def self.casestate(value,type)
|
|
173
|
+
if type == "s"
|
|
174
|
+
erg = case value
|
|
175
|
+
when "0;0","0" then 0
|
|
176
|
+
when "3;1" then 1
|
|
177
|
+
when "1;1" then 2
|
|
178
|
+
when "2;1" then 3
|
|
179
|
+
when "3;0","3" then 4
|
|
180
|
+
when "1;0","1" then 5
|
|
181
|
+
when "2;0","2" then 6
|
|
182
|
+
end
|
|
183
|
+
elsif type == "h"
|
|
184
|
+
erg = case value
|
|
185
|
+
when "0;0","0" then 0
|
|
186
|
+
when "1;1" then 3
|
|
187
|
+
when "1;0","1" then 6
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
return erg
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
#
|
|
195
|
+
# === Args:
|
|
196
|
+
# +state+::
|
|
197
|
+
# status, which schould be converted to numeric [string]
|
|
198
|
+
#
|
|
199
|
+
# === Description:
|
|
200
|
+
# Converts a named status to a numeric status
|
|
201
|
+
#
|
|
202
|
+
# === Return:
|
|
203
|
+
# +conv+::
|
|
204
|
+
# Returns the nummeric status
|
|
205
|
+
|
|
206
|
+
def self.convback(state)
|
|
207
|
+
conv = case state
|
|
208
|
+
when "normal" then 0
|
|
209
|
+
when "unknownack" then 1
|
|
210
|
+
when "warningack" then 2
|
|
211
|
+
when "criticalack" then 3
|
|
212
|
+
when "unknown" then 4
|
|
213
|
+
when "warning" then 5
|
|
214
|
+
when "critical","danger" then 6
|
|
215
|
+
end
|
|
216
|
+
return conv
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
#
|
|
220
|
+
# === Args:
|
|
221
|
+
# +groupname+::
|
|
222
|
+
# Name of the groupobject
|
|
223
|
+
#
|
|
224
|
+
# === Description:
|
|
225
|
+
# Gets the status of all hosts in a hostgroup
|
|
226
|
+
#
|
|
227
|
+
# === Return:
|
|
228
|
+
# +res+::
|
|
229
|
+
# Returns a status of all hosts
|
|
230
|
+
|
|
231
|
+
def self.getgroup(groupname)
|
|
232
|
+
begin
|
|
233
|
+
res = hgm(groupname)
|
|
234
|
+
if res.length == 0
|
|
235
|
+
raise 'Das Objekt "' + groupname + '" existiert nicht in Icinga!'
|
|
236
|
+
end
|
|
237
|
+
i = 0
|
|
238
|
+
res.each do |item|
|
|
239
|
+
res[i] = get(item, "hsh")
|
|
240
|
+
i += 1
|
|
241
|
+
end
|
|
242
|
+
res = bubble(res)[-1]
|
|
243
|
+
rescue Exception => e
|
|
244
|
+
puts "Es ist ein Fehler aufgetreten: " + e.message
|
|
245
|
+
puts "Objekttyp: Servicegroup"
|
|
246
|
+
end
|
|
247
|
+
return res
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
#
|
|
251
|
+
# === Args:
|
|
252
|
+
# +groupname+::
|
|
253
|
+
# Name of the groupobject
|
|
254
|
+
#
|
|
255
|
+
# === Description:
|
|
256
|
+
# Gets the status of all hosts in a hostgroup and its services
|
|
257
|
+
#
|
|
258
|
+
# === Return:
|
|
259
|
+
# +res+::
|
|
260
|
+
# Returns a stati of all hosts and services
|
|
261
|
+
|
|
262
|
+
def self.gs(groupname,servicename)
|
|
263
|
+
begin
|
|
264
|
+
member = sgm(groupname)
|
|
265
|
+
if member.length == 0
|
|
266
|
+
raise 'Das Objekt "' + groupname.to_s + '" existiert nicht in Icinga!'
|
|
267
|
+
end
|
|
268
|
+
i = 0
|
|
269
|
+
res = []
|
|
270
|
+
member.each do |item|
|
|
271
|
+
res[i] = RTDI::IDSocket.request("services","perf_data state","host_name = #{item.split("|")[0]}","display_name = #{servicename}")
|
|
272
|
+
if res[i] == 0
|
|
273
|
+
raise 'Das Objekt "' + item.split("|")[0] + '" und dem Service "' + servicename.to_s + '" existiert nicht!'
|
|
274
|
+
end
|
|
275
|
+
i += 1
|
|
276
|
+
end
|
|
277
|
+
x = 0
|
|
278
|
+
state = []
|
|
279
|
+
res.each do |item|
|
|
280
|
+
state[x] = item.split(";")[1]
|
|
281
|
+
res[x] = item.split(";")[0]
|
|
282
|
+
x += 1
|
|
283
|
+
end
|
|
284
|
+
state = bubble(state)[-1]
|
|
285
|
+
res << state
|
|
286
|
+
rescue Exception => e
|
|
287
|
+
puts "Es ist ein Fehler aufgetreten: " + e.message
|
|
288
|
+
puts "Objekttyp: Servicegroup"
|
|
289
|
+
end
|
|
290
|
+
return res
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
def self.groupservices(groupname)
|
|
295
|
+
begin
|
|
296
|
+
member = hgm(groupname)
|
|
297
|
+
if member.length == 0
|
|
298
|
+
raise 'Das Objekt "' + groupname.to_s + '" existiert nicht in Icinga!'
|
|
299
|
+
end
|
|
300
|
+
i = 0
|
|
301
|
+
res = []
|
|
302
|
+
member.each do |item|
|
|
303
|
+
res[i] = get(item, "ssh")
|
|
304
|
+
i += 1
|
|
305
|
+
end
|
|
306
|
+
res = bubble(res)[-1]
|
|
307
|
+
rescue Exception => e
|
|
308
|
+
puts "Es ist ein Fehler aufgetreten: " + e.message
|
|
309
|
+
puts "Objekttyp: Hostgroup with services"
|
|
310
|
+
end
|
|
311
|
+
return res
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
public
|
|
315
|
+
#
|
|
316
|
+
#
|
|
317
|
+
# === Args:
|
|
318
|
+
# +labels+::
|
|
319
|
+
# the Labels [array]
|
|
320
|
+
# +values+::
|
|
321
|
+
# host- or service-states [array]
|
|
322
|
+
#
|
|
323
|
+
# === Description:
|
|
324
|
+
# Prepare the host- and service-states
|
|
325
|
+
#
|
|
326
|
+
# === Return:
|
|
327
|
+
# Returns a multidimensional array. Ready to push this to the dashboard [array]
|
|
328
|
+
#
|
|
329
|
+
def self.prepare(labels, values)
|
|
330
|
+
status = []
|
|
331
|
+
i = 0
|
|
332
|
+
values.each do |item|
|
|
333
|
+
item = case item
|
|
334
|
+
when 0 then "<i class='icon-ok'></i>"
|
|
335
|
+
when 1,2,3 then "<i class='icon-cog'></i>"
|
|
336
|
+
when 5 then "<i class='icon-warning-sign'></i>"
|
|
337
|
+
when 4 then "<i class='icon-question-sign'></i>"
|
|
338
|
+
when 6 then "<i class='icon-remove'></i>"
|
|
339
|
+
end
|
|
340
|
+
status[i] = {label: labels[i], value: item}
|
|
341
|
+
i +=1
|
|
342
|
+
end
|
|
343
|
+
totalstate = stateall(values)
|
|
344
|
+
status.push(totalstate)
|
|
345
|
+
return status
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
#
|
|
349
|
+
#
|
|
350
|
+
# === Args:
|
|
351
|
+
# +list+::
|
|
352
|
+
# The old tile [array]
|
|
353
|
+
# +label+::
|
|
354
|
+
# Label of the new value [string]
|
|
355
|
+
# +value+::
|
|
356
|
+
# The value with the state [array]
|
|
357
|
+
# +position+::
|
|
358
|
+
# Position at the tile [integer]
|
|
359
|
+
#
|
|
360
|
+
# === Description:
|
|
361
|
+
# Adds an object to a tile, which should not display by a icon
|
|
362
|
+
#
|
|
363
|
+
# === Return:
|
|
364
|
+
# Returns the new tile (already prepared) [array]
|
|
365
|
+
#
|
|
366
|
+
|
|
367
|
+
def self.raw(oldlist,lab,value)
|
|
368
|
+
if oldlist.length > 1
|
|
369
|
+
state_old = oldlist.delete(oldlist[-1])
|
|
370
|
+
new_list = oldlist
|
|
371
|
+
newstate = casestate(value[1],"s")
|
|
372
|
+
state_old_cb = convback(state_old)
|
|
373
|
+
gesstate = [state_old_cb.to_i, newstate.to_i]
|
|
374
|
+
gesstate = stateall(gesstate)
|
|
375
|
+
new_list.insert(-1, {label: lab, value: value[0]})
|
|
376
|
+
new_list << gesstate
|
|
377
|
+
elsif oldlist.length == 1
|
|
378
|
+
newstate = casestate(value[1],"s")
|
|
379
|
+
new_list = []
|
|
380
|
+
new_list.insert(-1, {label: lab, value: value[0]})
|
|
381
|
+
new_list << newstate
|
|
382
|
+
end
|
|
383
|
+
return new_list
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
#
|
|
387
|
+
#
|
|
388
|
+
# === Args:
|
|
389
|
+
# +name+::
|
|
390
|
+
# The name of the object [string]
|
|
391
|
+
# +type+::
|
|
392
|
+
# type of the object (service or host) [string]
|
|
393
|
+
# +group+::
|
|
394
|
+
# true, if the object is a host- or servicegroup [boolean]
|
|
395
|
+
# +etc+::
|
|
396
|
+
# additional object which schould be added to the group [array]
|
|
397
|
+
#
|
|
398
|
+
# === Description:
|
|
399
|
+
# Gets the host- and servicestate
|
|
400
|
+
#
|
|
401
|
+
# === Return:
|
|
402
|
+
# Returns the state of a host, service or a group
|
|
403
|
+
#
|
|
404
|
+
def self.getstate(name, type, group=false, etc=nil)
|
|
405
|
+
if group && type == "service"
|
|
406
|
+
res = groupservices(name)
|
|
407
|
+
elsif group
|
|
408
|
+
res = getgroup(name)
|
|
409
|
+
elsif type == "service"
|
|
410
|
+
res = get(name, "ssd")
|
|
411
|
+
elsif type == "servicehost"
|
|
412
|
+
res = get(name, "ssh")
|
|
413
|
+
elsif type == "host"
|
|
414
|
+
res = get(name, "hs")
|
|
415
|
+
end
|
|
416
|
+
return res
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
#
|
|
420
|
+
#
|
|
421
|
+
# === Args:
|
|
422
|
+
# +name+::
|
|
423
|
+
# The name of the service-object [string]
|
|
424
|
+
#
|
|
425
|
+
# === Description:
|
|
426
|
+
# Gets the perf_data of a service
|
|
427
|
+
#
|
|
428
|
+
# === Return:
|
|
429
|
+
# Return the perf_data
|
|
430
|
+
#
|
|
431
|
+
def self.getperfdata(name)
|
|
432
|
+
extname = []
|
|
433
|
+
begin
|
|
434
|
+
if name.index(":")
|
|
435
|
+
extname = name.split(":")
|
|
436
|
+
res = RTDI::IDSocket.request("services","state perf_data","display_name = #{extname[1]}","host_name = #{extname[0]}")
|
|
437
|
+
if res.length == 0
|
|
438
|
+
raise 'Das Objekt "' + extname[0] + '" mit dem Service "' + extname[1] + '" existiert nicht in Icinga!'
|
|
439
|
+
end
|
|
440
|
+
else
|
|
441
|
+
extname[1] = name
|
|
442
|
+
res = RTDI::IDSocket.request("services","state perf_data","display_name = #{extname[1]}")
|
|
443
|
+
if res.length == 0
|
|
444
|
+
raise 'Das Objekt "' + extname[1] + '" existiert nicht in Icinga!'
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
res = res.split(";")
|
|
448
|
+
state = res[0]
|
|
449
|
+
res = res[1].scan(/[=]([0-9]+[.,]?[0-9]+)/)
|
|
450
|
+
#res[0] = res[1].split(/[=]([0-9]+[.,]?[0-9]+)/)
|
|
451
|
+
res << state
|
|
452
|
+
rescue Exception => e
|
|
453
|
+
puts "Es ist ein Fehler aufgetreten: " + e.message
|
|
454
|
+
puts "Objekttyp: Service (perf_data)"
|
|
455
|
+
end
|
|
456
|
+
return res
|
|
457
|
+
end
|
|
458
|
+
def self.calcpue()
|
|
459
|
+
energymeter = RTDI::IDSocket.request("services","perf_data","display_name = energymeter_power")
|
|
460
|
+
pdu = RTDI::Status.gs("pdu_activepower","pdu_activepower")
|
|
461
|
+
pue = []
|
|
462
|
+
i = 0
|
|
463
|
+
pdu_strom = 0
|
|
464
|
+
pdu.each do |item|
|
|
465
|
+
if item.length != 1
|
|
466
|
+
pdu_strom += item.gsub!("ActivePower=","").to_i
|
|
467
|
+
i += 1
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
energymeter = energymeter.scan(/[=]([0-9]+[.,]?[0-9]+)/)[0][0]
|
|
471
|
+
pue[0] = (pdu_strom.to_f / energymeter.to_f).round 2
|
|
472
|
+
pue[1] = "0"
|
|
473
|
+
return pue
|
|
474
|
+
end
|
|
475
|
+
end
|
|
476
|
+
end
|