icinga2 0.7.0.1 → 0.8.1.2

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.
@@ -1,22 +1,37 @@
1
1
  # Icinga2 - Hostgroups
2
2
 
3
3
 
4
- ## add
5
- add_hostgroup()
4
+ ## <a name="add-hostgroup"></a>add a hostgroup
5
+ add_hostgroup( params )
6
6
 
7
+ ### Example
8
+ @icinga.add_hostgroup(host_group: 'foo', display_name: 'FOO')
7
9
 
8
- ## delete
9
- delete_hostgroup()
10
10
 
11
+ ## <a name="delete-hostgroup"></a>delete a hostgroup
12
+ delete_hostgroup( params )
11
13
 
12
- ## list
14
+ ### Example
15
+ @icinga.delete_hostgroup(host_group: 'foo')
13
16
 
14
- ### named
15
- hostgroups()
16
17
 
17
- ### all
18
- hostgroups()
18
+ ## <a name="list-hostgroups"></a>list hostgroups
19
19
 
20
+ ### list named hostgroup
21
+ hostgroups( params )
20
22
 
21
- ## check
22
- exists_hostgroup()
23
+ #### Example
24
+ @icinga.hostgroups(host_group: 'linux-servers')
25
+
26
+ ### list all hostgroups
27
+ hostgroups
28
+
29
+ ### Example
30
+ @icinga.hostgroups
31
+
32
+
33
+ ## <a name="usergroup-exists"></a>check if the hostgroup exists
34
+ exists_hostgroup?( hostgroup )
35
+
36
+ ### Example
37
+ @icinga.exists_hostgroup?('linux-servers')
@@ -1,34 +1,107 @@
1
1
  # Icinga2 - Hosts
2
2
 
3
- ## add
4
- vars = {
5
- 'aws' => false
3
+ ## <a name="add-host"></a>add a host
4
+ add_host( params )
5
+
6
+ ### Example
7
+ param = {
8
+ host: 'foo',
9
+ fqdn: 'foo.bar.com',
10
+ display_name: 'test node',
11
+ max_check_attempts: 5,
12
+ notes: 'test node'
6
13
  }
14
+ @icinga.add_host(param)
15
+
16
+
17
+ ## <a name="delete-host"></a>delete a host
18
+ delete_host( params )
19
+
20
+ ### Example
21
+ @icinga.delete_host(host: 'foo')
22
+
23
+
24
+ ## <a name="list-hosts"></a>list hosts
25
+
26
+ ### list a named host
27
+ hosts( params )
28
+
29
+ #### Example
30
+ @icinga.host(host: 'icinga2')
31
+
32
+ ### list all hosts
33
+ hosts
34
+
35
+ #### Example
36
+ @icinga.hosts
37
+
38
+
39
+ ## <a name="host-exists"></a>check if the host exists
40
+ exists_host?( host_name )
41
+
42
+ ### Example
43
+ @icinga.exists_host?('icinga2')
44
+
7
45
 
8
- addHost( 'foo-bar.lan', vars )
46
+ ## <a name="list-host-objects"></a>get host objects
47
+ host_objects( params )
9
48
 
10
- ## delete
11
- deleteHost( 'foo-bar.lan' )
49
+ ### Example
50
+ @icinga.host_objects(attrs: ['name', 'state'])
12
51
 
13
- ## list
14
52
 
15
- ### named
16
- hosts( 'foo-bar.lan' )
53
+ ## <a name="hosts-adjusted"></a>adjusted hosts state
54
+ hosts_adjusted
17
55
 
18
- ### all
19
- hosts()
56
+ ### Example
57
+ @icinga.cib_data
58
+ @icinga.host_objects
59
+ warning, critical, unknown = @icinga.hosts_adjusted.values
20
60
 
21
- ## check
22
- existsHost()
61
+ or
62
+ h = @icinga.hosts_adjusted
63
+ down = h.dig(:down_adjusted)
23
64
 
24
- ##
25
- host_objects
26
65
 
27
- ##
66
+ ## <a name="count-hosts-with-problems"></a>count of hosts with problems
67
+ count_hosts_with_problems
68
+
69
+ ### Example
70
+ @icinga.count_hosts_with_problems
71
+
72
+
73
+ ## <a name="list-hosts-with-problems"></a>a hash of hosts with problems
74
+ list_hosts_with_problems( max_items )
75
+
76
+ ### Example
77
+ @icinga.list_hosts_with_problems
78
+ @icinga.list_hosts_with_problems( 10 )
79
+
80
+
81
+ ## <a name="count-all-hosts"></a>count of all hosts
82
+ hosts_all
83
+
84
+ ### Example
85
+ @icinga.host_objects
86
+ @icinga.hosts_all
87
+
88
+
89
+ ## <a name="count-host-problems"></a>count all hosts with problems (down, warning, unknown state)
28
90
  host_problems
29
91
 
30
- ##
31
- problem_hosts
92
+ ### Example
93
+ @icinga.host_objects
94
+ all, down, critical, unknown = @icinga.host_problems.values
95
+
96
+ or
97
+ p = @icinga.host_problems
98
+ down = h.dig(:down)
99
+
100
+
101
+ ## <a name="host-severity"></a>(protected) calculate a host severity
102
+ host_severity( params )
103
+
104
+ original code are from [Icinga Web2](/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php)
32
105
 
33
- ##
34
- host_severity
106
+ ### Example
107
+ host_severity( {'attrs' => { 'state' => 0.0, 'acknowledgement' => 0.0, 'downtime_depth' => 0.0 } } )
@@ -60,16 +60,27 @@
60
60
  <div id="content"><div id='filecontents'>
61
61
  <h1 id="label-ruby-icinga2">ruby-icinga2</h1>
62
62
 
63
- <p>Small Ruby Class for the Icinga2 API</p>
63
+ <p>Ruby Class for the Icinga2 API</p>
64
64
 
65
65
  <h2 id="label-Requirements">Requirements</h2>
66
+ <ul><li>
67
+ <p>ruby version ~&gt; 2.3</p>
68
+ </li><li>
69
+ <p>rest-client ~&gt; 2.0</p>
70
+ </li><li>
71
+ <p>openssl ~&gt; 2.0</p>
72
+ </li><li>
73
+ <p>json ~&gt; 2.1</p>
74
+ </li></ul>
75
+
76
+ <h2 id="label-install">install</h2>
66
77
 
67
- <pre class="code ruby"><code class="ruby">gem install rest-client --no-rdoc --no-ri
68
- gem install json --no-rdoc --no-ri</code></pre>
78
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_icinga2'>icinga2</span>
79
+ </code></pre>
69
80
 
70
81
  <h2 id="label-usage">usage</h2>
71
82
 
72
- <p>create an instance and get information about the Icinga2 Server</p>
83
+ <p>create an instance</p>
73
84
 
74
85
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_config'>config</span> <span class='op'>=</span> <span class='lbrace'>{</span>
75
86
  <span class='symbol'>:icinga</span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span>
@@ -84,141 +95,183 @@ gem install json --no-rdoc --no-ri</code></pre>
84
95
  <span class='rbrace'>}</span>
85
96
  <span class='rbrace'>}</span>
86
97
 
87
- <span class='id identifier rubyid_i'>i</span> <span class='op'>=</span> <span class='const'>Icinga</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> <span class='id identifier rubyid_config'>config</span> <span class='rparen'>)</span>
88
- <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_i'>i</span><span class='period'>.</span><span class='id identifier rubyid_application_data'>application_data</span><span class='lparen'>(</span><span class='rparen'>)</span>
98
+ <span class='ivar'>@icinga</span> <span class='op'>=</span> <span class='const'>Icinga</span><span class='op'>::</span><span class='const'>Client</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span> <span class='id identifier rubyid_config'>config</span> <span class='rparen'>)</span>
89
99
  </code></pre>
90
100
 
91
101
  <h2 id="label-Status">Status</h2>
92
102
 
93
103
  <p>supports the following API Calls:</p>
94
104
  <ul><li>
95
- <p><a href="doc/status.md">Users</a></p>
105
+ <p><a href="doc/users.md">Users</a></p>
96
106
  <ul><li>
97
- <p>application_data</p>
107
+ <p><a href="doc/users.md#add-user">add user</a></p>
98
108
  </li><li>
99
- <p>cib_data</p>
109
+ <p><a href="doc/users.md#delete-dser">delete user</a></p>
100
110
  </li><li>
101
- <p>api_listener</p>
111
+ <p><a href="doc/users.md#list-users">list users</a></p>
102
112
  </li><li>
103
- <p>application_data</p>
113
+ <p><a href="doc/users.md#user-exists">check if user exists</a></p>
104
114
  </li><li>
105
- <p>cib_data</p>
115
+ <p><a href="doc/users.md#add-user">add user</a></p>
106
116
  </li><li>
107
- <p>api_listener</p>
108
- </li></ul>
117
+ <p><a href="doc/users.md#delete-dser">delete user</a></p>
109
118
  </li><li>
110
- <p><a href="doc/users.md">Users</a></p>
111
- <ul><li>
112
- <p>add_user( params = {} )</p>
119
+ <p><a href="doc/users.md#list-users">list users</a></p>
113
120
  </li><li>
114
- <p>delete_user( params = {} )</p>
115
- </li><li>
116
- <p>users( params = {} )</p>
117
- </li><li>
118
- <p>exists_user?( name )</p>
121
+ <p><a href="doc/users.md#user-exists">check if user exists</a></p>
119
122
  </li></ul>
120
123
  </li><li>
121
124
  <p><a href="doc/usergroups.md">Usergroups</a></p>
122
125
  <ul><li>
123
- <p>add_usergroup( params = {} )</p>
126
+ <p><a href="doc/usergroups.md#add-usergroup">add usergroup</a></p>
124
127
  </li><li>
125
- <p>delete_usergroup( params = {} )</p>
128
+ <p><a href="doc/usergroups.md#delete-usergroup">delete usergroup</a></p>
126
129
  </li><li>
127
- <p>usergroups( params = {} )</p>
130
+ <p><a href="doc/usergroups.md#list-usergroups">list usergroups</a></p>
128
131
  </li><li>
129
- <p>exists_usergroup?( name )</p>
132
+ <p><a href="doc/usergroups.md#usergroup-exists">check if usergroup exists</a></p>
130
133
  </li></ul>
131
134
  </li><li>
132
135
  <p><a href="doc/hosts.md">Hosts</a></p>
133
136
  <ul><li>
134
- <p>add_host( params = {} )</p>
137
+ <p><a href="doc/hosts.md#add-host">add host</a></p>
138
+ </li><li>
139
+ <p><a href="doc/hosts.md#delete-host">delete host</a></p>
135
140
  </li><li>
136
- <p>delete_host( params = {} )</p>
141
+ <p><a href="doc/hosts.md#list-hosts">list hosts</a></p>
137
142
  </li><li>
138
- <p>hosts( params = {} )</p>
143
+ <p><a href="doc/hosts.md#host-exists">check if host exists</a></p>
139
144
  </li><li>
140
- <p>exists_host?( name )</p>
145
+ <p><a href="doc/hosts.md#list-host-objects">list host objects</a></p>
141
146
  </li><li>
142
- <p>host_objects( params = {} )</p>
147
+ <p><a href="doc/hosts.md#hosts-adjusted">adjusted hosts state</a></p>
143
148
  </li><li>
144
- <p>host_problems</p>
149
+ <p><a href="doc/hosts.md#count-hosts-with-problems">count of hosts with
150
+ problems</a></p>
145
151
  </li><li>
146
- <p>problem_hosts( max_items = 5 )</p>
152
+ <p><a href="doc/hosts.md#list-hosts-with-problems">list of hosts with
153
+ problems</a></p>
147
154
  </li><li>
148
- <p>host_severity( host )</p>
155
+ <p><a href="doc/hosts.md#count-all-hosts">count of all hosts</a></p>
156
+ </li><li>
157
+ <p><a href="doc/hosts.md#count-host-problems">count hosts with problems</a></p>
158
+ </li><li>
159
+ <p>calculate host severity (protected)</p>
149
160
  </li></ul>
150
161
  </li><li>
151
162
  <p><a href="doc/hostgroups.md">Hostgroups</a></p>
152
163
  <ul><li>
153
- <p>add_hostgroup(params = {})</p>
164
+ <p><a href="doc/hostgroups.md#add-usergroup">add hostgroup</a></p>
154
165
  </li><li>
155
- <p>delete_hostgroup(params = {})</p>
166
+ <p><a href="doc/hostgroups.md#delete-usergroup">delete hostgroup</a></p>
156
167
  </li><li>
157
- <p>hostgroups(params = {})</p>
168
+ <p><a href="doc/hostgroups.md#list-usergroups">list hostgroups</a></p>
158
169
  </li><li>
159
- <p>exists_hostgroup?(name)</p>
170
+ <p><a href="doc/hostgroups.md#usergroup-exists">check if hostgroup exists</a></p>
160
171
  </li></ul>
161
172
  </li><li>
162
173
  <p><a href="doc/services.md">Services</a></p>
163
174
  <ul><li>
164
- <p>add_services( host, services = {} )</p>
175
+ <p><a href="doc/services.md#add-service">add service</a> (<strong>this
176
+ function is not operable yet!</strong>)</p>
177
+ </li><li>
178
+ <p><a href="doc/services.md#delete-service">delete service</a> (<strong>not
179
+ yet implemented</strong>)</p>
180
+ </li><li>
181
+ <p><a href="doc/services.md#add-service">add service</a> (<strong>this
182
+ function is not operable yet!</strong>)</p>
183
+ </li><li>
184
+ <p><a href="doc/services.md#unhandled-services">list unhandled services</a>
185
+ (<strong>not yet implemented</strong>)</p>
186
+ </li><li>
187
+ <p><a href="doc/services.md#list-services">list services</a></p>
188
+ </li><li>
189
+ <p><a href="doc/services.md#service-exists">check if service exists</a></p>
165
190
  </li><li>
166
- <p>unhandled_services( params = {} )</p>
191
+ <p><a href="doc/services.md#list-service-objects">list service objects</a></p>
167
192
  </li><li>
168
- <p>services( params = {} )</p>
193
+ <p><a href="doc/services.md#services-adjusted">adjusted service state</a></p>
169
194
  </li><li>
170
- <p>exists_service?( params = {} )</p>
195
+ <p><a href="doc/services.md#count-services-with-problems">count services with
196
+ problems</a></p>
171
197
  </li><li>
172
- <p>service_objects( params = {} )</p>
198
+ <p><a href="doc/services.md#list-services-with-problems">list of services with
199
+ problems</a></p>
173
200
  </li><li>
174
- <p>service_problems</p>
201
+ <p><a href="doc/services.md#update-host">update host</a> (<strong>this
202
+ function is not operable yet!</strong>)</p>
175
203
  </li><li>
176
- <p>problem_services( max_items = 5 )</p>
204
+ <p><a href="doc/services.md#count-all-services">count of all services</a></p>
177
205
  </li><li>
178
- <p>update_host( hash, host )</p>
206
+ <p><a href="doc/services.md#count-all-services-handled">count all services
207
+ with handled problems</a></p>
179
208
  </li><li>
180
- <p>service_severity( service )</p>
209
+ <p>calculate service severity (protected)</p>
181
210
  </li></ul>
182
211
  </li><li>
183
212
  <p><a href="doc/servicegroups.md">Servicegroups</a></p>
184
213
  <ul><li>
185
- <p>add_servicegroup( params = {} )</p>
214
+ <p><a href="doc/servicegroups.md#add-servicegroup">add servicegroup</a></p>
186
215
  </li><li>
187
- <p>delete_servicegroup( params = {} )</p>
216
+ <p><a href="doc/servicegroups.md#delete-servicegroup">delete servicegroup</a></p>
188
217
  </li><li>
189
- <p>servicegroups( params = {} )</p>
218
+ <p><a href="doc/servicegroups.md#list-servicegroup">list servicegroups</a></p>
190
219
  </li><li>
191
- <p>exists_servicegroup?( name )</p>
220
+ <p><a href="doc/servicegroups.md#servicegroup-exists">check if servicegroup
221
+ exists</a></p>
192
222
  </li></ul>
193
223
  </li><li>
194
224
  <p><a href="doc/downtimes.md">Downtimes</a></p>
195
225
  <ul><li>
196
- <p>add_downtime( params = {} )</p>
226
+ <p><a href="doc/downtimes.md#add-downtime">add downtime</a></p>
197
227
  </li><li>
198
- <p>downtimes( params = {} )</p>
228
+ <p><a href="doc/downtimes.md#list-downtimes">list downtimes</a></p>
199
229
  </li></ul>
200
230
  </li><li>
201
231
  <p><a href="doc/notifications.md">Notifications</a></p>
202
232
  <ul><li>
203
- <p>enable_host_notification( host )</p>
233
+ <p><a href="doc/notifications.md#enable-host-notification">enable host
234
+ notifications</a></p>
204
235
  </li><li>
205
- <p>disable_host_notification( host )</p>
236
+ <p><a href="doc/notifications.md#disable-host-notification">disable host
237
+ notifications</a></p>
206
238
  </li><li>
207
- <p>enable_service_notification( params = {} )</p>
239
+ <p><a href="doc/notifications.md#enable-service-notification">enable service
240
+ notifications</a></p>
208
241
  </li><li>
209
- <p>disable_service_notification( host )</p>
242
+ <p><a href="doc/notifications.md#disable-service-notification">disable service
243
+ notifications</a></p>
210
244
  </li><li>
211
- <p>enable_hostgroup_notification( group )</p>
245
+ <p><a href="doc/notifications.md#enable-hostgroup-notification">enable
246
+ hostgroup notifications</a></p>
212
247
  </li><li>
213
- <p>disable_hostgroup_notification( group )</p>
248
+ <p><a href="doc/notifications.md#disable-hostgroup-notification">disable
249
+ hostgroup notifications</a></p>
250
+ </li><li>
251
+ <p><a href="doc/notifications.md#list-notifications">list all
252
+ notifications</a></p>
253
+ </li><li>
254
+ <p>host notification (protected)</p>
255
+ </li><li>
256
+ <p>hostgroup notification (protected)</p>
257
+ </li><li>
258
+ <p>service notification (protected)</p>
259
+ </li></ul>
260
+ </li><li>
261
+ <p><a href="doc/statistics.md">Statistics</a></p>
262
+ <ul><li>
263
+ <p><a href="doc/statistics.md#stats-avg">statistic data for latence and
264
+ execution time</a></p>
214
265
  </li><li>
215
- <p>notifications( params = {} )</p>
266
+ <p><a href="doc/statistics.md#stats-interval">statistic data for interval
267
+ data</a></p>
216
268
  </li><li>
217
- <p>host_notification( params = {} )</p>
269
+ <p><a href="doc/statistics.md#stats-services">statistic data for services</a></p>
218
270
  </li><li>
219
- <p>hostgroup_notification( params = {} )</p>
271
+ <p><a href="doc/statistics.md#stats-hosts">statistic data for hosts</a></p>
220
272
  </li><li>
221
- <p>service_notification( params = {} )</p>
273
+ <p><a href="doc/statistics.md#stats-work-queue">queue statistics from the
274
+ api</a></p>
222
275
  </li></ul>
223
276
  </li></ul>
224
277
 
@@ -238,8 +291,7 @@ Successfully installed icinga2-0.6.0
238
291
 
239
292
  <h2 id="label-test+via+CLI">test via CLI</h2>
240
293
 
241
- <pre class="code ruby"><code class="ruby">#$ export ICINGA_HOST=localhost ; export ICINGA_API_USER=root ; export ICINGA_API_PASSWORD=icinga
242
- #$ irb
294
+ <pre class="code ruby"><code class="ruby">#$ irb
243
295
  2.3.0 :001 &gt; require &#39;icinga2&#39;
244
296
  =&gt; true
245
297
  2.3.0 :002 &gt; config = { :icinga =&gt; { :host =&gt; &#39;localhost&#39;, :api =&gt; { :user =&gt; &#39;root&#39;, :pass =&gt; &#39;icinga&#39; } } }
@@ -268,7 +320,7 @@ feature&#39;</code>)</p>
268
320
  </div></div>
269
321
 
270
322
  <div id="footer">
271
- Generated on Wed Jun 28 05:55:20 2017 by
323
+ Generated on Tue Aug 22 11:29:51 2017 by
272
324
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
273
325
  0.9.9 (ruby-2.3.4).
274
326
  </div>