icinga2 0.9.0.1 → 0.9.2.1
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.
- checksums.yaml +4 -4
- data/README.md +51 -45
- data/doc/hosts.md +62 -21
- data/doc/services.md +215 -54
- data/doc/statistics.md +28 -10
- data/doc/usergroups.md +49 -11
- data/doc/users.md +64 -13
- data/examples/_blank.rb +72 -0
- data/examples/downtimes.rb +79 -0
- data/examples/hostgroups.rb +91 -0
- data/examples/hosts.rb +180 -0
- data/examples/informations.rb +95 -0
- data/examples/notifications.rb +109 -0
- data/examples/servicegroups.rb +102 -0
- data/examples/services.rb +202 -0
- data/examples/statistics.rb +137 -0
- data/examples/test.rb +32 -377
- data/examples/usergroups.rb +95 -0
- data/examples/users.rb +98 -0
- data/lib/icinga2.rb +4 -394
- data/lib/icinga2/client.rb +431 -0
- data/lib/icinga2/downtimes.rb +40 -20
- data/lib/icinga2/hostgroups.rb +38 -22
- data/lib/icinga2/hosts.rb +308 -92
- data/lib/icinga2/network.rb +211 -213
- data/lib/icinga2/notifications.rb +30 -28
- data/lib/icinga2/servicegroups.rb +43 -24
- data/lib/icinga2/services.rb +218 -130
- data/lib/icinga2/statistics.rb +14 -10
- data/lib/icinga2/tools.rb +1 -1
- data/lib/icinga2/usergroups.rb +12 -15
- data/lib/icinga2/users.rb +16 -17
- data/lib/icinga2/version.rb +1 -15
- data/lib/monkey_patches.rb +89 -0
- metadata +21 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db0fe25ebd8e946d7c604572bf519a42d07a9d82
|
4
|
+
data.tar.gz: a903a6ec90465f9c77eaa435fd87fce351aa6993
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bae9836345523dcf3756967d14d54d19bd8b0b266f0883e01397bdaca52b05671e09266bbbbc3d384c903a6bc33f9177bc7ad76d8489ac9c88b44a7de75ed6ed
|
7
|
+
data.tar.gz: f956ffb022e2fa3857646d8e1b1a2f366276c2945a478e4d5faac64b6747d86c653ede0202e358635a530405a55226659c58f10f28065cd9ef6efcafdaf82d68
|
data/README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# ruby-icinga2
|
2
2
|
|
3
|
-
|
3
|
+
An enhanced ruby gem to communicate with Icinga2 API
|
4
4
|
|
5
5
|
[](https://badge.fury.io/rb/icinga2)
|
6
6
|
|
7
|
-
[][gem-downloads]
|
7
|
+
[][travis]
|
8
|
+
[][gem-downloads]
|
10
9
|
[][gem-downloads]
|
11
10
|
[][gemnasium]
|
12
11
|
|
@@ -17,16 +16,17 @@ Ruby Class for the Icinga2 API
|
|
17
16
|
|
18
17
|
## Requirements
|
19
18
|
|
20
|
-
* ruby version => 2.
|
19
|
+
* ruby version => 2.0
|
21
20
|
* rest-client ~> 2.0
|
22
|
-
* openssl ~> 2.0 (only with ruby 2.3)
|
23
21
|
* json ~> 2.1
|
22
|
+
* openssl ~> 2.0 (only with ruby >= 2.3)
|
23
|
+
* ruby_dig (only with ruby < 2.3)
|
24
24
|
|
25
|
-
##
|
25
|
+
## Install
|
26
26
|
|
27
27
|
gem install icinga2
|
28
28
|
|
29
|
-
##
|
29
|
+
## Usage
|
30
30
|
|
31
31
|
create an instance
|
32
32
|
|
@@ -37,14 +37,53 @@ create an instance
|
|
37
37
|
:port => icingaApiPort,
|
38
38
|
:user => icingaApiUser,
|
39
39
|
:pass => icingaApiPass
|
40
|
-
}
|
41
|
-
:cluster => icingaCluster,
|
42
|
-
:satellite => icingaSatellite,
|
40
|
+
}
|
43
41
|
}
|
44
42
|
}
|
45
43
|
|
46
44
|
@icinga = Icinga::Client.new( config )
|
47
45
|
|
46
|
+
### Use the examples
|
47
|
+
|
48
|
+
You can use the [Icinga Vagrant-Box](https://github.com/Icinga/icinga-vagrant) from the Icinga Team or
|
49
|
+
my own [Docker Container](https://hub.docker.com/r/bodsch/docker-icinga2/) as Datasource.
|
50
|
+
|
51
|
+
**Remember** Change the exported Environment Variables to your choosed Datasource!
|
52
|
+
|
53
|
+
you can find many examples under the directory `examples`:
|
54
|
+
|
55
|
+
#$ export ICINGA_HOST=localhost ; export ICINGA_API_USER=root ; export ICINGA_API_PASSWORD=icinga
|
56
|
+
#$ ruby examples/informations.rb
|
57
|
+
#$ ruby examples/statistics.rb
|
58
|
+
#$ ruby examples/users.rb
|
59
|
+
|
60
|
+
and so on.
|
61
|
+
|
62
|
+
### Test via CLI
|
63
|
+
|
64
|
+
#$ irb
|
65
|
+
2.3.0 :001 > require 'icinga2'
|
66
|
+
=> true
|
67
|
+
2.3.0 :002 > config = { :icinga => { :host => 'localhost', :api => { :user => 'root', :pass => 'icinga' } } }
|
68
|
+
=> {:icinga=>{:host=>"localhost", :api=>{:user=>"root", :pass=>"icinga"}}}
|
69
|
+
2.3.0 :003 > i = Icinga2::Client.new( config )
|
70
|
+
|
71
|
+
|
72
|
+
## Create a own gem file
|
73
|
+
|
74
|
+
#$ gem build icinga2.gemspec
|
75
|
+
Successfully built RubyGem
|
76
|
+
Name: icinga2
|
77
|
+
Version: 0.9.0
|
78
|
+
File: icinga2-0.9.0.gem
|
79
|
+
|
80
|
+
## Install local gem
|
81
|
+
|
82
|
+
#$ gem install icinga2
|
83
|
+
Successfully installed icinga2-0.9.0
|
84
|
+
1 gem installed
|
85
|
+
|
86
|
+
|
48
87
|
## Status
|
49
88
|
|
50
89
|
supports the following API Calls:
|
@@ -64,10 +103,10 @@ supports the following API Calls:
|
|
64
103
|
- [Hosts](doc/hosts.md)
|
65
104
|
* [add host](doc/hosts.md#add-host)
|
66
105
|
* [delete host](doc/hosts.md#delete-host)
|
106
|
+
* [modify host](doc/hosts.md#modify-host)
|
67
107
|
* [list hosts](doc/hosts.md#list-hosts)
|
68
108
|
* [check if host exists](doc/hosts.md#host-exists)
|
69
109
|
* [list host objects](doc/hosts.md#list-host-objects)
|
70
|
-
* [adjusted hosts state](doc/hosts.md#hosts-adjusted)
|
71
110
|
* [count of hosts with problems](doc/hosts.md#count-hosts-with-problems)
|
72
111
|
* [list of hosts with problems](doc/hosts.md#list-hosts-with-problems)
|
73
112
|
* [count of all hosts](doc/hosts.md#count-all-hosts)
|
@@ -87,7 +126,6 @@ supports the following API Calls:
|
|
87
126
|
* [list services](doc/services.md#list-services)
|
88
127
|
* [check if service exists](doc/services.md#service-exists)
|
89
128
|
* [list service objects](doc/services.md#list-service-objects)
|
90
|
-
* [adjusted service state](doc/services.md#services-adjusted)
|
91
129
|
* [count services with problems](doc/services.md#count-services-with-problems)
|
92
130
|
* [list of services with problems](doc/services.md#list-services-with-problems)
|
93
131
|
* [count of all services](doc/services.md#count-all-services)
|
@@ -125,34 +163,6 @@ supports the following API Calls:
|
|
125
163
|
* [queue statistics from the api](doc/statistics.md#stats-work-queue)
|
126
164
|
|
127
165
|
|
128
|
-
## create a own gem File
|
129
|
-
|
130
|
-
#$ gem build icinga2.gemspec
|
131
|
-
Successfully built RubyGem
|
132
|
-
Name: icinga2
|
133
|
-
Version: 0.6.0
|
134
|
-
File: icinga2-0.6.0.gem
|
135
|
-
|
136
|
-
## install gem
|
137
|
-
|
138
|
-
#$ gem install icinga2
|
139
|
-
Successfully installed icinga2-0.6.0
|
140
|
-
1 gem installed
|
141
|
-
|
142
|
-
## test via CLI
|
143
|
-
|
144
|
-
#$ irb
|
145
|
-
2.3.0 :001 > require 'icinga2'
|
146
|
-
=> true
|
147
|
-
2.3.0 :002 > config = { :icinga => { :host => 'localhost', :api => { :user => 'root', :pass => 'icinga' } } }
|
148
|
-
=> {:icinga=>{:host=>"localhost", :api=>{:user=>"root", :pass=>"icinga"}}}
|
149
|
-
2.3.0 :003 > i = Icinga2::Client.new( config )
|
150
|
-
|
151
|
-
## test via example
|
152
|
-
#$ export ICINGA_HOST=localhost ; export ICINGA_API_USER=root ; export ICINGA_API_PASSWORD=icinga
|
153
|
-
#$ ruby examples/test.rb
|
154
|
-
|
155
|
-
|
156
166
|
|
157
167
|
## Contributing
|
158
168
|
|
@@ -161,7 +171,3 @@ supports the following API Calls:
|
|
161
171
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
162
172
|
4. Push to the branch (`git push origin my-new-feature`)
|
163
173
|
5. Create new Pull Request
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
data/doc/hosts.md
CHANGED
@@ -5,11 +5,21 @@
|
|
5
5
|
|
6
6
|
### Example
|
7
7
|
param = {
|
8
|
-
|
9
|
-
|
8
|
+
name: 'foo',
|
9
|
+
address: 'foo.bar.com',
|
10
10
|
display_name: 'test node',
|
11
11
|
max_check_attempts: 5,
|
12
|
-
notes: 'test node'
|
12
|
+
notes: 'test node',
|
13
|
+
vars: {
|
14
|
+
description: 'host foo',
|
15
|
+
os: 'Linux',
|
16
|
+
partitions: {
|
17
|
+
'/' => {
|
18
|
+
crit: '95%',
|
19
|
+
warn: '90%'
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
13
23
|
}
|
14
24
|
@icinga.add_host(param)
|
15
25
|
|
@@ -18,7 +28,52 @@
|
|
18
28
|
delete_host( params )
|
19
29
|
|
20
30
|
### Example
|
21
|
-
@icinga.delete_host(
|
31
|
+
@icinga.delete_host(name: 'foo')
|
32
|
+
|
33
|
+
|
34
|
+
## <a name="modify-host"></a>modify a host
|
35
|
+
modify-host( params )
|
36
|
+
|
37
|
+
### Example
|
38
|
+
|
39
|
+
|
40
|
+
param = {
|
41
|
+
name: 'foo',
|
42
|
+
address: 'foo.bar.com',
|
43
|
+
display_name: 'Host for an example Problem',
|
44
|
+
max_check_attempts: 10,
|
45
|
+
}
|
46
|
+
|
47
|
+
or
|
48
|
+
|
49
|
+
param = {
|
50
|
+
name: 'foo',
|
51
|
+
address: 'foo.bar.com',
|
52
|
+
notes: 'an demonstration object',
|
53
|
+
vars: {
|
54
|
+
description: 'schould be delete ASAP',
|
55
|
+
os: 'Linux',
|
56
|
+
partitions: {
|
57
|
+
'/' => {
|
58
|
+
crit: '98%',
|
59
|
+
warn: '95%'
|
60
|
+
}
|
61
|
+
}
|
62
|
+
},
|
63
|
+
merge_vars: true
|
64
|
+
}
|
65
|
+
|
66
|
+
or
|
67
|
+
|
68
|
+
param = {
|
69
|
+
name: 'foo',
|
70
|
+
address: 'foo.bar.com',
|
71
|
+
vars: {
|
72
|
+
description: 'removed all other custom vars',
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
@icinga.modify-host( name: 'foo')
|
22
77
|
|
23
78
|
|
24
79
|
## <a name="list-hosts"></a>list hosts
|
@@ -27,7 +82,7 @@
|
|
27
82
|
hosts( params )
|
28
83
|
|
29
84
|
#### Example
|
30
|
-
@icinga.host(
|
85
|
+
@icinga.host(name: 'icinga2')
|
31
86
|
|
32
87
|
### list all hosts
|
33
88
|
hosts
|
@@ -50,19 +105,6 @@
|
|
50
105
|
@icinga.host_objects(attrs: ['name', 'state'])
|
51
106
|
|
52
107
|
|
53
|
-
## <a name="hosts-adjusted"></a>adjusted hosts state
|
54
|
-
hosts_adjusted
|
55
|
-
|
56
|
-
### Example
|
57
|
-
@icinga.cib_data
|
58
|
-
@icinga.host_objects
|
59
|
-
warning, critical, unknown = @icinga.hosts_adjusted.values
|
60
|
-
|
61
|
-
or
|
62
|
-
h = @icinga.hosts_adjusted
|
63
|
-
down = h.dig(:down_adjusted)
|
64
|
-
|
65
|
-
|
66
108
|
## <a name="count-hosts-with-problems"></a>count of hosts with problems
|
67
109
|
count_hosts_with_problems
|
68
110
|
|
@@ -82,7 +124,6 @@ or
|
|
82
124
|
hosts_all
|
83
125
|
|
84
126
|
### Example
|
85
|
-
@icinga.host_objects
|
86
127
|
@icinga.hosts_all
|
87
128
|
|
88
129
|
|
@@ -90,10 +131,10 @@ or
|
|
90
131
|
host_problems
|
91
132
|
|
92
133
|
### Example
|
93
|
-
@icinga.
|
94
|
-
all, down, critical, unknown = @icinga.host_problems.values
|
134
|
+
all, down, critical, unknown, handled, adjusted = @icinga.host_problems.values
|
95
135
|
|
96
136
|
or
|
137
|
+
|
97
138
|
p = @icinga.host_problems
|
98
139
|
down = h.dig(:down)
|
99
140
|
|
data/doc/services.md
CHANGED
@@ -1,22 +1,40 @@
|
|
1
1
|
# Icinga2 - Services
|
2
2
|
|
3
3
|
|
4
|
-
## <a name="add-service"></a
|
5
|
-
add_services( params )
|
4
|
+
## <a name="add-service"></a>*add_services( params )*
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
Add a Service to Icinga2
|
7
|
+
|
8
|
+
`params` is an `Hash` with following Parameters:
|
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.
|
14
19
|
|
15
|
-
|
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)
|
30
|
+
|
31
|
+
The result are an `Hash`
|
32
|
+
|
33
|
+
### Example
|
16
34
|
|
17
35
|
@icinga.add_services(
|
18
|
-
|
19
|
-
|
36
|
+
host_name: 'foo',
|
37
|
+
name: 'ping4',
|
20
38
|
vars: {
|
21
39
|
attrs: {
|
22
40
|
check_command: 'ping4',
|
@@ -26,14 +44,109 @@
|
|
26
44
|
}
|
27
45
|
)
|
28
46
|
|
47
|
+
or
|
48
|
+
|
49
|
+
@icinga.add_service(
|
50
|
+
host_name: 'foo',
|
51
|
+
name: 'http',
|
52
|
+
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
|
+
}
|
63
|
+
}
|
64
|
+
)
|
65
|
+
|
29
66
|
|
30
|
-
## <a name="list-services"></a>list services
|
31
67
|
|
32
|
-
|
33
|
-
|
68
|
+
## <a name="delete-service"></a>*delete_service( params )*
|
69
|
+
|
70
|
+
Delete an Service From Icinga2
|
71
|
+
|
72
|
+
`params` is an `Hash` with following Parameters:
|
73
|
+
|
74
|
+
| Parameter | Type | Example | Description
|
75
|
+
| :-------------------- | :-----: | :----- | :-----------
|
76
|
+
| `host` | String | `foo` | existing Host for these Service
|
77
|
+
| `name` | String | `ping4` | Service Name they will be deleted
|
78
|
+
| `cascade` | Bool | `true` | delete service also when other objects depend on it (default: `false`)
|
79
|
+
|
80
|
+
|
81
|
+
The result are an `Hash`
|
82
|
+
|
83
|
+
#### Example
|
84
|
+
|
85
|
+
@icinga.delete_service(host_name: 'foo', name: 'ping4')
|
86
|
+
|
87
|
+
or
|
88
|
+
|
89
|
+
@icinga.delete_service(host_name: 'foo', name: 'new_ping4', cascade: true)
|
90
|
+
|
91
|
+
|
92
|
+
## <a name="modify-service"></a>*modify_service( params )*
|
93
|
+
|
94
|
+
Modify an Service.
|
95
|
+
|
96
|
+
`params` is an `Hash` with following Parameters:
|
97
|
+
|
98
|
+
| Parameter | Type | Example | Description
|
99
|
+
| :-------------------- | :-----: | :----- | :-----------
|
100
|
+
| `name` | String | `ping4` | Service Name they will be deleted
|
101
|
+
| `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)
|
108
|
+
|
109
|
+
The result are an `Hash`
|
110
|
+
|
111
|
+
#### Example
|
112
|
+
|
113
|
+
@icinga.modify_service(
|
114
|
+
name: 'http2',
|
115
|
+
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
|
+
}
|
124
|
+
}
|
125
|
+
)
|
126
|
+
|
127
|
+
|
128
|
+
## <a name="unhandled-services"></a>*unhandled_services*
|
129
|
+
|
130
|
+
return all unhandled services
|
131
|
+
|
132
|
+
The result are an `Hash`
|
34
133
|
|
35
134
|
#### Example
|
36
|
-
@icinga.
|
135
|
+
@icinga.unhandled_services
|
136
|
+
|
137
|
+
|
138
|
+
## <a name="list-services"></a>*services* or *services( params )*
|
139
|
+
|
140
|
+
returns all or a named service
|
141
|
+
|
142
|
+
the optional `params` is an `Hash` with following Parameters:
|
143
|
+
|
144
|
+
| Parameter | Type | Example | Description
|
145
|
+
| :-------------------- | :-----: | :----- | :-----------
|
146
|
+
| `host` | String | `foo` | Hostname
|
147
|
+
| `service` | String | `ping4` | service to list
|
148
|
+
|
149
|
+
The result are an `Hash`
|
37
150
|
|
38
151
|
### list all services
|
39
152
|
services
|
@@ -42,96 +155,144 @@
|
|
42
155
|
@icinga.services
|
43
156
|
|
44
157
|
|
45
|
-
|
46
|
-
|
158
|
+
### list named service
|
159
|
+
services( params )
|
47
160
|
|
48
161
|
#### Example
|
49
|
-
@icinga.
|
162
|
+
@icinga.services( host_name: 'icinga2', service: 'ping4' )
|
50
163
|
|
51
|
-
@icinga.delete_service(host: 'foo', service_name: 'new_ping4', cascade: true)
|
52
164
|
|
165
|
+
## <a name="service-exists"></a>*exists_service?( params )*
|
53
166
|
|
54
|
-
|
55
|
-
unhandled_services
|
167
|
+
check if the service exists
|
56
168
|
|
57
|
-
|
58
|
-
@icinga.unhandled_services
|
169
|
+
the optional `params` is an `Hash` with following Parameters:
|
59
170
|
|
171
|
+
| Parameter | Type | Example | Description
|
172
|
+
| :-------------------- | :-----: | :----- | :-----------
|
173
|
+
| `host` | String | `foo` | Hostname
|
174
|
+
| `service` | String | `ping4` | servicename
|
60
175
|
|
61
|
-
|
62
|
-
exists_service?( params )
|
176
|
+
The result are an `Hash`
|
63
177
|
|
64
178
|
### Example
|
65
|
-
@icinga.exists_service?(
|
179
|
+
@icinga.exists_service?( host_name: 'icinga2', service: 'users' )
|
180
|
+
|
181
|
+
|
182
|
+
## <a name="list-service-objects"></a>*service_objects( params )*
|
66
183
|
|
184
|
+
list service objects
|
67
185
|
|
68
|
-
|
69
|
-
|
186
|
+
the optional `params` is an `Hash` with following Parameters:
|
187
|
+
|
188
|
+
| Parameter | Type | Example | Description
|
189
|
+
| :-------------------- | :-----: | :----- | :-----------
|
190
|
+
| `attrs` | Array | `[]` | Array of `attrs`
|
191
|
+
| `filter` | Array | `[]` | Array of `filter`
|
192
|
+
| `joins` | Array | `[]` | Array of `joins`
|
193
|
+
|
194
|
+
For more Examples for Quering Objects read the [Icinga2 Documentation](https://www.icinga.com/docs/icinga2/latest/doc/12-icinga2-api/#querying-objects)
|
195
|
+
|
196
|
+
- defaults for `attrs` are `['name', 'state', 'acknowledgement', 'downtime_depth', 'last_check']`
|
197
|
+
- defaults for `filter` are `[]`
|
198
|
+
- defaults for `joins` are `['host.name','host.state','host.acknowledgement','host.downtime_depth','host.last_check']`
|
199
|
+
|
200
|
+
The result are an `Array`
|
70
201
|
|
71
202
|
### Example
|
72
|
-
@icinga.service_objects(
|
203
|
+
@icinga.service_objects(
|
204
|
+
attrs: ['name', 'state'],
|
205
|
+
joins: ['host.name','host.state']
|
206
|
+
)
|
207
|
+
|
73
208
|
|
209
|
+
## <a name="services-adjusted"></a>*services_adjusted*
|
74
210
|
|
75
|
-
|
76
|
-
|
211
|
+
returns adjusted service state
|
212
|
+
|
213
|
+
The result are an `Hash`
|
77
214
|
|
78
215
|
### Example
|
79
|
-
|
80
|
-
@icinga.service_objects
|
216
|
+
|
81
217
|
warning, critical, unknown = @icinga.services_adjusted.values
|
82
218
|
|
83
219
|
or
|
220
|
+
|
84
221
|
s = @icinga.services_adjusted
|
85
222
|
unknown = s.dig(:unknown)
|
86
223
|
|
87
224
|
|
88
|
-
## <a name="count-services-with-problems"></a
|
89
|
-
|
225
|
+
## <a name="count-services-with-problems"></a>*count_services_with_problems*
|
226
|
+
|
227
|
+
count services with problems
|
228
|
+
|
229
|
+
The result are an `Integer`
|
90
230
|
|
91
231
|
### Example
|
92
232
|
@icinga.count_services_with_problems
|
93
233
|
|
94
234
|
|
95
|
-
## <a name="list-services-with-problems"></a
|
96
|
-
|
235
|
+
## <a name="list-services-with-problems"></a>*list_services_with_problems( max_items )*
|
236
|
+
|
237
|
+
list of services with problems
|
238
|
+
|
239
|
+
The result are an `Hash`
|
97
240
|
|
98
241
|
### Example
|
99
|
-
|
100
|
-
@icinga.list_services_with_problems(10)
|
242
|
+
|
101
243
|
problems, problems_and_severity = @icinga.list_services_with_problems(10).values
|
102
244
|
|
245
|
+
or
|
246
|
+
|
247
|
+
l = @icinga.list_services_with_problems(10)
|
248
|
+
problems_and_severity = l.dig(:services_with_problems_and_severity)
|
249
|
+
|
250
|
+
|
251
|
+
## <a name="services-all"></a>*services_all*
|
103
252
|
|
104
|
-
|
105
|
-
|
253
|
+
count all services
|
254
|
+
|
255
|
+
The result are an `Integer`
|
106
256
|
|
107
257
|
### Example
|
108
|
-
|
258
|
+
|
109
259
|
@icinga.services_all
|
110
260
|
|
111
261
|
|
112
|
-
## <a name="
|
113
|
-
|
262
|
+
## <a name="service-problems"></a>*service_problems*
|
263
|
+
|
264
|
+
returns data with service problems
|
265
|
+
|
266
|
+
The result are an `Hash`
|
114
267
|
|
115
268
|
### Example
|
116
|
-
|
117
|
-
@icinga.
|
118
|
-
all, critical, warning, unknown = @icinga.service_problems_handled.values
|
269
|
+
|
270
|
+
all, warning, critical, unknown, pending, in_downtime, acknowledged, adjusted_warning, adjusted_critical, adjusted_unknown = @icinga.service_problems.values
|
119
271
|
|
120
272
|
or
|
121
|
-
|
273
|
+
|
274
|
+
p = @icinga.service_problems
|
122
275
|
warning = p.dig(:warning)
|
123
276
|
|
124
277
|
|
125
|
-
## <a name=""></a
|
126
|
-
|
278
|
+
## <a name=""></a>*service_severity( params )* (protected)
|
279
|
+
|
280
|
+
calculate a service severity
|
281
|
+
(taken from the IcingaWeb2 Code)
|
282
|
+
|
283
|
+
The result are an `Integer`
|
127
284
|
|
128
285
|
### Example
|
129
286
|
service_severity( {'attrs' => { 'state' => 0.0, 'acknowledgement' => 0.0, 'downtime_depth' => 0.0 } } )
|
130
287
|
|
131
288
|
|
132
289
|
|
133
|
-
## <a name=""></a
|
134
|
-
|
290
|
+
## <a name=""></a>*update_host( hash, host )* (private)
|
291
|
+
|
292
|
+
update host
|
293
|
+
|
294
|
+
The result are an `Hash`
|
135
295
|
|
136
296
|
### Example
|
137
|
-
|
297
|
+
service_severity( {'attrs' => { 'state' => 0.0, 'acknowledgement' => 0.0, 'downtime_depth' => 0.0 } } )
|
298
|
+
|