icinga2 0.6.2 → 0.6.3

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
  SHA1:
3
- metadata.gz: e5753bd46e4e8aac89bd4024561b64d812dee3b4
4
- data.tar.gz: 7503c21269a8652b174f28ba66e301a49aeccd95
3
+ metadata.gz: 36fd6f89ab9f69c033767b14de5cca6df6d2e53a
4
+ data.tar.gz: 2b89c7dcb2380bebf6d13a7fd8ab7c9984b8ab2e
5
5
  SHA512:
6
- metadata.gz: 77ca15fb7bbffb42c39d00cd2e3aabe346c0a4b04cc093d309833a7458777ffadf085bc54c35702d6990b4c4eedb78448dbeb2559a367645a26e93c266153651
7
- data.tar.gz: 16f7169211a1cf36e9ec3152aa91dd7d5fdb43f3945212289dc2939ddc6ca496aab131420ab5d06acc7f855058c07db9cdd3ebcde916ef1da8731e49aabf78d6
6
+ metadata.gz: fc2293409575e948d11a27f2d85e34ed7453105111e4cdae47fb7ab9bcb77d30a45d23b0b16e072d6ce6aa7d68cc5f025d5df4f849a94d8c1844d2295661d237
7
+ data.tar.gz: a8ef82c2e70f0a848a929ee38c4c19228b91fe25330dac91092f8f0e1b11adbd9a95092c5805d0051d5ff9e77a8fb574737af461713c248c8a00aeb9a1bd1dcc
data/doc/Icinga2.html CHANGED
@@ -112,6 +112,54 @@
112
112
  <h2>Constant Summary</h2>
113
113
  <dl class="constants">
114
114
 
115
+ <dt id="HANDLED_WARNING-constant" class="">HANDLED_WARNING =
116
+ <div class="docstring">
117
+ <div class="discussion">
118
+
119
+ <p>static variables for handled warning</p>
120
+
121
+
122
+ </div>
123
+ </div>
124
+ <div class="tags">
125
+
126
+
127
+ </div>
128
+ </dt>
129
+ <dd><pre class="code"><span class='int'>1</span></pre></dd>
130
+
131
+ <dt id="HANDLED_CRITICAL-constant" class="">HANDLED_CRITICAL =
132
+ <div class="docstring">
133
+ <div class="discussion">
134
+
135
+ <p>static variables for handled critical</p>
136
+
137
+
138
+ </div>
139
+ </div>
140
+ <div class="tags">
141
+
142
+
143
+ </div>
144
+ </dt>
145
+ <dd><pre class="code"><span class='int'>2</span></pre></dd>
146
+
147
+ <dt id="HANDLED_UNKNOWN-constant" class="">HANDLED_UNKNOWN =
148
+ <div class="docstring">
149
+ <div class="discussion">
150
+
151
+ <p>static variables for handled unknown</p>
152
+
153
+
154
+ </div>
155
+ </div>
156
+ <div class="tags">
157
+
158
+
159
+ </div>
160
+ </dt>
161
+ <dd><pre class="code"><span class='int'>3</span></pre></dd>
162
+
115
163
  <dt id="VERSION-constant" class="">VERSION =
116
164
  <div class="docstring">
117
165
  <div class="discussion">
@@ -141,7 +189,7 @@
141
189
  </div>
142
190
 
143
191
  <div id="footer">
144
- Generated on Sat Jun 17 14:00:30 2017 by
192
+ Generated on Sun Jun 18 15:20:36 2017 by
145
193
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
146
194
  0.9.9 (ruby-2.3.4).
147
195
  </div>
data/doc/Logging.html CHANGED
@@ -88,7 +88,19 @@
88
88
 
89
89
  </div>
90
90
 
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+
94
+ <p>taken from <a
95
+ href="https://stackoverflow.com/questions/917566/ruby-share-logger-instance-among-module-classes">stackoverflow.com/questions/917566/ruby-share-logger-instance-among-module-classes</a></p>
96
+
91
97
 
98
+ </div>
99
+ </div>
100
+ <div class="tags">
101
+
102
+
103
+ </div>
92
104
 
93
105
 
94
106
 
@@ -202,8 +214,6 @@
202
214
  <pre class="lines">
203
215
 
204
216
 
205
- 26
206
- 27
207
217
  28
208
218
  29
209
219
  30
@@ -213,10 +223,12 @@
213
223
  34
214
224
  35
215
225
  36
216
- 37</pre>
226
+ 37
227
+ 38
228
+ 39</pre>
217
229
  </td>
218
230
  <td>
219
- <pre class="code"><span class="info file"># File 'lib/logging.rb', line 26</span>
231
+ <pre class="code"><span class="info file"># File 'lib/logging.rb', line 28</span>
220
232
 
221
233
  <span class='kw'>def</span> <span class='id identifier rubyid_configure_logger_for'>configure_logger_for</span><span class='lparen'>(</span> <span class='id identifier rubyid_classname'>classname</span> <span class='rparen'>)</span>
222
234
 
@@ -250,12 +262,12 @@
250
262
  <pre class="lines">
251
263
 
252
264
 
253
- 22
254
- 23
255
- 24</pre>
265
+ 24
266
+ 25
267
+ 26</pre>
256
268
  </td>
257
269
  <td>
258
- <pre class="code"><span class="info file"># File 'lib/logging.rb', line 22</span>
270
+ <pre class="code"><span class="info file"># File 'lib/logging.rb', line 24</span>
259
271
 
260
272
  <span class='kw'>def</span> <span class='id identifier rubyid_logger_for'>logger_for</span><span class='lparen'>(</span> <span class='id identifier rubyid_classname'>classname</span> <span class='rparen'>)</span>
261
273
  <span class='ivar'>@loggers</span><span class='lbracket'>[</span><span class='id identifier rubyid_classname'>classname</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='id identifier rubyid_configure_logger_for'>configure_logger_for</span><span class='lparen'>(</span> <span class='id identifier rubyid_classname'>classname</span> <span class='rparen'>)</span>
@@ -286,12 +298,12 @@
286
298
  <pre class="lines">
287
299
 
288
300
 
289
- 11
290
- 12
291
- 13</pre>
301
+ 13
302
+ 14
303
+ 15</pre>
292
304
  </td>
293
305
  <td>
294
- <pre class="code"><span class="info file"># File 'lib/logging.rb', line 11</span>
306
+ <pre class="code"><span class="info file"># File 'lib/logging.rb', line 13</span>
295
307
 
296
308
  <span class='kw'>def</span> <span class='id identifier rubyid_logger'>logger</span>
297
309
  <span class='ivar'>@logger</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="" title="Logging (module)">Logging</a></span></span><span class='period'>.</span><span class='id identifier rubyid_logger_for'><span class='object_link'><a href="#logger_for-class_method" title="Logging.logger_for (method)">logger_for</a></span></span><span class='lparen'>(</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='rparen'>)</span>
@@ -306,7 +318,7 @@
306
318
  </div>
307
319
 
308
320
  <div id="footer">
309
- Generated on Sat Jun 17 14:00:30 2017 by
321
+ Generated on Sun Jun 18 15:20:36 2017 by
310
322
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
311
323
  0.9.9 (ruby-2.3.4).
312
324
  </div>
data/doc/_index.html CHANGED
@@ -275,7 +275,7 @@
275
275
  </div>
276
276
 
277
277
  <div id="footer">
278
- Generated on Sat Jun 17 14:00:30 2017 by
278
+ Generated on Sun Jun 18 15:20:36 2017 by
279
279
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
280
280
  0.9.9 (ruby-2.3.4).
281
281
  </div>
data/doc/file.README.html CHANGED
@@ -268,7 +268,7 @@ feature&#39;</code>)</p>
268
268
  </div></div>
269
269
 
270
270
  <div id="footer">
271
- Generated on Sat Jun 17 14:00:30 2017 by
271
+ Generated on Sun Jun 18 15:20:36 2017 by
272
272
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
273
273
  0.9.9 (ruby-2.3.4).
274
274
  </div>
data/doc/index.html CHANGED
@@ -268,7 +268,7 @@ feature&#39;</code>)</p>
268
268
  </div></div>
269
269
 
270
270
  <div id="footer">
271
- Generated on Sat Jun 17 14:00:30 2017 by
271
+ Generated on Sun Jun 18 15:20:36 2017 by
272
272
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
273
273
  0.9.9 (ruby-2.3.4).
274
274
  </div>
data/doc/method_list.html CHANGED
@@ -293,6 +293,14 @@
293
293
 
294
294
 
295
295
  <li class="even ">
296
+ <div class="item">
297
+ <span class='object_link'><a href="Icinga2/Status.html#extract_data-instance_method" title="Icinga2::Status#extract_data (method)">#extract_data</a></span>
298
+ <small>Icinga2::Status</small>
299
+ </div>
300
+ </li>
301
+
302
+
303
+ <li class="odd ">
296
304
  <div class="item">
297
305
  <span class='object_link'><a href="Icinga2/Converts.html#format_service-class_method" title="Icinga2::Converts.format_service (method)">format_service</a></span>
298
306
  <small>Icinga2::Converts</small>
@@ -300,7 +308,7 @@
300
308
  </li>
301
309
 
302
310
 
303
- <li class="odd ">
311
+ <li class="even ">
304
312
  <div class="item">
305
313
  <span class='object_link'><a href="Icinga2/Network.html#get-class_method" title="Icinga2::Network.get (method)">get</a></span>
306
314
  <small>Icinga2::Network</small>
@@ -308,7 +316,7 @@
308
316
  </li>
309
317
 
310
318
 
311
- <li class="even ">
319
+ <li class="odd ">
312
320
  <div class="item">
313
321
  <span class='object_link'><a href="Icinga2/Network.html#get_with_payload-class_method" title="Icinga2::Network.get_with_payload (method)">get_with_payload</a></span>
314
322
  <small>Icinga2::Network</small>
@@ -316,6 +324,14 @@
316
324
  </li>
317
325
 
318
326
 
327
+ <li class="even ">
328
+ <div class="item">
329
+ <span class='object_link'><a href="Icinga2/Tools.html#handled_problems-instance_method" title="Icinga2::Tools#handled_problems (method)">#handled_problems</a></span>
330
+ <small>Icinga2::Tools</small>
331
+ </div>
332
+ </li>
333
+
334
+
319
335
  <li class="odd ">
320
336
  <div class="item">
321
337
  <span class='object_link'><a href="Icinga2/Hosts.html#host_objects-instance_method" title="Icinga2::Hosts#host_objects (method)">#host_objects</a></span>
@@ -358,13 +374,117 @@
358
374
 
359
375
  <li class="even ">
360
376
  <div class="item">
361
- <span class='object_link'><a href="Icinga2/Client.html#initialize-instance_method" title="Icinga2::Client#initialize (method)">#initialize</a></span>
377
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_acknowledged-instance_method" title="Icinga2::Client#hosts_acknowledged (method)">#hosts_acknowledged</a></span>
378
+ <small>Icinga2::Client</small>
379
+ </div>
380
+ </li>
381
+
382
+
383
+ <li class="odd ">
384
+ <div class="item">
385
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_active_checks_1min-instance_method" title="Icinga2::Client#hosts_active_checks_1min (method)">#hosts_active_checks_1min</a></span>
386
+ <small>Icinga2::Client</small>
387
+ </div>
388
+ </li>
389
+
390
+
391
+ <li class="even ">
392
+ <div class="item">
393
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_all-instance_method" title="Icinga2::Client#hosts_all (method)">#hosts_all</a></span>
394
+ <small>Icinga2::Client</small>
395
+ </div>
396
+ </li>
397
+
398
+
399
+ <li class="odd ">
400
+ <div class="item">
401
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_down-instance_method" title="Icinga2::Client#hosts_down (method)">#hosts_down</a></span>
402
+ <small>Icinga2::Client</small>
403
+ </div>
404
+ </li>
405
+
406
+
407
+ <li class="even ">
408
+ <div class="item">
409
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_down_adjusted-instance_method" title="Icinga2::Client#hosts_down_adjusted (method)">#hosts_down_adjusted</a></span>
410
+ <small>Icinga2::Client</small>
411
+ </div>
412
+ </li>
413
+
414
+
415
+ <li class="odd ">
416
+ <div class="item">
417
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_handled_critical_problems-instance_method" title="Icinga2::Client#hosts_handled_critical_problems (method)">#hosts_handled_critical_problems</a></span>
418
+ <small>Icinga2::Client</small>
419
+ </div>
420
+ </li>
421
+
422
+
423
+ <li class="even ">
424
+ <div class="item">
425
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_handled_problems-instance_method" title="Icinga2::Client#hosts_handled_problems (method)">#hosts_handled_problems</a></span>
426
+ <small>Icinga2::Client</small>
427
+ </div>
428
+ </li>
429
+
430
+
431
+ <li class="odd ">
432
+ <div class="item">
433
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_handled_unknown_problems-instance_method" title="Icinga2::Client#hosts_handled_unknown_problems (method)">#hosts_handled_unknown_problems</a></span>
434
+ <small>Icinga2::Client</small>
435
+ </div>
436
+ </li>
437
+
438
+
439
+ <li class="even ">
440
+ <div class="item">
441
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_handled_warning_problems-instance_method" title="Icinga2::Client#hosts_handled_warning_problems (method)">#hosts_handled_warning_problems</a></span>
362
442
  <small>Icinga2::Client</small>
363
443
  </div>
364
444
  </li>
365
445
 
366
446
 
367
447
  <li class="odd ">
448
+ <div class="item">
449
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_in_downtime-instance_method" title="Icinga2::Client#hosts_in_downtime (method)">#hosts_in_downtime</a></span>
450
+ <small>Icinga2::Client</small>
451
+ </div>
452
+ </li>
453
+
454
+
455
+ <li class="even ">
456
+ <div class="item">
457
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_passive_checks_1min-instance_method" title="Icinga2::Client#hosts_passive_checks_1min (method)">#hosts_passive_checks_1min</a></span>
458
+ <small>Icinga2::Client</small>
459
+ </div>
460
+ </li>
461
+
462
+
463
+ <li class="odd ">
464
+ <div class="item">
465
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_problems-instance_method" title="Icinga2::Client#hosts_problems (method)">#hosts_problems</a></span>
466
+ <small>Icinga2::Client</small>
467
+ </div>
468
+ </li>
469
+
470
+
471
+ <li class="even ">
472
+ <div class="item">
473
+ <span class='object_link'><a href="Icinga2/Client.html#hosts_up-instance_method" title="Icinga2::Client#hosts_up (method)">#hosts_up</a></span>
474
+ <small>Icinga2::Client</small>
475
+ </div>
476
+ </li>
477
+
478
+
479
+ <li class="odd ">
480
+ <div class="item">
481
+ <span class='object_link'><a href="Icinga2/Client.html#initialize-instance_method" title="Icinga2::Client#initialize (method)">#initialize</a></span>
482
+ <small>Icinga2::Client</small>
483
+ </div>
484
+ </li>
485
+
486
+
487
+ <li class="even ">
368
488
  <div class="item">
369
489
  <span class='object_link'><a href="Logging.html#logger-instance_method" title="Logging#logger (method)">#logger</a></span>
370
490
  <small>Logging</small>
@@ -372,7 +492,7 @@
372
492
  </li>
373
493
 
374
494
 
375
- <li class="even ">
495
+ <li class="odd ">
376
496
  <div class="item">
377
497
  <span class='object_link'><a href="Logging.html#logger_for-class_method" title="Logging.logger_for (method)">logger_for</a></span>
378
498
  <small>Logging</small>
@@ -380,6 +500,14 @@
380
500
  </li>
381
501
 
382
502
 
503
+ <li class="even ">
504
+ <div class="item">
505
+ <span class='object_link'><a href="Icinga2/Client.html#node_name-instance_method" title="Icinga2::Client#node_name (method)">#node_name</a></span>
506
+ <small>Icinga2::Client</small>
507
+ </div>
508
+ </li>
509
+
510
+
383
511
  <li class="odd ">
384
512
  <div class="item">
385
513
  <span class='object_link'><a href="Icinga2/Notifications.html#notifications-instance_method" title="Icinga2::Notifications#notifications (method)">#notifications</a></span>
@@ -397,6 +525,14 @@
397
525
 
398
526
 
399
527
  <li class="odd ">
528
+ <div class="item">
529
+ <span class='object_link'><a href="Icinga2/Tools.html#parse_version-instance_method" title="Icinga2::Tools#parse_version (method)">#parse_version</a></span>
530
+ <small>Icinga2::Tools</small>
531
+ </div>
532
+ </li>
533
+
534
+
535
+ <li class="even ">
400
536
  <div class="item">
401
537
  <span class='object_link'><a href="Icinga2/Network.html#post-class_method" title="Icinga2::Network.post (method)">post</a></span>
402
538
  <small>Icinga2::Network</small>
@@ -404,7 +540,7 @@
404
540
  </li>
405
541
 
406
542
 
407
- <li class="even ">
543
+ <li class="odd ">
408
544
  <div class="item">
409
545
  <span class='object_link'><a href="Icinga2/Hosts.html#problem_hosts-instance_method" title="Icinga2::Hosts#problem_hosts (method)">#problem_hosts</a></span>
410
546
  <small>Icinga2::Hosts</small>
@@ -412,7 +548,7 @@
412
548
  </li>
413
549
 
414
550
 
415
- <li class="odd ">
551
+ <li class="even ">
416
552
  <div class="item">
417
553
  <span class='object_link'><a href="Icinga2/Services.html#problem_services-instance_method" title="Icinga2::Services#problem_services (method)">#problem_services</a></span>
418
554
  <small>Icinga2::Services</small>
@@ -420,7 +556,7 @@
420
556
  </li>
421
557
 
422
558
 
423
- <li class="even ">
559
+ <li class="odd ">
424
560
  <div class="item">
425
561
  <span class='object_link'><a href="Icinga2/Network.html#put-class_method" title="Icinga2::Network.put (method)">put</a></span>
426
562
  <small>Icinga2::Network</small>
@@ -428,6 +564,14 @@
428
564
  </li>
429
565
 
430
566
 
567
+ <li class="even ">
568
+ <div class="item">
569
+ <span class='object_link'><a href="Icinga2/Client.html#revision-instance_method" title="Icinga2::Client#revision (method)">#revision</a></span>
570
+ <small>Icinga2::Client</small>
571
+ </div>
572
+ </li>
573
+
574
+
431
575
  <li class="odd ">
432
576
  <div class="item">
433
577
  <span class='object_link'><a href="Icinga2/Services.html#service_objects-instance_method" title="Icinga2::Services#service_objects (method)">#service_objects</a></span>
@@ -469,6 +613,142 @@
469
613
 
470
614
 
471
615
  <li class="even ">
616
+ <div class="item">
617
+ <span class='object_link'><a href="Icinga2/Client.html#services_acknowledged-instance_method" title="Icinga2::Client#services_acknowledged (method)">#services_acknowledged</a></span>
618
+ <small>Icinga2::Client</small>
619
+ </div>
620
+ </li>
621
+
622
+
623
+ <li class="odd ">
624
+ <div class="item">
625
+ <span class='object_link'><a href="Icinga2/Client.html#services_active_checks_1min-instance_method" title="Icinga2::Client#services_active_checks_1min (method)">#services_active_checks_1min</a></span>
626
+ <small>Icinga2::Client</small>
627
+ </div>
628
+ </li>
629
+
630
+
631
+ <li class="even ">
632
+ <div class="item">
633
+ <span class='object_link'><a href="Icinga2/Client.html#services_all-instance_method" title="Icinga2::Client#services_all (method)">#services_all</a></span>
634
+ <small>Icinga2::Client</small>
635
+ </div>
636
+ </li>
637
+
638
+
639
+ <li class="odd ">
640
+ <div class="item">
641
+ <span class='object_link'><a href="Icinga2/Client.html#services_critical-instance_method" title="Icinga2::Client#services_critical (method)">#services_critical</a></span>
642
+ <small>Icinga2::Client</small>
643
+ </div>
644
+ </li>
645
+
646
+
647
+ <li class="even ">
648
+ <div class="item">
649
+ <span class='object_link'><a href="Icinga2/Client.html#services_critical_adjusted-instance_method" title="Icinga2::Client#services_critical_adjusted (method)">#services_critical_adjusted</a></span>
650
+ <small>Icinga2::Client</small>
651
+ </div>
652
+ </li>
653
+
654
+
655
+ <li class="odd ">
656
+ <div class="item">
657
+ <span class='object_link'><a href="Icinga2/Client.html#services_handled_critical_problems-instance_method" title="Icinga2::Client#services_handled_critical_problems (method)">#services_handled_critical_problems</a></span>
658
+ <small>Icinga2::Client</small>
659
+ </div>
660
+ </li>
661
+
662
+
663
+ <li class="even ">
664
+ <div class="item">
665
+ <span class='object_link'><a href="Icinga2/Client.html#services_handled_unknown_problems-instance_method" title="Icinga2::Client#services_handled_unknown_problems (method)">#services_handled_unknown_problems</a></span>
666
+ <small>Icinga2::Client</small>
667
+ </div>
668
+ </li>
669
+
670
+
671
+ <li class="odd ">
672
+ <div class="item">
673
+ <span class='object_link'><a href="Icinga2/Client.html#services_handled_warning_problems-instance_method" title="Icinga2::Client#services_handled_warning_problems (method)">#services_handled_warning_problems</a></span>
674
+ <small>Icinga2::Client</small>
675
+ </div>
676
+ </li>
677
+
678
+
679
+ <li class="even ">
680
+ <div class="item">
681
+ <span class='object_link'><a href="Icinga2/Client.html#services_in_downtime-instance_method" title="Icinga2::Client#services_in_downtime (method)">#services_in_downtime</a></span>
682
+ <small>Icinga2::Client</small>
683
+ </div>
684
+ </li>
685
+
686
+
687
+ <li class="odd ">
688
+ <div class="item">
689
+ <span class='object_link'><a href="Icinga2/Client.html#services_ok-instance_method" title="Icinga2::Client#services_ok (method)">#services_ok</a></span>
690
+ <small>Icinga2::Client</small>
691
+ </div>
692
+ </li>
693
+
694
+
695
+ <li class="even ">
696
+ <div class="item">
697
+ <span class='object_link'><a href="Icinga2/Client.html#services_passive_checks_1min-instance_method" title="Icinga2::Client#services_passive_checks_1min (method)">#services_passive_checks_1min</a></span>
698
+ <small>Icinga2::Client</small>
699
+ </div>
700
+ </li>
701
+
702
+
703
+ <li class="odd ">
704
+ <div class="item">
705
+ <span class='object_link'><a href="Icinga2/Client.html#services_problems-instance_method" title="Icinga2::Client#services_problems (method)">#services_problems</a></span>
706
+ <small>Icinga2::Client</small>
707
+ </div>
708
+ </li>
709
+
710
+
711
+ <li class="even ">
712
+ <div class="item">
713
+ <span class='object_link'><a href="Icinga2/Client.html#services_unknown-instance_method" title="Icinga2::Client#services_unknown (method)">#services_unknown</a></span>
714
+ <small>Icinga2::Client</small>
715
+ </div>
716
+ </li>
717
+
718
+
719
+ <li class="odd ">
720
+ <div class="item">
721
+ <span class='object_link'><a href="Icinga2/Client.html#services_unknown_adjusted-instance_method" title="Icinga2::Client#services_unknown_adjusted (method)">#services_unknown_adjusted</a></span>
722
+ <small>Icinga2::Client</small>
723
+ </div>
724
+ </li>
725
+
726
+
727
+ <li class="even ">
728
+ <div class="item">
729
+ <span class='object_link'><a href="Icinga2/Client.html#services_warning-instance_method" title="Icinga2::Client#services_warning (method)">#services_warning</a></span>
730
+ <small>Icinga2::Client</small>
731
+ </div>
732
+ </li>
733
+
734
+
735
+ <li class="odd ">
736
+ <div class="item">
737
+ <span class='object_link'><a href="Icinga2/Client.html#services_warning_adjusted-instance_method" title="Icinga2::Client#services_warning_adjusted (method)">#services_warning_adjusted</a></span>
738
+ <small>Icinga2::Client</small>
739
+ </div>
740
+ </li>
741
+
742
+
743
+ <li class="even ">
744
+ <div class="item">
745
+ <span class='object_link'><a href="Icinga2/Client.html#start_time-instance_method" title="Icinga2::Client#start_time (method)">#start_time</a></span>
746
+ <small>Icinga2::Client</small>
747
+ </div>
748
+ </li>
749
+
750
+
751
+ <li class="odd ">
472
752
  <div class="item">
473
753
  <span class='object_link'><a href="Icinga2/Converts.html#state_to_color-class_method" title="Icinga2::Converts.state_to_color (method)">state_to_color</a></span>
474
754
  <small>Icinga2::Converts</small>
@@ -476,7 +756,7 @@
476
756
  </li>
477
757
 
478
758
 
479
- <li class="odd ">
759
+ <li class="even ">
480
760
  <div class="item">
481
761
  <span class='object_link'><a href="Icinga2/Converts.html#state_to_string-class_method" title="Icinga2::Converts.state_to_string (method)">state_to_string</a></span>
482
762
  <small>Icinga2::Converts</small>
@@ -484,7 +764,7 @@
484
764
  </li>
485
765
 
486
766
 
487
- <li class="even ">
767
+ <li class="odd ">
488
768
  <div class="item">
489
769
  <span class='object_link'><a href="Icinga2/Services.html#unhandled_services-instance_method" title="Icinga2::Services#unhandled_services (method)">#unhandled_services</a></span>
490
770
  <small>Icinga2::Services</small>
@@ -492,7 +772,7 @@
492
772
  </li>
493
773
 
494
774
 
495
- <li class="odd ">
775
+ <li class="even ">
496
776
  <div class="item">
497
777
  <span class='object_link'><a href="Icinga2/Services.html#update_host-instance_method" title="Icinga2::Services#update_host (method)">#update_host</a></span>
498
778
  <small>Icinga2::Services</small>
@@ -500,6 +780,14 @@
500
780
  </li>
501
781
 
502
782
 
783
+ <li class="odd ">
784
+ <div class="item">
785
+ <span class='object_link'><a href="Icinga2/Client.html#uptime-instance_method" title="Icinga2::Client#uptime (method)">#uptime</a></span>
786
+ <small>Icinga2::Client</small>
787
+ </div>
788
+ </li>
789
+
790
+
503
791
  <li class="even ">
504
792
  <div class="item">
505
793
  <span class='object_link'><a href="Icinga2/Usergroups.html#usergroups-instance_method" title="Icinga2::Usergroups#usergroups (method)">#usergroups</a></span>
@@ -516,6 +804,14 @@
516
804
  </li>
517
805
 
518
806
 
807
+ <li class="even ">
808
+ <div class="item">
809
+ <span class='object_link'><a href="Icinga2/Client.html#version-instance_method" title="Icinga2::Client#version (method)">#version</a></span>
810
+ <small>Icinga2::Client</small>
811
+ </div>
812
+ </li>
813
+
814
+
519
815
 
520
816
  </ul>
521
817
  </div>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Sat Jun 17 14:00:30 2017 by
103
+ Generated on Sun Jun 18 15:20:36 2017 by
104
104
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.9 (ruby-2.3.4).
106
106
  </div>
data/examples/test.rb CHANGED
@@ -41,152 +41,174 @@ i = Icinga2::Client.new( config )
41
41
 
42
42
  unless( i.nil? )
43
43
 
44
- # run tests ...
45
- #
46
- #
47
-
48
- puts 'Information about Icinga2'
49
- puts i.application_data
50
- puts ''
51
- puts 'CIB'
52
- puts i.cib_data
53
- puts ''
54
- puts 'API Listener'
55
- puts i.api_listener
56
- puts ''
57
-
58
- puts 'check if Host \'icinga2\' exists'
59
- puts i.exists_host?( 'icinga2' ) ? 'true' : 'false'
60
- puts ''
61
- puts 'get host Objects'
62
- puts i.host_objects
63
- puts ''
64
- puts 'Host problems'
65
- puts i.host_problems
66
- puts ''
67
- puts 'Problem Hosts'
68
- puts i.problem_hosts
69
- puts ''
70
- puts 'list named Hosts'
71
- puts i.hosts( host: 'icinga2' )
72
- puts i.hosts( host: 'bp-cluster')
73
- puts ''
74
- puts 'list all Hosts'
75
- puts i.hosts
76
- puts ''
77
-
78
- puts 'check if Hostgroup \'linux-servers\' exists'
79
- puts i.exists_hostgroup?( 'linux-servers' ) ? 'true' : 'false'
80
- puts ''
81
- puts 'add hostgroup \'foo\''
82
- puts i.add_hostgroup( host_group: 'foo', display_name: 'FOO' )
83
- puts ''
84
- puts 'list named Hostgroup \'foo\''
85
- puts i.hostgroups( host_group: 'foo' )
86
- puts ''
87
- puts 'list all Hostgroups'
88
- puts i.hostgroups
89
- puts ''
90
- puts 'delete Hostgroup \'foo\''
91
- puts i.delete_hostgroup( host_group: 'foo' )
92
- puts ''
93
-
94
- puts 'check if service \'users\' on host \'icinga2\' exists'
95
- puts i.exists_service?( host: 'icinga2', service: 'users' ) ? 'true' : 'false'
96
- puts ''
97
- puts 'get service Objects'
98
- puts i.service_objects
99
- puts ''
100
- puts 'Service problems'
101
- puts i.service_problems
102
- puts ''
103
- puts 'Problem Services'
104
- puts i.problem_services
105
- puts ''
106
- puts i.problem_services(10)
107
- puts ''
108
- puts 'list named Service \'ping4\' from Host \'icinga2\''
109
- puts i.services( host: 'icinga2', service: 'ping4' )
110
- puts ''
111
- puts 'list all Services'
112
- puts i.services
113
- puts ''
114
-
115
- puts 'check if Servicegroup \'disk\' exists'
116
- puts i.exists_servicegroup?( 'disk' ) ? 'true' : 'false'
117
- puts ''
118
- puts 'add Servicegroup \'foo\''
119
- puts i.add_servicegroup( name: 'foo', display_name: 'FOO' )
120
- puts ''
121
- puts 'list named Servicegroup \'foo\''
122
- puts i.servicegroups( name: 'foo' )
123
- puts ''
124
- puts 'list all Servicegroup'
125
- puts i.servicegroups
126
- puts ''
127
- puts 'delete Servicegroup \'foo\''
128
- puts i.delete_servicegroup( name: 'foo' )
129
- puts ''
130
-
131
- puts 'check if Usergroup \'icingaadmins\' exists'
132
- puts i.exists_usergroup?( 'icingaadmins' ) ? 'true' : 'false'
133
- puts ''
134
- puts 'add Usergroup \'foo\''
135
- puts i.add_usergroup( name: 'foo', display_name: 'FOO' )
136
- puts ''
137
- puts 'list named Usergroup \'foo\''
138
- puts i.usergroups( name: 'foo' )
139
- puts ''
140
- puts 'list all Usergroup'
141
- puts i.usergroups
142
- puts ''
143
- puts 'delete Usergroup \'foo\''
144
- puts i.delete_usergroup( name: 'foo' )
145
- puts ''
146
-
147
- puts 'check if User \'icingaadmin\' exists'
148
- puts i.exists_user?( 'icingaadmin' ) ? 'true' : 'false'
149
- puts ''
150
- puts 'add User \'foo\''
151
- puts i.add_user( name: 'foo', display_name: 'FOO', email: 'foo@bar.com', pager: '0000', groups: ['icingaadmins'] )
152
- puts ''
153
- puts 'list named User \'icingaadmin\''
154
- puts i.users name: 'icingaadmin'
155
- puts ''
156
- puts 'list all User'
157
- puts i.users
158
- puts ''
159
- puts 'delete User \'foo\''
160
- puts i.delete_user( name: 'foo' )
161
- puts ''
162
-
163
- puts 'add Downtime \'test\''
164
- puts i.add_downtime( name: 'test', type: 'service', host: 'icinga2', comment: 'test downtime', author: 'icingaadmin', start_time: Time.now.to_i, end_time: Time.now.to_i + 20 )
165
- puts ''
166
- puts 'list all Downtimes'
167
- puts i.downtimes
168
- puts ''
169
- puts 'list all Notifications'
170
- puts i.notifications
171
- puts ''
172
- puts 'enable Notifications for host'
173
- puts i.enable_host_notification( 'icinga2' )
174
- puts ''
175
- puts 'disable Notifications for host'
176
- puts i.disable_host_notification( 'icinga2' )
177
- puts ''
178
- puts 'enable Notifications for host and services'
179
- puts i.enable_service_notification('icinga2')
180
- puts ''
181
- puts 'disable Notifications for host and services'
182
- puts i.disable_service_notification( 'icinga2' )
183
- puts ''
184
- puts 'enable Notifications for hostgroup'
185
- puts i.enable_hostgroup_notification( host: 'icinga2', host_group: 'linux-servers')
186
- puts ''
187
- puts 'disable Notifications for hostgroup'
188
- puts i.disable_hostgroup_notification( host: 'icinga2', host_group: 'linux-servers')
189
- puts ''
44
+ # run tests ...
45
+ #
46
+ #
47
+
48
+ puts 'Information about Icinga2'
49
+ puts i.application_data
50
+ puts ''
51
+ puts 'CIB'
52
+ puts i.cib_data
53
+ puts ''
54
+ puts 'API Listener'
55
+ puts i.api_listener
56
+ puts ''
57
+
58
+ puts format( 'version: %s, revision %s', i.version, i.revision )
59
+ puts format( 'start time: %s', i.start_time )
60
+ puts format( 'uptime: %s', i.uptime )
61
+ puts ''
62
+ puts format( 'all hosts: %d', i.hosts_all )
63
+ puts format( 'host down %d', i.hosts_down )
64
+ puts format( 'hosts handled warning problems: %d', i.hosts_handled_warning_problems )
65
+ puts format( 'hosts handled critical problems: %d', i.hosts_handled_critical_problems )
66
+ puts format( 'hosts handled unknown problems: %d', i.hosts_handled_unknown_problems )
67
+ puts ''
68
+ puts format( 'all services: %d', i.services_all )
69
+ puts format( 'services critical %d', i.services_critical)
70
+ puts format( 'services warning %d', i.services_warning)
71
+ puts format( 'services unknown %d', i.services_unknown)
72
+ puts format( 'services handled warning problems %d', i.services_handled_warning_problems)
73
+ puts format( 'services handled critical problems %d', i.services_handled_critical_problems)
74
+ puts format( 'services handled unknown problems %d', i.services_handled_unknown_problems)
75
+ puts format( 'services adjusted critical %d', i.services_critical_adjusted)
76
+ puts format( 'services adjusted warning %d', i.services_warning_adjusted)
77
+ puts format( 'services adjusted unknown %d', i.services_unknown_adjusted)
78
+ puts ''
79
+
80
+ puts 'check if Host \'icinga2\' exists'
81
+ puts i.exists_host?( 'icinga2' ) ? 'true' : 'false'
82
+ puts ''
83
+ puts 'get host Objects'
84
+ puts i.hosts_objects
85
+ puts ''
86
+ puts 'Host problems'
87
+ puts i.hosts_problems
88
+ puts ''
89
+ puts 'Problem Hosts'
90
+ puts i.problem_hosts
91
+ puts ''
92
+ puts 'list named Hosts'
93
+ puts i.hosts( host: 'icinga2' )
94
+ puts i.hosts( host: 'bp-cluster')
95
+ puts ''
96
+ puts 'list all Hosts'
97
+ puts i.hosts
98
+ puts ''
99
+
100
+ puts 'check if Hostgroup \'linux-servers\' exists'
101
+ puts i.exists_hostgroup?( 'linux-servers' ) ? 'true' : 'false'
102
+ puts ''
103
+ puts 'add hostgroup \'foo\''
104
+ puts i.add_hostgroup( hosts_group: 'foo', display_name: 'FOO' )
105
+ puts ''
106
+ puts 'list named Hostgroup \'foo\''
107
+ puts i.hostgroups( hosts_group: 'foo' )
108
+ puts ''
109
+ puts 'list all Hostgroups'
110
+ puts i.hostgroups
111
+ puts ''
112
+ puts 'delete Hostgroup \'foo\''
113
+ puts i.delete_hostgroup( hosts_group: 'foo' )
114
+ puts ''
115
+
116
+ puts 'check if service \'users\' on host \'icinga2\' exists'
117
+ puts i.exists_service?( host: 'icinga2', service: 'users' ) ? 'true' : 'false'
118
+ puts ''
119
+ puts 'get service Objects'
120
+ puts i.services_objects
121
+ puts ''
122
+ puts 'Service problems'
123
+ puts i.services_problems
124
+ puts ''
125
+ puts 'Problem Services'
126
+ puts i.problem_services
127
+ puts ''
128
+ puts i.problem_services(10)
129
+ puts ''
130
+ puts 'list named Service \'ping4\' from Host \'icinga2\''
131
+ puts i.services( host: 'icinga2', service: 'ping4' )
132
+ puts ''
133
+ puts 'list all Services'
134
+ puts i.services
135
+ puts ''
136
+
137
+ puts 'check if Servicegroup \'disk\' exists'
138
+ puts i.exists_servicegroup?( 'disk' ) ? 'true' : 'false'
139
+ puts ''
140
+ puts 'add Servicegroup \'foo\''
141
+ puts i.add_servicegroup( name: 'foo', display_name: 'FOO' )
142
+ puts ''
143
+ puts 'list named Servicegroup \'foo\''
144
+ puts i.servicegroups( name: 'foo' )
145
+ puts ''
146
+ puts 'list all Servicegroup'
147
+ puts i.servicegroups
148
+ puts ''
149
+ puts 'delete Servicegroup \'foo\''
150
+ puts i.delete_servicegroup( name: 'foo' )
151
+ puts ''
152
+
153
+ puts 'check if Usergroup \'icingaadmins\' exists'
154
+ puts i.exists_usergroup?( 'icingaadmins' ) ? 'true' : 'false'
155
+ puts ''
156
+ puts 'add Usergroup \'foo\''
157
+ puts i.add_usergroup( name: 'foo', display_name: 'FOO' )
158
+ puts ''
159
+ puts 'list named Usergroup \'foo\''
160
+ puts i.usergroups( name: 'foo' )
161
+ puts ''
162
+ puts 'list all Usergroup'
163
+ puts i.usergroups
164
+ puts ''
165
+ puts 'delete Usergroup \'foo\''
166
+ puts i.delete_usergroup( name: 'foo' )
167
+ puts ''
168
+
169
+ puts 'check if User \'icingaadmin\' exists'
170
+ puts i.exists_user?( 'icingaadmin' ) ? 'true' : 'false'
171
+ puts ''
172
+ puts 'add User \'foo\''
173
+ puts i.add_user( name: 'foo', display_name: 'FOO', email: 'foo@bar.com', pager: '0000', groups: ['icingaadmins'] )
174
+ puts ''
175
+ puts 'list named User \'icingaadmin\''
176
+ puts i.users name: 'icingaadmin'
177
+ puts ''
178
+ puts 'list all User'
179
+ puts i.users
180
+ puts ''
181
+ puts 'delete User \'foo\''
182
+ puts i.delete_user( name: 'foo' )
183
+ puts ''
184
+
185
+ puts 'add Downtime \'test\''
186
+ puts i.add_downtime( name: 'test', type: 'service', host: 'icinga2', comment: 'test downtime', author: 'icingaadmin', start_time: Time.now.to_i, end_time: Time.now.to_i + 20 )
187
+ puts ''
188
+ puts 'list all Downtimes'
189
+ puts i.downtimes
190
+ puts ''
191
+ puts 'list all Notifications'
192
+ puts i.notifications
193
+ puts ''
194
+ puts 'enable Notifications for host'
195
+ puts i.enable_hosts_notification( 'icinga2' )
196
+ puts ''
197
+ puts 'disable Notifications for host'
198
+ puts i.disable_hosts_notification( 'icinga2' )
199
+ puts ''
200
+ puts 'enable Notifications for host and services'
201
+ puts i.enable_services_notification('icinga2')
202
+ puts ''
203
+ puts 'disable Notifications for host and services'
204
+ puts i.disable_services_notification( 'icinga2' )
205
+ puts ''
206
+ puts 'enable Notifications for hostgroup'
207
+ puts i.enable_hostgroup_notification( host: 'icinga2', hosts_group: 'linux-servers')
208
+ puts ''
209
+ puts 'disable Notifications for hostgroup'
210
+ puts i.disable_hostgroup_notification( host: 'icinga2', hosts_group: 'linux-servers')
211
+ puts ''
190
212
 
191
213
  end
192
214
 
data/lib/icinga2.rb CHANGED
@@ -31,6 +31,13 @@ require_relative 'icinga2/usergroups'
31
31
  # Namespace for classes and modules that handle all Icinga2 API calls
32
32
  module Icinga2
33
33
 
34
+ # static variables for handled warning
35
+ HANDLED_WARNING = 1
36
+ # static variables for handled critical
37
+ HANDLED_CRITICAL = 2
38
+ # static variables for handled unknown
39
+ HANDLED_UNKNOWN = 3
40
+
34
41
  # Abstract base class for the API calls.
35
42
  # Provides some helper methods
36
43
  #
@@ -38,6 +45,18 @@ module Icinga2
38
45
  #
39
46
  class Client
40
47
 
48
+ attr_reader :version, :revision, :node_name, :start_time, :uptime
49
+ attr_reader :hosts_up, :hosts_down, :hosts_in_downtime, :hosts_acknowledged
50
+ attr_reader :hosts_all, :hosts_problems, :hosts_handled_warning_problems, :hosts_handled_critical_problems, :hosts_handled_unknown_problems
51
+ attr_reader :hosts_handled_problems, :hosts_down_adjusted
52
+
53
+ attr_reader :services_ok, :services_warning, :services_critical, :services_unknown, :services_in_downtime, :services_acknowledged
54
+ attr_reader :services_all, :services_problems, :services_handled_warning_problems, :services_handled_critical_problems, :services_handled_unknown_problems
55
+ attr_reader :services_warning_adjusted, :services_critical_adjusted, :services_unknown_adjusted
56
+ attr_reader :hosts_active_checks_1min, :hosts_passive_checks_1min, :services_active_checks_1min, :services_passive_checks_1min
57
+
58
+
59
+
41
60
  include Logging
42
61
 
43
62
  include Icinga2::Version
@@ -98,6 +117,20 @@ module Icinga2
98
117
  @has_cert = cert?( user: @icinga_api_user, password: @icinga_api_pass )
99
118
  @headers = { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }
100
119
 
120
+
121
+ @version = @revision = 0
122
+ @node_name = @start_time = @uptime = ''
123
+ @avg_latency = @avg_execution_time = 0
124
+ @hosts_up = @hosts_down = @hosts_in_downtime = @hosts_acknowledged = 0
125
+ @hosts_all = @hosts_problems = @hosts_handled_warning_problems = @hosts_handled_critical_problems = @hosts_handled_unknown_problems = 0
126
+ @hosts_handled_problems = @hosts_down_adjusted = 0
127
+ @services_ok = @services_warning = @services_critical = @services_unknown = @services_in_downtime = @services_acknowledged = 0
128
+ @services_all = @services_problems = @services_handled_warning_problems = @services_handled_critical_problems = @services_handled_unknown_problems = 0
129
+ @services_warning_adjusted = @services_critical_adjusted = @services_unknown_adjusted = 0
130
+ @hosts_active_checks_1min = @hosts_passive_checks_1min = @services_active_checks_1min = @services_passive_checks_1min = 0
131
+
132
+ extract_data
133
+
101
134
  self
102
135
  end
103
136
 
@@ -128,7 +128,7 @@ module Icinga2
128
128
  'filter' => filter
129
129
  }
130
130
 
131
- result = Network.post( host: name,
131
+ Network.post( host: name,
132
132
  url: format( '%s/v1/actions/schedule-downtime', @icinga_api_url_base ),
133
133
  headers: @headers,
134
134
  options: @options,
@@ -162,14 +162,11 @@ module Icinga2
162
162
 
163
163
  host = params.dig(:host)
164
164
 
165
- result = Network.get( host: host,
165
+ Network.get( host: host,
166
166
  url: format( '%s/v1/objects/downtimes/%s', @icinga_api_url_base, host ),
167
167
  headers: @headers,
168
168
  options: @options )
169
169
 
170
- JSON.pretty_generate( result )
171
-
172
-
173
170
  end
174
171
 
175
172
  end
@@ -54,5 +54,98 @@ module Icinga2
54
54
 
55
55
  end
56
56
 
57
+ # extract many datas from application_data and cib_data
58
+ # and store them in global variables
59
+ #
60
+ def extract_data
61
+
62
+ a_data = application_data
63
+
64
+ if( a_data.is_a?(Hash) )
65
+
66
+ a_data = a_data.dig('status','icingaapplication','app')
67
+
68
+ if( !a_data.nil? )
69
+
70
+ # extract
71
+ # - version
72
+ @version, @revision = parse_version(a_data.dig('version'))
73
+
74
+ # - node_name
75
+ @node_name = a_data.dig('node_name')
76
+
77
+ # - start_time
78
+ @start_time = Time.at(a_data.dig('program_start').to_f)
79
+ end
80
+ end
81
+
82
+ c_data = cib_data
83
+
84
+ if( c_data.is_a?(Hash) )
85
+
86
+ c_data = c_data.dig('status')
87
+
88
+ if( !c_data.nil? )
89
+
90
+ # extract
91
+ # - uptime
92
+ uptime = c_data.dig('uptime').round(2)
93
+ @uptime = Time.at(uptime).utc.strftime('%H:%M:%S')
94
+
95
+ # - avg_latency / avg_execution_time
96
+ @avg_latency = c_data.dig('avg_latency').round(2)
97
+ @avg_execution_time = c_data.dig('avg_execution_time').round(2)
98
+
99
+ # - hosts
100
+ @hosts_up = c_data.dig('num_hosts_up').to_i
101
+ @hosts_down = c_data.dig('num_hosts_down').to_i
102
+ @hosts_in_downtime = c_data.dig('num_hosts_in_downtime').to_i
103
+ @hosts_acknowledged = c_data.dig('num_hosts_acknowledged').to_i
104
+
105
+ h_objects = host_objects
106
+ all_hosts = h_objects.dig(:nodes)
107
+
108
+ @hosts_all = all_hosts.size
109
+ @hosts_problems = host_problems
110
+ @hosts_handled_warning_problems = handled_problems(all_hosts, Icinga2::HANDLED_WARNING)
111
+ @hosts_handled_critical_problems = handled_problems(all_hosts, Icinga2::HANDLED_CRITICAL)
112
+ @hosts_handled_unknown_problems = handled_problems(all_hosts, Icinga2::HANDLED_UNKNOWN)
113
+
114
+ # calculate host problems adjusted by handled problems
115
+ # count togther handled host problems
116
+ @hosts_handled_problems = @hosts_handled_warning_problems + @hosts_handled_critical_problems + @hosts_handled_unknown_problems
117
+ @hosts_down_adjusted = @hosts_down - @hosts_handled_problems
118
+
119
+ # - services
120
+ @services_ok = c_data.dig('num_services_ok').to_i
121
+ @services_warning = c_data.dig('num_services_warning').to_i
122
+ @services_critical = c_data.dig('num_services_critical').to_i
123
+ @services_unknown = c_data.dig('num_services_unknown').to_i
124
+ @services_in_downtime = c_data.dig('num_services_in_downtime').to_i
125
+ @services_acknowledged = c_data.dig('num_services_acknowledged').to_i
126
+
127
+ s_objects = service_objects
128
+ all_services = s_objects.dig(:nodes)
129
+
130
+ @services_all = all_services.size
131
+ @services_problems = service_problems
132
+ @services_handled_warning_problems = handled_problems(all_services, Icinga2::HANDLED_WARNING)
133
+ @services_handled_critical_problems = handled_problems(all_services, Icinga2::HANDLED_CRITICAL)
134
+ @services_handled_unknown_problems = handled_problems(all_services, Icinga2::HANDLED_UNKNOWN)
135
+
136
+ # calculate service problems adjusted by handled problems
137
+ @services_warning_adjusted = @services_warning - @services_handled_warning_problems
138
+ @services_critical_adjusted = @services_critical - @services_handled_critical_problems
139
+ @services_unknown_adjusted = @services_unknown - @services_handled_unknown_problems
140
+
141
+
142
+ # - check stats
143
+ @hosts_active_checks_1min = c_data.dig('active_host_checks_1min')
144
+ @hosts_passive_checks_1min = c_data.dig('passive_host_checks_1min')
145
+ @services_active_checks_1min = c_data.dig('active_service_checks_1min')
146
+ @services_passive_checks_1min = c_data.dig('passive_service_checks_1min')
147
+ end
148
+ end
149
+ end
57
150
  end
58
151
  end
data/lib/icinga2/tools.rb CHANGED
@@ -17,5 +17,77 @@ module Icinga2
17
17
  object.dig('attrs', 'last_check').positive?
18
18
  end
19
19
 
20
+ # parse version string and extract version and revision
21
+ #
22
+ # @param [String] version
23
+ #
24
+ # @return [String, String]
25
+ #
26
+ def parse_version(version)
27
+
28
+ # version = "v2.4.10-504-gab4ba18"
29
+ # version = "v2.4.10"
30
+ version_map = version.split('-', 2)
31
+ version_str = version_map.first
32
+ # strip v2.4.10 (default) and r2.4.10 (Debian)
33
+ version_str = version_str.scan(/^[vr]+(.*)/).last.first
34
+
35
+ revision =
36
+ if version_map.size > 1
37
+ version_map.last
38
+ else
39
+ 'release'
40
+ end
41
+
42
+ [version_str, revision]
43
+ end
44
+
45
+
46
+ # return count of handled problems
47
+ #
48
+ # @param [Hash] objects
49
+ # @param [Integer] status
50
+ #
51
+ # @example for host objects
52
+ # h_objects = @icinga.host_objects
53
+ # all_hosts = h_objects.dig(:nodes)
54
+ # warning = @icinga.handled_problems(all_hosts, Icinga2::HANDLED_WARNING)
55
+ # critical = @icinga.handled_problems(all_hosts, Icinga2::HANDLED_CRITICAL)
56
+ # unknown = @icinga.handled_problems(all_hosts, Icinga2::HANDLED_UNKNOWN)
57
+ #
58
+ # @example for service objects
59
+ # s_objects = @icinga.service_objects
60
+ # all_services = s_objects.dig(:nodes)
61
+ # warning = @icinga.handled_problems(all_services, Icinga2::HANDLED_WARNING)
62
+ # critical = @icinga.handled_problems(all_services, Icinga2::HANDLED_CRITICAL)
63
+ # unknown = @icinga.handled_problems(all_services, Icinga2::HANDLED_UNKNOWN)
64
+ #
65
+ # @return [Integer]
66
+ #
67
+ def handled_problems(objects, status)
68
+
69
+ problems = 0
70
+
71
+ objects = JSON.parse(objects) if objects.is_a?(String)
72
+ nodes = objects.dig(:nodes)
73
+
74
+ unless !nodes
75
+
76
+ nodes.each do |n|
77
+
78
+ attrs = n.last.dig('attrs')
79
+ state = attrs.dig('state') || 0
80
+ downtime_depth = attrs.dig('downtime_depth') || 0
81
+ acknowledgement = attrs.dig('acknowledgement') || 0
82
+
83
+ if( state == status && downtime_depth.zero? && acknowledgement.zero? )
84
+ problems += 1
85
+ end
86
+
87
+ end
88
+ end
89
+ problems
90
+ end
91
+
20
92
  end
21
93
  end
@@ -11,7 +11,7 @@ module Icinga2
11
11
  # minor part of version
12
12
  MINOR = 6
13
13
  # tiny part of version
14
- TINY = 2
14
+ TINY = 3
15
15
 
16
16
  end
17
17
 
data/lib/logging.rb CHANGED
@@ -3,6 +3,8 @@
3
3
 
4
4
  require 'logger'
5
5
 
6
+ # taken from https://stackoverflow.com/questions/917566/ruby-share-logger-instance-among-module-classes
7
+ #
6
8
  module Logging
7
9
 
8
10
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icinga2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bodo Schulz