icinga2 0.9.2.1 → 0.9.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -22
  3. data/doc/Array.html +4 -6
  4. data/doc/Boolean.html +4 -6
  5. data/doc/FalseClass.html +4 -6
  6. data/doc/Hash.html +126 -8
  7. data/doc/Icinga2.html +7 -9
  8. data/doc/Logging.html +5 -7
  9. data/doc/Object.html +8 -10
  10. data/doc/Time.html +4 -6
  11. data/doc/TrueClass.html +4 -6
  12. data/doc/_index.html +20 -7
  13. data/doc/class_list.html +1 -1
  14. data/doc/file.README.html +32 -30
  15. data/doc/frames.html +1 -1
  16. data/doc/index.html +32 -30
  17. data/doc/method_list.html +34 -2
  18. data/doc/services.md +45 -62
  19. data/doc/top-level-namespace.html +4 -6
  20. data/examples/_blank.rb +2 -2
  21. data/examples/config.rb +23 -0
  22. data/examples/downtimes.rb +4 -33
  23. data/examples/hostgroups.rb +4 -33
  24. data/examples/hosts.rb +18 -33
  25. data/examples/informations.rb +4 -33
  26. data/examples/notifications.rb +4 -33
  27. data/examples/servicegroups.rb +4 -25
  28. data/examples/services.rb +46 -67
  29. data/examples/statistics.rb +4 -33
  30. data/examples/test.rb +7 -28
  31. data/examples/usergroups.rb +4 -33
  32. data/examples/users.rb +4 -33
  33. data/lib/icinga2/client.rb +16 -42
  34. data/lib/icinga2/converts.rb +16 -54
  35. data/lib/icinga2/downtimes.rb +46 -44
  36. data/lib/icinga2/hostgroups.rb +35 -35
  37. data/lib/icinga2/hosts.rb +235 -228
  38. data/lib/icinga2/network.rb +53 -125
  39. data/lib/icinga2/notifications.rb +37 -46
  40. data/lib/icinga2/servicegroups.rb +31 -41
  41. data/lib/icinga2/services.rb +211 -236
  42. data/lib/icinga2/tools.rb +10 -9
  43. data/lib/icinga2/usergroups.rb +22 -32
  44. data/lib/icinga2/users.rb +64 -59
  45. data/lib/icinga2/validator.rb +59 -0
  46. data/lib/icinga2/version.rb +1 -1
  47. metadata +78 -7
  48. data/lib/icinga2/network.rb-SAVE +0 -1004
@@ -132,6 +132,22 @@
132
132
  </li>
133
133
 
134
134
 
135
+ <li class="even ">
136
+ <div class="item">
137
+ <span class='object_link'><a href="Hash.html#assert_required_keys-instance_method" title="Hash#assert_required_keys (method)">#assert_required_keys</a></span>
138
+ <small>Hash</small>
139
+ </div>
140
+ </li>
141
+
142
+
143
+ <li class="odd ">
144
+ <div class="item">
145
+ <span class='object_link'><a href="Hash.html#assert_valid_keys-instance_method" title="Hash#assert_valid_keys (method)">#assert_valid_keys</a></span>
146
+ <small>Hash</small>
147
+ </div>
148
+ </li>
149
+
150
+
135
151
  <li class="even ">
136
152
  <div class="item">
137
153
  <span class='object_link'><a href="Icinga2/Client.html#available%3F-instance_method" title="Icinga2::Client#available? (method)">#available?</a></span>
@@ -646,7 +662,7 @@
646
662
 
647
663
  <li class="even ">
648
664
  <div class="item">
649
- <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>
665
+ <span class='object_link'><a href="Icinga2/Converts.html#state_to_color-instance_method" title="Icinga2::Converts#state_to_color (method)">#state_to_color</a></span>
650
666
  <small>Icinga2::Converts</small>
651
667
  </div>
652
668
  </li>
@@ -654,7 +670,7 @@
654
670
 
655
671
  <li class="odd ">
656
672
  <div class="item">
657
- <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>
673
+ <span class='object_link'><a href="Icinga2/Converts.html#state_to_string-instance_method" title="Icinga2::Converts#state_to_string (method)">#state_to_string</a></span>
658
674
  <small>Icinga2::Converts</small>
659
675
  </div>
660
676
  </li>
@@ -700,6 +716,22 @@
700
716
  </li>
701
717
 
702
718
 
719
+ <li class="odd ">
720
+ <div class="item">
721
+ <span class='object_link'><a href="Icinga2/Validator.html#validate-instance_method" title="Icinga2::Validator#validate (method)">#validate</a></span>
722
+ <small>Icinga2::Validator</small>
723
+ </div>
724
+ </li>
725
+
726
+
727
+ <li class="even ">
728
+ <div class="item">
729
+ <span class='object_link'><a href="Icinga2/Validator.html#validate_options!-instance_method" title="Icinga2::Validator#validate_options! (method)">#validate_options!</a></span>
730
+ <small>Icinga2::Validator</small>
731
+ </div>
732
+ </li>
733
+
734
+
703
735
  <li class="odd ">
704
736
  <div class="item">
705
737
  <span class='object_link'><a href="Icinga2/Client.html#version-instance_method" title="Icinga2::Client#version (method)">#version</a></span>
@@ -7,26 +7,36 @@ Add a Service to Icinga2
7
7
 
8
8
  `params` is an `Hash` with following Parameters:
9
9
 
10
- | Parameter | Type | Example | Description
11
- | :-------------------- | :-----: | :----- | :-----------
12
- | `host_name` | String | `foo` | existing Host for these Service
13
- | `name` | String | `ping4` | Service Name they will be create
14
- | `templates` | Array | `['own-service']` | (optional) a Array of templates (default: `['generic-service']`)
15
- | `vars` | Hash | (see below) | Hash with custom options
16
-
17
- Under the `vars` Hash is the structure very strict.
18
- They hold only a `attrs` Hash with all others variable.
19
-
20
- **Importand** The the `attrs` Hash has mandatory fields!
21
-
22
- | Parameter | Type | Example | Description
23
- | :-------------------- | :-----: | :------------ | :-----------
24
- | `check_command` | String | `ping4` | The Check Command to execute (**Importand** This Check-Comand must be exists! Otherwise an error will occur)
25
- | `check_interval` | Integer | `10` | The check Interval
26
- | `retry_interval` | Integer | `30` | The retry Interval
27
- | `vars` | Hash | (see below) | optional config params for the `check_command`
28
-
29
- For more custom fields, add an `vars` Hash with the config parameters of the `check_command` (see below in the examples)
10
+ | Parameter | Type | Example | Description
11
+ | :-------------------- | :-----: | :----- | :-----------
12
+ | `host_name` | String | `foo` | existing Host for these Service
13
+ | `name` | String | `ping4` | Service Name they will be create
14
+ | `display_name` | String | `ping4 check` | displayed Name
15
+ | `templates` | Array | `['own-service']` | (optional) a Array of templates (default: `['generic-service']`)
16
+ | `check_command` | String | `ping4` | The Check Command to execute (**Importand** This Check-Comand must be exists! Otherwise an error will occur)
17
+ | `check_interval` | Integer | `10` | The check Interval
18
+ | `retry_interval` | Integer | `30` | The retry Interval
19
+ | `notes` | String | `` |
20
+ | `notes_url` | String | `` |
21
+ | `action_url` | String | `` |
22
+ | `check_period` | String | `` |
23
+ | `check_timeout` | Integer | `` |
24
+ | `command_endpoint` | String | `` |
25
+ | `enable_active_checks` | Bool | `` |
26
+ | `enable_event_handler` | Bool | `` |
27
+ | `enable_flapping` | Bool | `` |
28
+ | `enable_notifications` | Bool | `` |
29
+ | `enable_passive_checks` | Bool | `` |
30
+ | `enable_perfdata` | Bool | `` |
31
+ | `event_command` | String | `` |
32
+ | `flapping_threshold_high`| Integer | `` |
33
+ | `flapping_threshold_low` | Integer | `` |
34
+ | `flapping_threshold` | Integer | `` |
35
+ | `icon_image_alt` | String | `` |
36
+ | `icon_image` | String | `` |
37
+ | `max_check_attempts` | Integer | `` |
38
+ | `volatile` | Bool | `` |
39
+ | `vars` | Hash | (see below) | optional config params for the `check_command`
30
40
 
31
41
  The result are an `Hash`
32
42
 
@@ -35,13 +45,9 @@ The result are an `Hash`
35
45
  @icinga.add_services(
36
46
  host_name: 'foo',
37
47
  name: 'ping4',
38
- vars: {
39
- attrs: {
40
- check_command: 'ping4',
41
- check_interval: 10,
42
- retry_interval: 30
43
- }
44
- }
48
+ check_command: 'ping4',
49
+ check_interval: 10,
50
+ retry_interval: 30
45
51
  )
46
52
 
47
53
  or
@@ -49,17 +55,13 @@ or
49
55
  @icinga.add_service(
50
56
  host_name: 'foo',
51
57
  name: 'http',
58
+ check_command: 'http',
59
+ check_interval: 10,
60
+ retry_interval: 30,
52
61
  vars: {
53
- attrs: {
54
- check_command: 'http',
55
- check_interval: 10,
56
- retry_interval: 30,
57
- vars: {
58
- http_address: '127.0.0.1',
59
- http_url: '/access/index',
60
- http_port: 80
61
- }
62
- }
62
+ http_address: '127.0.0.1',
63
+ http_url: '/access/index',
64
+ http_port: 80
63
65
  }
64
66
  )
65
67
 
@@ -97,14 +99,9 @@ Modify an Service.
97
99
 
98
100
  | Parameter | Type | Example | Description
99
101
  | :-------------------- | :-----: | :----- | :-----------
100
- | `name` | String | `ping4` | Service Name they will be deleted
102
+ | `name` | String | `ping4` | Service Name they will be deleted
101
103
  | `templates` | Array | `['own-service']` | (optional) a Array of templates (default: `['generic-service']`)
102
- | `vars` | Hash | (see below) | Hash with custom options
103
-
104
- Under the `vars` Hash is the structure very strict.
105
- They hold only a `attrs` Hash with all others variable. (similar to `add_service`)
106
-
107
- For more custom fields, add an `vars` Hash with the config parameters of the `check_command` (see below in the examples)
104
+ | `vars` | Hash | (see below) | Hash with custom options (see `add_services()`)
108
105
 
109
106
  The result are an `Hash`
110
107
 
@@ -112,15 +109,11 @@ The result are an `Hash`
112
109
 
113
110
  @icinga.modify_service(
114
111
  name: 'http2',
112
+ check_interval: 60,
113
+ retry_interval: 10,
115
114
  vars: {
116
- attrs: {
117
- check_interval: 60,
118
- retry_interval: 10,
119
- vars: {
120
- http_url: '/access/login' ,
121
- http_address: '10.41.80.63'
122
- }
123
- }
115
+ http_url: '/access/login' ,
116
+ http_address: '10.41.80.63'
124
117
  }
125
118
  )
126
119
 
@@ -286,13 +279,3 @@ The result are an `Integer`
286
279
  service_severity( {'attrs' => { 'state' => 0.0, 'acknowledgement' => 0.0, 'downtime_depth' => 0.0 } } )
287
280
 
288
281
 
289
-
290
- ## <a name=""></a>*update_host( hash, host )* (private)
291
-
292
- update host
293
-
294
- The result are an `Hash`
295
-
296
- ### Example
297
- service_severity( {'attrs' => { 'state' => 0.0, 'acknowledgement' => 0.0, 'downtime_depth' => 0.0 } } )
298
-
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.9.4
9
+ &mdash; Documentation by YARD 0.9.11
10
10
 
11
11
  </title>
12
12
 
@@ -28,7 +28,7 @@
28
28
  </head>
29
29
  <body>
30
30
  <div class="nav_wrap">
31
- <iframe id="nav" src="class_list.html"></iframe>
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
32
  <div id="resizer"></div>
33
33
  </div>
34
34
 
@@ -59,8 +59,6 @@
59
59
  <div class="clear"></div>
60
60
  </div>
61
61
 
62
- <iframe id="search_frame" src="class_list.html"></iframe>
63
-
64
62
  <div id="content"><h1>Top Level Namespace
65
63
 
66
64
 
@@ -104,9 +102,9 @@
104
102
  </div>
105
103
 
106
104
  <div id="footer">
107
- Generated on Sun Nov 12 15:48:13 2017 by
105
+ Generated on Sat Dec 9 20:28:06 2017 by
108
106
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
109
- 0.9.4 (ruby-2.2.8).
107
+ 0.9.11 (ruby-2.2.8).
110
108
  </div>
111
109
 
112
110
  </div>
@@ -61,8 +61,8 @@ unless( i.nil? )
61
61
  puts ''
62
62
 
63
63
  rescue => e
64
- $stderr.puts( e )
65
- $stderr.puts( e.backtrace.join("\n") )
64
+ warn( e )
65
+ warn( e.backtrace.join("\n") )
66
66
  end
67
67
  end
68
68
 
@@ -0,0 +1,23 @@
1
+
2
+ icinga_host = ENV.fetch( 'ICINGA_HOST' , 'icinga2' )
3
+ icinga_api_port = ENV.fetch( 'ICINGA_API_PORT' , 5665 )
4
+ icinga_api_user = ENV.fetch( 'ICINGA_API_USER' , 'admin' )
5
+ icinga_api_pass = ENV.fetch( 'ICINGA_API_PASSWORD' , nil )
6
+ icinga_api_pki_path = ENV.fetch( 'ICINGA_API_PKI_PATH' , '/etc/icinga2' )
7
+ icinga_api_node_name = ENV.fetch( 'ICINGA_API_NODE_NAME' , nil )
8
+
9
+ @config = {
10
+ icinga: {
11
+ host: icinga_host,
12
+ api: {
13
+ port: icinga_api_port,
14
+ user: icinga_api_user,
15
+ password: icinga_api_pass,
16
+ pki_path: icinga_api_pki_path,
17
+ node_name: icinga_api_node_name
18
+ }
19
+ }
20
+ }
21
+
22
+ # ---------------------------------------------------------------------------------------
23
+
@@ -9,40 +9,11 @@
9
9
  # -----------------------------------------------------------------------------
10
10
 
11
11
  require_relative '../lib/icinga2'
12
+ require_relative 'config'
12
13
 
13
14
  # -----------------------------------------------------------------------------
14
15
 
15
- icinga_host = ENV.fetch( 'ICINGA_HOST' , 'icinga2' )
16
- icinga_api_port = ENV.fetch( 'ICINGA_API_PORT' , 5665 )
17
- icinga_api_user = ENV.fetch( 'ICINGA_API_USER' , 'admin' )
18
- icinga_api_pass = ENV.fetch( 'ICINGA_API_PASSWORD' , nil )
19
- icinga_api_pki_path = ENV.fetch( 'ICINGA_API_PKI_PATH' , '/etc/icinga2' )
20
- icinga_api_node_name = ENV.fetch( 'ICINGA_API_NODE_NAME' , nil )
21
- icinga_cluster = ENV.fetch( 'ICINGA_CLUSTER' , false )
22
- icinga_satellite = ENV.fetch( 'ICINGA_CLUSTER_SATELLITE', nil )
23
-
24
-
25
- # convert string to bool
26
- icinga_cluster = icinga_cluster.to_s.eql?('true') ? true : false
27
-
28
- config = {
29
- icinga: {
30
- host: icinga_host,
31
- api: {
32
- port: icinga_api_port,
33
- user: icinga_api_user,
34
- password: icinga_api_pass,
35
- pki_path: icinga_api_pki_path,
36
- node_name: icinga_api_node_name
37
- },
38
- cluster: icinga_cluster,
39
- satellite: icinga_satellite
40
- }
41
- }
42
-
43
- # ---------------------------------------------------------------------------------------
44
-
45
- i = Icinga2::Client.new( config )
16
+ i = Icinga2::Client.new( @config )
46
17
 
47
18
  unless( i.nil? )
48
19
 
@@ -68,8 +39,8 @@ unless( i.nil? )
68
39
  puts ''
69
40
 
70
41
  rescue => e
71
- $stderr.puts( e )
72
- $stderr.puts( e.backtrace.join("\n") )
42
+ warn( e )
43
+ warn( e.backtrace.join("\n") )
73
44
  end
74
45
  end
75
46
 
@@ -9,40 +9,11 @@
9
9
  # -----------------------------------------------------------------------------
10
10
 
11
11
  require_relative '../lib/icinga2'
12
+ require_relative 'config'
12
13
 
13
14
  # -----------------------------------------------------------------------------
14
15
 
15
- icinga_host = ENV.fetch( 'ICINGA_HOST' , 'icinga2' )
16
- icinga_api_port = ENV.fetch( 'ICINGA_API_PORT' , 5665 )
17
- icinga_api_user = ENV.fetch( 'ICINGA_API_USER' , 'admin' )
18
- icinga_api_pass = ENV.fetch( 'ICINGA_API_PASSWORD' , nil )
19
- icinga_api_pki_path = ENV.fetch( 'ICINGA_API_PKI_PATH' , '/etc/icinga2' )
20
- icinga_api_node_name = ENV.fetch( 'ICINGA_API_NODE_NAME' , nil )
21
- icinga_cluster = ENV.fetch( 'ICINGA_CLUSTER' , false )
22
- icinga_satellite = ENV.fetch( 'ICINGA_CLUSTER_SATELLITE', nil )
23
-
24
-
25
- # convert string to bool
26
- icinga_cluster = icinga_cluster.to_s.eql?('true') ? true : false
27
-
28
- config = {
29
- icinga: {
30
- host: icinga_host,
31
- api: {
32
- port: icinga_api_port,
33
- user: icinga_api_user,
34
- password: icinga_api_pass,
35
- pki_path: icinga_api_pki_path,
36
- node_name: icinga_api_node_name
37
- },
38
- cluster: icinga_cluster,
39
- satellite: icinga_satellite
40
- }
41
- }
42
-
43
- # ---------------------------------------------------------------------------------------
44
-
45
- i = Icinga2::Client.new( config )
16
+ i = Icinga2::Client.new( @config )
46
17
 
47
18
  unless( i.nil? )
48
19
 
@@ -80,8 +51,8 @@ unless( i.nil? )
80
51
  puts ''
81
52
 
82
53
  rescue => e
83
- $stderr.puts( e )
84
- $stderr.puts( e.backtrace.join("\n") )
54
+ warn( e )
55
+ warn( e.backtrace.join("\n") )
85
56
  end
86
57
  end
87
58
 
@@ -9,40 +9,11 @@
9
9
  # -----------------------------------------------------------------------------
10
10
 
11
11
  require_relative '../lib/icinga2'
12
+ require_relative 'config'
12
13
 
13
14
  # -----------------------------------------------------------------------------
14
15
 
15
- icinga_host = ENV.fetch( 'ICINGA_HOST' , 'icinga2' )
16
- icinga_api_port = ENV.fetch( 'ICINGA_API_PORT' , 5665 )
17
- icinga_api_user = ENV.fetch( 'ICINGA_API_USER' , 'admin' )
18
- icinga_api_pass = ENV.fetch( 'ICINGA_API_PASSWORD' , nil )
19
- icinga_api_pki_path = ENV.fetch( 'ICINGA_API_PKI_PATH' , '/etc/icinga2' )
20
- icinga_api_node_name = ENV.fetch( 'ICINGA_API_NODE_NAME' , nil )
21
- icinga_cluster = ENV.fetch( 'ICINGA_CLUSTER' , false )
22
- icinga_satellite = ENV.fetch( 'ICINGA_CLUSTER_SATELLITE', nil )
23
-
24
-
25
- # convert string to bool
26
- icinga_cluster = icinga_cluster.to_s.eql?('true') ? true : false
27
-
28
- config = {
29
- icinga: {
30
- host: icinga_host,
31
- api: {
32
- port: icinga_api_port,
33
- user: icinga_api_user,
34
- password: icinga_api_pass,
35
- pki_path: icinga_api_pki_path,
36
- node_name: icinga_api_node_name
37
- },
38
- cluster: icinga_cluster,
39
- satellite: icinga_satellite
40
- }
41
- }
42
-
43
- # ---------------------------------------------------------------------------------------
44
-
45
- i = Icinga2::Client.new( config )
16
+ i = Icinga2::Client.new( @config )
46
17
 
47
18
  unless( i.nil? )
48
19
 
@@ -165,12 +136,26 @@ unless( i.nil? )
165
136
  puts i.hosts(name: 'c1-mysql-1')
166
137
  puts ''
167
138
 
139
+ puts '= list named Hosts \'c1-mysql-1\' (with attrs and filter)'
140
+ puts i.hosts(
141
+ name: 'c1-mysql-1',
142
+ attrs: %w[display_name name address]
143
+ )
144
+ puts ''
145
+
146
+ puts '= host object with attrs and filter'
147
+ # Get host name, address of hosts belonging to a specific hostgroup
148
+ puts i.host_objects(
149
+ attrs: %w[display_name name address],
150
+ filter: '"linux-servers" in host.groups'
151
+ )
152
+
168
153
  puts ' ------------------------------------------------------------- '
169
154
  puts ''
170
155
 
171
156
  rescue => e
172
- $stderr.puts( e )
173
- $stderr.puts( e.backtrace.join("\n") )
157
+ warn( e )
158
+ warn( e.backtrace.join("\n") )
174
159
  end
175
160
  end
176
161