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.
- checksums.yaml +4 -4
- data/README.md +73 -58
- data/doc/Icinga2.html +35 -3
- data/doc/Logging.html +2 -2
- data/doc/_index.html +2 -2
- data/doc/class_list.html +1 -1
- data/doc/downtimes.md +21 -4
- data/doc/file.README.html +118 -66
- data/doc/hostgroups.md +26 -11
- data/doc/hosts.md +93 -20
- data/doc/index.html +118 -66
- data/doc/method_list.html +84 -300
- data/doc/notifications.md +42 -14
- data/doc/servicegroups.md +28 -11
- data/doc/services.md +91 -21
- data/doc/statistics.md +54 -0
- data/doc/top-level-namespace.html +1 -1
- data/doc/usergroups.md +25 -4
- data/doc/users.md +26 -29
- data/examples/test.rb +213 -76
- data/lib/icinga2.rb +256 -71
- data/lib/icinga2/converts.rb +5 -2
- data/lib/icinga2/downtimes.rb +26 -88
- data/lib/icinga2/hostgroups.rb +46 -32
- data/lib/icinga2/hosts.rb +205 -92
- data/lib/icinga2/network.rb +136 -325
- data/lib/icinga2/network.rb-SAVE +1004 -0
- data/lib/icinga2/notifications.rb +49 -72
- data/lib/icinga2/servicegroups.rb +54 -42
- data/lib/icinga2/services.rb +212 -82
- data/lib/icinga2/statistics.rb +191 -0
- data/lib/icinga2/tools.rb +28 -23
- data/lib/icinga2/usergroups.rb +49 -39
- data/lib/icinga2/users.rb +56 -61
- data/lib/icinga2/version.rb +3 -3
- metadata +5 -3
- data/lib/icinga2/status.rb +0 -210
data/doc/notifications.md
CHANGED
@@ -1,32 +1,60 @@
|
|
1
1
|
# Icinga2 - Notifications
|
2
2
|
|
3
3
|
|
4
|
-
## -
|
4
|
+
## <a name="enable-host-notification"></a>enable host notifications
|
5
5
|
enable_host_notification( host )
|
6
6
|
|
7
|
-
|
7
|
+
### Example
|
8
|
+
@icinga.enable_host_notification('icinga')
|
9
|
+
|
10
|
+
|
11
|
+
## <a name="disable-host-notification"></a>disable host notifications
|
8
12
|
disable_host_notification( host )
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
### Example
|
15
|
+
@icinga.disable_host_notification('icinga')
|
16
|
+
|
17
|
+
|
18
|
+
## <a name="enable-service-notification"></a>enable service notifications
|
19
|
+
enable_service_notification( host )
|
12
20
|
|
13
|
-
|
21
|
+
### Example
|
22
|
+
@icinga.enable_service_notification('icinga')
|
23
|
+
|
24
|
+
|
25
|
+
## <a name="disable-service-notification"></a>disable service notifications
|
14
26
|
disable_service_notification( host )
|
15
27
|
|
16
|
-
|
17
|
-
|
28
|
+
### Example
|
29
|
+
@icinga.disable_service_notification('icinga')
|
30
|
+
|
31
|
+
|
32
|
+
## <a name="enable-hostgroup-notification"></a>enable hostgroup notifications
|
33
|
+
enable_hostgroup_notification( params )
|
34
|
+
|
35
|
+
### Example
|
36
|
+
@icinga.enable_hostgroup_notification(host: 'icinga2', host_group: 'linux-servers')
|
37
|
+
|
38
|
+
|
39
|
+
## <a name="disable-hostgroup-notification"></a>disable hostgroup notifications
|
40
|
+
disable_hostgroup_notification( params )
|
41
|
+
|
42
|
+
### Example
|
43
|
+
@icinga.disable_hostgroup_notification(host: 'icinga2', host_group: 'linux-servers')
|
44
|
+
|
45
|
+
|
46
|
+
## <a name="list-notifications"></a>list all notifications
|
47
|
+
notifications
|
18
48
|
|
19
|
-
|
20
|
-
|
49
|
+
### Example
|
50
|
+
@icinga.notifications
|
21
51
|
|
22
|
-
## -
|
23
|
-
notifications( params = {} )
|
24
52
|
|
25
|
-
##
|
53
|
+
## (protected) function for host notifications
|
26
54
|
host_notification( params = {} )
|
27
55
|
|
28
|
-
##
|
56
|
+
## (protected) function for hostgroup notifications
|
29
57
|
hostgroup_notification( params = {} )
|
30
58
|
|
31
|
-
##
|
59
|
+
## (protected) function for service notifications
|
32
60
|
service_notification( params = {} )
|
data/doc/servicegroups.md
CHANGED
@@ -1,22 +1,39 @@
|
|
1
1
|
# Icinga2 - Servicegroups
|
2
2
|
|
3
3
|
|
4
|
-
## add
|
5
|
-
add_servicegroup()
|
4
|
+
## <a name="add-servicegroup"></a>add a servicegroup
|
5
|
+
add_servicegroup( params )
|
6
6
|
|
7
|
+
### Example
|
8
|
+
@icinga.add_servicegroup(service_group: 'foo', display_name: 'FOO')
|
7
9
|
|
8
|
-
## delete
|
9
|
-
delete_servicegroup()
|
10
|
+
## <a name="delete-servicegroup"></a>delete a servicegroup
|
11
|
+
delete_servicegroup( params )
|
10
12
|
|
13
|
+
### Example
|
14
|
+
@icinga.delete_servicegroup(service_group: 'foo')
|
11
15
|
|
12
|
-
##
|
13
|
-
|
16
|
+
## <a name="list-servicegroup"></a>list servicegroups
|
17
|
+
|
18
|
+
### list a named servicegroup
|
19
|
+
servicegroups( params )
|
20
|
+
|
21
|
+
#### Example
|
22
|
+
@icinga.servicegroups(service_group: 'disk')
|
23
|
+
|
24
|
+
### list all servicegroups
|
25
|
+
servicegroups
|
26
|
+
|
27
|
+
#### Example
|
28
|
+
@icinga.servicegroups
|
29
|
+
|
30
|
+
|
31
|
+
## <a name="servicegroup-exists"></a>checks if the servicegroup exists
|
32
|
+
exists_servicegroup?( service_group )
|
33
|
+
|
34
|
+
### Example
|
35
|
+
@icinga.exists_servicegroup?('disk')
|
14
36
|
|
15
|
-
## list
|
16
37
|
|
17
|
-
### named
|
18
|
-
servicegroups()
|
19
38
|
|
20
|
-
### all
|
21
|
-
servicegroups()
|
22
39
|
|
data/doc/services.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
# Icinga2 - Services
|
2
2
|
|
3
3
|
|
4
|
-
## add
|
4
|
+
## <a name="add-service"></a>add services
|
5
|
+
add_services( params )
|
6
|
+
|
7
|
+
**this function is not operable! need help, time and/or beer**
|
8
|
+
|
9
|
+
### Example
|
5
10
|
services = {
|
6
11
|
'service-heap-mem' => {
|
7
12
|
'display_name' => 'Tomcat - Heap Memory',
|
@@ -9,41 +14,106 @@
|
|
9
14
|
}
|
10
15
|
}
|
11
16
|
|
12
|
-
|
17
|
+
@icinga.add_services( 'foo-bar.lan', services )
|
13
18
|
|
14
|
-
## -
|
15
19
|
|
16
|
-
|
20
|
+
## <a name="list-services"></a>list services
|
17
21
|
|
22
|
+
### list named service
|
23
|
+
services( params )
|
18
24
|
|
19
|
-
|
25
|
+
#### Example
|
26
|
+
@icinga.services( host: 'icinga2', service: 'ping4' )
|
20
27
|
|
21
|
-
###
|
22
|
-
services
|
28
|
+
### list all services
|
29
|
+
services
|
23
30
|
|
24
|
-
|
25
|
-
services
|
31
|
+
#### Example
|
32
|
+
@icinga.services
|
26
33
|
|
27
|
-
|
34
|
+
|
35
|
+
## <a name="delete-service"></a>delete
|
28
36
|
**not yet implemented**
|
29
37
|
|
38
|
+
## <a name="unhandled-services"></a>list unhandled_services
|
39
|
+
**not yet implemented**
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
## <a name="service-exists"></a>check if the service exists
|
45
|
+
exists_service?( params )
|
46
|
+
|
47
|
+
### Example
|
48
|
+
@icinga.exists_service?(host: 'icinga2', service: 'users' )
|
49
|
+
|
50
|
+
|
51
|
+
## <a name="list-service-objects"></a>list service objects
|
52
|
+
service_objects( params )
|
53
|
+
|
54
|
+
### Example
|
55
|
+
@icinga.service_objects(attrs: ['name', 'state'], joins: ['host.name','host.state'])
|
56
|
+
|
57
|
+
|
58
|
+
## <a name="services-adjusted"></a>adjusted service state
|
59
|
+
services_adjusted
|
30
60
|
|
61
|
+
### Example
|
62
|
+
@icinga.cib_data
|
63
|
+
@icinga.service_objects
|
64
|
+
warning, critical, unknown = @icinga.services_adjusted.values
|
31
65
|
|
32
|
-
|
33
|
-
|
66
|
+
or
|
67
|
+
s = @icinga.services_adjusted
|
68
|
+
unknown = s.dig(:unknown)
|
34
69
|
|
35
|
-
##
|
36
|
-
service_objects( params = {} )
|
37
70
|
|
71
|
+
## <a name="count-services-with-problems"></a>count services with problems
|
72
|
+
count_services_with_problems
|
38
73
|
|
39
|
-
|
40
|
-
|
74
|
+
### Example
|
75
|
+
@icinga.count_services_with_problems
|
41
76
|
|
42
|
-
##
|
43
|
-
problem_services( max_items = 5 )
|
44
77
|
|
45
|
-
##
|
78
|
+
## <a name="list-services-with-problems"></a>list of services with problems
|
79
|
+
list_services_with_problems( max_items )
|
80
|
+
|
81
|
+
### Example
|
82
|
+
@icinga.list_services_with_problems
|
83
|
+
@icinga.list_services_with_problems(10)
|
84
|
+
problems, problems_and_severity = @icinga.list_services_with_problems(10).values
|
85
|
+
|
86
|
+
|
87
|
+
## <a name="update-host"></a>update host
|
46
88
|
update_host( hash, host )
|
89
|
+
**this function is not operable! need help, time and/or beer**
|
90
|
+
|
91
|
+
### Example
|
92
|
+
|
93
|
+
|
94
|
+
## <a name="count-all-services"></a>count all services
|
95
|
+
services_all
|
96
|
+
|
97
|
+
### Example
|
98
|
+
@icinga.service_objects
|
99
|
+
@icinga.services_all
|
100
|
+
|
101
|
+
|
102
|
+
## <a name="count-all-services-handled"></a>count all services with handled problems
|
103
|
+
service_problems_handled
|
104
|
+
|
105
|
+
### Example
|
106
|
+
@icinga.cib_data
|
107
|
+
@icinga.service_objects
|
108
|
+
all, critical, warning, unknown = @icinga.service_problems_handled.values
|
109
|
+
|
110
|
+
or
|
111
|
+
p = @icinga.service_problems_handled
|
112
|
+
warning = p.dig(:warning)
|
113
|
+
|
114
|
+
|
115
|
+
## <a name=""></a>(protected) calculate a service severity
|
116
|
+
service_severity( params )
|
47
117
|
|
48
|
-
|
49
|
-
service_severity(
|
118
|
+
### Example
|
119
|
+
service_severity( {'attrs' => { 'state' => 0.0, 'acknowledgement' => 0.0, 'downtime_depth' => 0.0 } } )
|
data/doc/statistics.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Icinga2 - Statistics
|
2
|
+
|
3
|
+
|
4
|
+
## <a name="stats-avg"></a>statistic data for latency and execution_time
|
5
|
+
average_statistics
|
6
|
+
|
7
|
+
### Example
|
8
|
+
@icinga.cib_data
|
9
|
+
latency, execution_time = @icinga.average_statistics.values
|
10
|
+
|
11
|
+
or
|
12
|
+
h = @icinga.average_statistics
|
13
|
+
latency = h.dig(:latency)
|
14
|
+
|
15
|
+
## <a name="stats-interval"></a>statistic data for intervall data
|
16
|
+
interval_statistics
|
17
|
+
|
18
|
+
### Example
|
19
|
+
@icinga.cib_data
|
20
|
+
hosts_active_checks, hosts_passive_checks, services_active_checks, services_passive_checks = @icinga.interval_statistics.values
|
21
|
+
|
22
|
+
or
|
23
|
+
i = @icinga.interval_statistics
|
24
|
+
hosts_active_checks = i.dig(:hosts_active_checks)
|
25
|
+
|
26
|
+
|
27
|
+
## <a name="stats-services"></a>statistic data for services
|
28
|
+
service_statistics
|
29
|
+
|
30
|
+
### Example
|
31
|
+
@icinga.cib_data
|
32
|
+
ok, warning, critical, unknown, pending, in_downtime, ack = @icinga.service_statistics.values
|
33
|
+
|
34
|
+
or
|
35
|
+
s = @icinga.service_statistics
|
36
|
+
critical = s.dig(:critical)
|
37
|
+
|
38
|
+
## <a name="stats-hosts"></a>statistic data for hosts
|
39
|
+
host_statistics
|
40
|
+
|
41
|
+
### Example
|
42
|
+
@icinga.cib_data
|
43
|
+
up, down, pending, unreachable, in_downtime, ack = @icinga.host_statistics.values
|
44
|
+
|
45
|
+
or
|
46
|
+
h = @icinga.host_statistics
|
47
|
+
pending = h.dig(:pending)
|
48
|
+
|
49
|
+
## <a name="stats-work-queue"></a>queue statistics from the api
|
50
|
+
work_queue_statistics
|
51
|
+
|
52
|
+
### Example
|
53
|
+
@icinga.work_queue_statistics
|
54
|
+
|
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on
|
103
|
+
Generated on Tue Aug 22 11:29:51 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/doc/usergroups.md
CHANGED
@@ -1,16 +1,37 @@
|
|
1
1
|
# Icinga2 - Usergroups
|
2
2
|
|
3
3
|
|
4
|
-
|
4
|
+
## <a name="add-usergroup"></a>add a usergroup
|
5
|
+
add_usergroup( params )
|
5
6
|
|
7
|
+
### Example
|
8
|
+
@icinga.add_usergroup(user_group: 'foo', display_name: 'FOO')
|
6
9
|
|
7
|
-
delete_usergroup
|
8
10
|
|
11
|
+
## <a name="delete-usergroup"></a>delete a usergroup
|
12
|
+
delete_usergroup( params )
|
9
13
|
|
10
|
-
|
14
|
+
### Example
|
15
|
+
@icinga.delete_usergroup(user_group: 'foo')
|
16
|
+
|
17
|
+
|
18
|
+
## <a name="list-usergroups"></a>list usergroups
|
11
19
|
|
20
|
+
### list named usergroup
|
21
|
+
usergroups( params )
|
22
|
+
|
23
|
+
#### Example
|
24
|
+
@icinga.usergroups(user_group: 'icingaadmins')
|
25
|
+
|
26
|
+
### list all usergroups
|
27
|
+
usergroups
|
12
28
|
|
13
|
-
|
29
|
+
#### Example
|
30
|
+
@icinga.usergroups
|
14
31
|
|
15
32
|
|
33
|
+
## <a name="usergroup-exists"></a>check if the usergroup exists
|
34
|
+
exists_usergroup?( user_group )
|
16
35
|
|
36
|
+
### Example
|
37
|
+
@icinga.exists_usergroup?('icingaadmins')
|
data/doc/users.md
CHANGED
@@ -1,42 +1,39 @@
|
|
1
1
|
# Icinga2 - Users
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
3
|
+
## <a name="add-user"></a>add a user
|
4
|
+
add_user( params )
|
5
|
+
|
6
|
+
### Example
|
7
|
+
params = {
|
8
|
+
user_name: 'foo',
|
9
|
+
display_name: 'FOO',
|
10
|
+
email: 'foo@bar.com',
|
11
|
+
pager: '0000',
|
12
|
+
groups: ['icingaadmins']
|
12
13
|
}
|
14
|
+
@icinga.add_user( params )
|
13
15
|
|
14
|
-
add_user var
|
15
|
-
|
16
|
-
return `Hash`
|
17
|
-
|
18
|
-
## delete User
|
19
16
|
|
20
|
-
|
17
|
+
## <a name="delete-user"></a>delete a user
|
18
|
+
delete_user( params )
|
21
19
|
|
22
|
-
|
20
|
+
### Example
|
21
|
+
@icinga.delete_user(user_name: 'foo')
|
23
22
|
|
24
|
-
## list User
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
users
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
### all Users
|
24
|
+
## <a name="list-users"></a>list users
|
25
|
+
### list named user
|
26
|
+
users( params )
|
27
|
+
#### Example
|
28
|
+
@icinga.users(user_name: 'icingaadmin')
|
33
29
|
|
30
|
+
### list all users
|
34
31
|
users
|
32
|
+
#### Example
|
33
|
+
@icinga.users
|
35
34
|
|
36
|
-
return `Hash`
|
37
|
-
|
38
|
-
## check, if User exists
|
39
35
|
|
40
|
-
|
36
|
+
## <a name="user-exists"></a>checks if the user exists
|
41
37
|
|
42
|
-
|
38
|
+
### Example
|
39
|
+
@icinga.exists_user?('icingaadmin')
|
data/examples/test.rb
CHANGED
@@ -50,152 +50,246 @@ unless( i.nil? )
|
|
50
50
|
#
|
51
51
|
#
|
52
52
|
|
53
|
-
puts '
|
53
|
+
puts ''
|
54
|
+
puts ' ============================================================= '
|
55
|
+
puts '= icinga2 status'
|
56
|
+
puts i.status_data
|
57
|
+
puts ''
|
58
|
+
|
59
|
+
puts '= icinga2 application data'
|
54
60
|
puts i.application_data
|
55
61
|
puts ''
|
56
|
-
puts 'CIB'
|
62
|
+
puts '= CIB'
|
57
63
|
puts i.cib_data
|
58
64
|
puts ''
|
59
|
-
puts 'API Listener'
|
65
|
+
puts '= API Listener'
|
60
66
|
puts i.api_listener
|
67
|
+
puts ''
|
61
68
|
|
69
|
+
v, r = i.version
|
70
|
+
l, e = i.average_statistics
|
71
|
+
puts format( '= version: %s, revision %s', v, r )
|
72
|
+
puts format( '= avg_latency: %s, avg_execution_time %s', l, e )
|
73
|
+
puts format( '= start time: %s', i.start_time )
|
74
|
+
puts format( '= uptime: %s', i.uptime )
|
62
75
|
puts ''
|
63
|
-
puts format( 'version: %s, revision %s', i.version, i.revision )
|
64
|
-
puts format( 'start time: %s', i.start_time )
|
65
|
-
puts format( 'uptime: %s', i.uptime )
|
66
76
|
|
77
|
+
puts ' ------------------------------------------------------------- '
|
78
|
+
puts ''
|
79
|
+
puts ' ==> HOSTS'
|
67
80
|
puts ''
|
68
|
-
|
69
|
-
|
70
|
-
|
81
|
+
|
82
|
+
i.cib_data
|
83
|
+
i.host_objects
|
84
|
+
|
85
|
+
p, a = i.hosts_adjusted
|
86
|
+
|
87
|
+
puts format( '= host handled problems : %d', p )
|
88
|
+
puts format( '= host down adjusted : %d', a )
|
89
|
+
|
90
|
+
puts '= host objects'
|
91
|
+
puts format( '= count of all hosts : %d', i.hosts_all )
|
92
|
+
puts format( '= hosts with problems: %d', i.hosts_problems )
|
93
|
+
puts format( '= hosts are down : %d', i.hosts_down )
|
94
|
+
puts format( '= hosts are critical : %d', i.hosts_critical )
|
95
|
+
puts format( '= hosts are unknown : %d', i.hosts_unknown )
|
96
|
+
puts format( '= count hosts w. problems: %d', i.count_hosts_with_problems )
|
97
|
+
|
98
|
+
['icinga2', 'bp-foo'].each do |h|
|
99
|
+
puts format( '= check if Host \'%s\' exists', h )
|
100
|
+
puts i.exists_host?( h ) ? 'true' : 'false'
|
101
|
+
end
|
71
102
|
|
72
103
|
puts ''
|
73
|
-
puts
|
74
|
-
puts
|
75
|
-
puts format( 'services warning: %d', i.services_warning)
|
76
|
-
puts format( 'services unknown: %d', i.services_unknown)
|
104
|
+
puts '= Problem Hosts'
|
105
|
+
puts i.list_hosts_with_problems
|
77
106
|
puts ''
|
78
|
-
|
79
|
-
|
80
|
-
|
107
|
+
|
108
|
+
['icinga2', 'bp-foo'].each do |h|
|
109
|
+
puts format('= list named Hosts \'%s\'', h )
|
110
|
+
puts i.hosts( host: h )
|
111
|
+
end
|
112
|
+
|
81
113
|
puts ''
|
82
|
-
puts
|
83
|
-
puts
|
84
|
-
puts
|
114
|
+
puts '= list all Hosts'
|
115
|
+
puts i.hosts
|
116
|
+
puts ' = delete Host'
|
117
|
+
puts i.delete_host( host: 'foo' )
|
118
|
+
puts ' = add Host'
|
119
|
+
puts i.add_host(
|
120
|
+
host: 'foo',
|
121
|
+
fqdn: 'foo.bar.com',
|
122
|
+
display_name: 'test node',
|
123
|
+
max_check_attempts: 5,
|
124
|
+
notes: 'test node'
|
125
|
+
)
|
126
|
+
puts ''
|
127
|
+
puts ' ------------------------------------------------------------- '
|
85
128
|
puts ''
|
86
129
|
|
87
|
-
puts '
|
88
|
-
puts i.exists_host?( 'icinga2' ) ? 'true' : 'false'
|
130
|
+
puts ' ------------------------------------------------------------- '
|
89
131
|
puts ''
|
90
|
-
puts '
|
91
|
-
puts i.host_objects
|
132
|
+
puts ' ==> HOSTGROUPS'
|
92
133
|
puts ''
|
93
|
-
puts '
|
94
|
-
puts i.
|
134
|
+
puts '= check if Hostgroup \'linux-servers\' exists'
|
135
|
+
puts i.exists_hostgroup?( 'linux-servers' ) ? 'true' : 'false'
|
95
136
|
puts ''
|
96
|
-
puts '
|
97
|
-
puts i.
|
137
|
+
puts '= list named Hostgroup \'linux-servers\''
|
138
|
+
puts i.hostgroups( host_group: 'linux-servers' )
|
139
|
+
puts '= list named Hostgroup \'foo\''
|
140
|
+
puts i.hostgroups( host_group: 'foo' )
|
98
141
|
puts ''
|
99
|
-
puts 'list
|
100
|
-
puts i.
|
101
|
-
puts i.hosts( host: 'bp-cluster')
|
142
|
+
puts '= list all Hostgroups'
|
143
|
+
puts i.hostgroups
|
102
144
|
puts ''
|
103
|
-
puts '
|
104
|
-
puts i.
|
145
|
+
puts '= add hostgroup \'foo\''
|
146
|
+
puts i.add_hostgroup( host_group: 'foo', display_name: 'FOO' )
|
105
147
|
puts ''
|
106
|
-
|
107
|
-
puts
|
108
|
-
puts i.exists_hostgroup?( 'linux-servers' ) ? 'true' : 'false'
|
148
|
+
puts '= delete Hostgroup \'foo\''
|
149
|
+
puts i.delete_hostgroup( host_group: 'foo' )
|
109
150
|
puts ''
|
110
|
-
puts '
|
111
|
-
puts i.add_hostgroup( hosts_group: 'foo', display_name: 'FOO' )
|
151
|
+
puts ' ------------------------------------------------------------- '
|
112
152
|
puts ''
|
113
|
-
|
114
|
-
puts i.hostgroups( hosts_group: 'foo' )
|
153
|
+
|
115
154
|
puts ''
|
116
|
-
puts '
|
117
|
-
puts i.hostgroups
|
155
|
+
puts ' ------------------------------------------------------------- '
|
118
156
|
puts ''
|
119
|
-
puts '
|
120
|
-
puts i.delete_hostgroup( hosts_group: 'foo' )
|
157
|
+
puts ' ==> SERVICES'
|
121
158
|
puts ''
|
159
|
+
i.service_objects
|
160
|
+
|
161
|
+
warning, critical, unknown = i.services_adjusted
|
122
162
|
|
123
|
-
puts '
|
163
|
+
puts format( '= count of all services: %d', i.services_all )
|
164
|
+
puts format( '= services critical: %d', i.services_critical)
|
165
|
+
puts format( '= services warning: %d', i.services_warning)
|
166
|
+
puts format( '= services unknown: %d', i.services_unknown)
|
167
|
+
puts ''
|
168
|
+
puts format( '= services handled warning problems: %d', i.services_handled_critical)
|
169
|
+
puts format( '= services handled critical problems: %d', i.services_handled_critical)
|
170
|
+
puts format( '= services handled unknown problems: %d', i.services_handled_unknown)
|
171
|
+
puts ''
|
172
|
+
puts format( '= services adjusted warning: %d', warning)
|
173
|
+
puts format( '= services adjusted critical: %d', critical)
|
174
|
+
puts format( '= services adjusted unknown: %d', unknown)
|
175
|
+
puts ''
|
176
|
+
puts '= check if service \'users\' on host \'icinga2\' exists'
|
124
177
|
puts i.exists_service?( host: 'icinga2', service: 'users' ) ? 'true' : 'false'
|
125
178
|
puts ''
|
126
|
-
puts 'get service Objects'
|
179
|
+
puts '= get service Objects'
|
127
180
|
puts i.service_objects
|
128
181
|
puts ''
|
129
|
-
puts '
|
130
|
-
puts i.
|
182
|
+
puts '= Services with problems'
|
183
|
+
puts i.count_services_with_problems
|
131
184
|
puts ''
|
132
|
-
puts 'Problem Services'
|
133
|
-
a,
|
185
|
+
puts '= Problem Services'
|
186
|
+
a,b = i.list_services_with_problems
|
134
187
|
puts a
|
188
|
+
puts b
|
135
189
|
puts ''
|
136
|
-
puts i.
|
190
|
+
puts i.list_services_with_problems(10)
|
137
191
|
puts ''
|
138
|
-
puts 'list named Service \'ping4\' from Host \'icinga2\''
|
192
|
+
puts '= list named Service \'ping4\' from Host \'icinga2\''
|
139
193
|
puts i.services( host: 'icinga2', service: 'ping4' )
|
140
194
|
puts ''
|
141
|
-
puts 'list all Services'
|
195
|
+
puts '= list all Services'
|
142
196
|
puts i.services
|
143
197
|
puts ''
|
198
|
+
puts ' ------------------------------------------------------------- '
|
199
|
+
puts ''
|
144
200
|
|
201
|
+
puts ''
|
202
|
+
puts ' ------------------------------------------------------------- '
|
203
|
+
puts ''
|
204
|
+
puts ' ==> SERVICEGROUPS'
|
205
|
+
puts ''
|
145
206
|
puts 'check if Servicegroup \'disk\' exists'
|
146
207
|
puts i.exists_servicegroup?( 'disk' ) ? 'true' : 'false'
|
147
|
-
puts ''
|
148
|
-
puts '
|
149
|
-
puts i.add_servicegroup( name: 'foo', display_name: 'FOO' )
|
208
|
+
puts 'check if Servicegroup \'foo\' exists'
|
209
|
+
puts i.exists_servicegroup?( 'foo' ) ? 'true' : 'false'
|
150
210
|
puts ''
|
151
211
|
puts 'list named Servicegroup \'foo\''
|
152
|
-
puts i.servicegroups(
|
212
|
+
puts i.servicegroups( service_group: 'foo' )
|
213
|
+
puts 'list named Servicegroup \'disk\''
|
214
|
+
puts i.servicegroups( service_group: 'disk' )
|
153
215
|
puts ''
|
154
216
|
puts 'list all Servicegroup'
|
155
217
|
puts i.servicegroups
|
156
218
|
puts ''
|
157
|
-
puts '
|
158
|
-
puts i.
|
219
|
+
puts 'add Servicegroup \'foo\''
|
220
|
+
puts i.add_servicegroup( service_group: 'foo', display_name: 'FOO' )
|
159
221
|
puts ''
|
160
|
-
|
161
|
-
puts
|
162
|
-
puts i.exists_usergroup?( 'icingaadmins' ) ? 'true' : 'false'
|
222
|
+
puts 'delete Servicegroup \'foo\''
|
223
|
+
puts i.delete_servicegroup( service_group: 'foo' )
|
163
224
|
puts ''
|
164
|
-
puts '
|
165
|
-
puts i.add_usergroup( name: 'foo', display_name: 'FOO' )
|
225
|
+
puts ' ------------------------------------------------------------- '
|
166
226
|
puts ''
|
167
|
-
|
168
|
-
puts i.usergroups( name: 'foo' )
|
227
|
+
|
169
228
|
puts ''
|
170
|
-
puts '
|
171
|
-
puts i.usergroups
|
229
|
+
puts ' ------------------------------------------------------------- '
|
172
230
|
puts ''
|
173
|
-
puts '
|
174
|
-
puts i.delete_usergroup( name: 'foo' )
|
231
|
+
puts ' ==> USERS'
|
175
232
|
puts ''
|
176
|
-
|
177
233
|
puts 'check if User \'icingaadmin\' exists'
|
178
234
|
puts i.exists_user?( 'icingaadmin' ) ? 'true' : 'false'
|
179
235
|
puts ''
|
180
|
-
puts 'add User \'foo\''
|
181
|
-
puts i.add_user( name: 'foo', display_name: 'FOO', email: 'foo@bar.com', pager: '0000', groups: ['icingaadmins'] )
|
182
|
-
puts ''
|
183
236
|
puts 'list named User \'icingaadmin\''
|
184
|
-
puts i.users
|
237
|
+
puts i.users( user_name: 'icingaadmin' )
|
185
238
|
puts ''
|
186
239
|
puts 'list all User'
|
187
240
|
puts i.users
|
188
241
|
puts ''
|
242
|
+
puts 'add User \'foo\''
|
243
|
+
puts i.add_user( user_name: 'foo', display_name: 'FOO', email: 'foo@bar.com', pager: '0000', groups: ['icingaadmins'] )
|
244
|
+
puts ''
|
189
245
|
puts 'delete User \'foo\''
|
190
|
-
puts i.delete_user(
|
246
|
+
puts i.delete_user( user_name: 'foo' )
|
247
|
+
puts ''
|
248
|
+
puts ' ------------------------------------------------------------- '
|
249
|
+
puts ''
|
250
|
+
puts ''
|
251
|
+
puts ' ------------------------------------------------------------- '
|
252
|
+
puts ''
|
253
|
+
puts ' ==> USERGROUPS'
|
254
|
+
puts ''
|
255
|
+
puts 'check if Usergroup \'icingaadmins\' exists'
|
256
|
+
puts i.exists_usergroup?( 'icingaadmins' ) ? 'true' : 'false'
|
257
|
+
puts ''
|
258
|
+
puts 'list named Usergroup \'icingaadmins\''
|
259
|
+
puts i.usergroups( user_group: 'icingaadmins' )
|
260
|
+
puts ''
|
261
|
+
puts 'list all Usergroup'
|
262
|
+
puts i.usergroups
|
263
|
+
puts ''
|
264
|
+
puts 'add Usergroup \'foo\''
|
265
|
+
puts i.add_usergroup( user_group: 'foo', display_name: 'FOO' )
|
266
|
+
puts ''
|
267
|
+
puts 'delete Usergroup \'foo\''
|
268
|
+
puts i.delete_usergroup( user_group: 'foo' )
|
269
|
+
puts ''
|
270
|
+
puts ''
|
271
|
+
puts ' ------------------------------------------------------------- '
|
191
272
|
puts ''
|
192
273
|
|
274
|
+
puts ''
|
275
|
+
puts ' ------------------------------------------------------------- '
|
276
|
+
puts ''
|
277
|
+
puts ' ==> DOWNTIMES'
|
278
|
+
puts ''
|
193
279
|
puts 'add Downtime \'test\''
|
194
|
-
puts i.add_downtime( name: 'test', type: 'service', host: '
|
280
|
+
puts i.add_downtime( name: 'test', type: 'service', host: 'foo', comment: 'test downtime', author: 'icingaadmin', start_time: Time.now.to_i, end_time: Time.now.to_i + 20 )
|
195
281
|
puts ''
|
196
282
|
puts 'list all Downtimes'
|
197
283
|
puts i.downtimes
|
198
284
|
puts ''
|
285
|
+
puts ' ------------------------------------------------------------- '
|
286
|
+
puts ''
|
287
|
+
|
288
|
+
puts ''
|
289
|
+
puts ' ------------------------------------------------------------- '
|
290
|
+
puts ''
|
291
|
+
puts ' ==> NOTIFICATIONS'
|
292
|
+
puts ''
|
199
293
|
puts 'list all Notifications'
|
200
294
|
puts i.notifications
|
201
295
|
puts ''
|
@@ -217,12 +311,55 @@ unless( i.nil? )
|
|
217
311
|
puts 'disable Notifications for hostgroup'
|
218
312
|
puts i.disable_hostgroup_notification( host: 'icinga2', host_group: 'linux-servers')
|
219
313
|
puts ''
|
314
|
+
puts ''
|
315
|
+
puts ' ------------------------------------------------------------- '
|
316
|
+
puts ''
|
220
317
|
|
318
|
+
puts ''
|
319
|
+
puts ' ------------------------------------------------------------- '
|
320
|
+
puts ''
|
321
|
+
puts ' ==> WORK QUEUE STATISTICS'
|
322
|
+
puts ''
|
221
323
|
puts 'work queue statistics'
|
222
324
|
puts i.work_queue_statistics
|
325
|
+
puts ''
|
326
|
+
puts ' ------------------------------------------------------------- '
|
327
|
+
puts ''
|
328
|
+
|
329
|
+
|
330
|
+
# # examples from: https://github.com/saurabh-hirani/icinga2-api-examples
|
331
|
+
# #
|
332
|
+
# # Get display_name, check_command attribute for services applied for filtered hosts matching host.address == 1.2.3.4.
|
333
|
+
# # Join the output with the hosts on which these checks run (services are applied to hosts)
|
334
|
+
# #
|
335
|
+
# puts i.service_objects(
|
336
|
+
# attrs: ["display_name", "check_command"],
|
337
|
+
# filter: "match(\"1.2.3.4\",host.address)" ,
|
338
|
+
# joins: ["host.name", "host.address"]
|
339
|
+
# )
|
340
|
+
#
|
341
|
+
# puts ''
|
342
|
+
#
|
343
|
+
# # Get all services in critical state and filter out the ones for which active checks are disabled
|
344
|
+
# # service.states - 0 = OK, 1 = WARNING, 2 = CRITICAL
|
345
|
+
# #
|
346
|
+
# # { "joins": ["host.name", "host.address"], "filter": "service.state==2", "attrs": ["display_name", "check_command", "enable_active_checks"] }
|
347
|
+
# puts i.service_objects(
|
348
|
+
# attrs: ["display_name", "check_command", "enable_active_checks"],
|
349
|
+
# filter: "service.state==1" ,
|
350
|
+
# joins: ["host.name", "host.address"]
|
351
|
+
# )
|
352
|
+
#
|
353
|
+
# puts ''
|
354
|
+
# # Get host name, address of hosts belonging to a specific hostgroup
|
355
|
+
# puts i.host_objects(
|
356
|
+
# attrs: ["display_name", "name", "address"],
|
357
|
+
# filter: "\"windows-servers\" in host.groups"
|
358
|
+
# )
|
223
359
|
|
224
360
|
end
|
225
361
|
|
362
|
+
|
226
363
|
# -----------------------------------------------------------------------------
|
227
364
|
|
228
365
|
# EOF
|