icinga2 0.6.1 → 0.6.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.
@@ -0,0 +1,12 @@
1
+ # Icinga2 - Status
2
+
3
+
4
+ ## Application Data
5
+ application_data
6
+
7
+ ## CIB Data
8
+ cib_data
9
+
10
+ ## API Listener
11
+ api_listener
12
+
@@ -0,0 +1,110 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+
41
+
42
+ <span class="title">Top Level Namespace</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Top Level Namespace
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <h2>Defined Under Namespace</h2>
82
+ <p class="children">
83
+
84
+
85
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Icinga2.html" title="Icinga2 (module)">Icinga2</a></span>, <span class='object_link'><a href="Logging.html" title="Logging (module)">Logging</a></span>
86
+
87
+
88
+
89
+
90
+ </p>
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ </div>
101
+
102
+ <div id="footer">
103
+ Generated on Sat Jun 17 14:00:30 2017 by
104
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
+ 0.9.9 (ruby-2.3.4).
106
+ </div>
107
+
108
+ </div>
109
+ </body>
110
+ </html>
@@ -41,111 +41,152 @@ i = Icinga2::Client.new( config )
41
41
 
42
42
  unless( i.nil? )
43
43
 
44
- # # run tests ...
45
- # #
46
- # #
44
+ # run tests ...
47
45
  #
48
- puts 'Information about Icinga2:'
49
- puts i.application_data
50
- # puts i.cib_data()
51
- # puts i.api_listener
52
- # puts ''
53
- #
54
- # puts "check if Host 'icinga2-master' exists:"
55
- # puts i.exists_host?( 'icinga2-master' ) ? 'true' : 'false'
56
- # puts "get host Objects from 'icinga2-master'"
57
- # puts i.host_objects
58
- # puts 'Host problems:'
59
- # puts i.host_problems
60
- # puts 'Problem Hosts:'
61
- # puts i.problem_hosts
62
- #
63
- # puts 'list named Hosts:'
64
- # puts i.hosts( name: 'icinga2-master' )
65
- # puts 'list all Hosts:'
66
- # puts i.hosts
67
- # puts ''
68
- #
69
- # puts "check if Hostgroup 'linux-servers' exists:"
70
- # puts i.exists_hostgroup?( 'linux-servers' ) ? 'true' : 'false'
71
- # puts "add hostgroup 'foo'"
72
- # puts i.add_hostgroup( name: 'foo', display_name: 'FOO' )
73
- # puts "list named Hostgroup 'foo'"
74
- # puts i.hostgroups( name: 'foo' )
75
- # puts 'list all Hostgroups:'
76
- # puts i.hostgroups
77
- # puts "delete Hostgroup 'foo'"
78
- # puts i.delete_hostgroup( name: 'foo' )
79
- # puts ''
80
- #
81
- # puts "check if service 'users' on host 'icinga2-master' exists:"
82
- # puts i.exists_service?( host: 'icinga2-master', service: 'users' ) ? 'true' : 'false'
83
46
  #
84
- # puts 'get service Objects'
85
- # puts i.service_objects
86
- # puts 'Service problems:'
87
- # puts i.service_problems
88
- # puts 'Problem Services:'
89
- # puts i.problem_services
90
- #
91
- # puts "list named Service 'ping4' from Host 'icinga2-master'"
92
- # puts i.services( host: 'icinga2-master', service: 'ping4' )
93
- # puts 'list all Services:'
94
- # puts i.services
95
- # puts ''
96
- #
97
- # puts "check if Servicegroup 'disk' exists:"
98
- # puts i.exists_servicegroup?( 'disk' ) ? 'true' : 'false'
99
- # puts "add Servicegroup 'foo'"
100
- # puts i.add_servicegroup( name: 'foo', display_name: 'FOO' )
101
- # puts "list named Servicegroup 'foo'"
102
- # puts i.servicegroups( name: 'foo' )
103
- # puts 'list all Servicegroup:'
104
- # puts i.servicegroups
105
- # puts "delete Servicegroup 'foo'"
106
- # puts i.delete_servicegroup( name: 'foo' )
107
- # puts ''
108
- #
109
- # puts "check if Usergroup 'icingaadmins' exists:"
110
- # puts i.exists_usergroup?( 'icingaadmins' ) ? 'true' : 'false'
111
- # puts "add Usergroup 'foo'"
112
- # puts i.add_usergroup( name: 'foo', display_name: 'FOO' )
113
- # puts "list named Usergroup 'foo'"
114
- # puts i.usergroups( name: 'foo' )
115
- # puts 'list all Usergroup:'
116
- # puts i.usergroups
117
- # puts "delete Usergroup 'foo'"
118
- # puts i.delete_usergroup( name: 'foo' )
119
- # puts ''
120
- #
121
- # puts "check if User 'icingaadmin' exists:"
122
- # puts i.exists_user?( 'icingaadmin' ) ? 'true' : 'false'
123
- # puts "add User 'foo'"
124
- # puts i.add_user( name: 'foo', display_name: 'FOO', email: 'foo@bar.com', pager: '0000', groups: ['icingaadmins'] )
125
- # puts "list named User 'foo'"
126
- # puts i.users( name: 'foo' )
127
- # puts 'list all User:'
128
- # puts i.users
129
- # puts "delete User 'foo'"
130
- # puts i.delete_user( name: 'foo' )
131
- # puts ''
132
-
133
- puts "add Downtime 'test':"
134
- 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 )
135
- puts 'list all Downtimes:'
136
- puts i.downtimes
137
-
138
- puts 'list all Notifications:'
139
- puts i.notifications
140
-
141
- puts 'enable Notifications for host:'
142
- puts i.enable_host_notification( 'icinga2' )
143
- puts 'disable Notifications for host:'
144
- puts i.disable_host_notification( 'icinga2' )
145
-
146
- puts 'disable Notifications for host and services:'
147
- puts i.disable_service_notification( 'icinga2' )
148
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 ''
149
190
 
150
191
  end
151
192
 
@@ -28,9 +28,14 @@ require_relative 'icinga2/users'
28
28
  require_relative 'icinga2/usergroups'
29
29
 
30
30
  # -------------------------------------------------------------------------------------------------------------------
31
-
31
+ # Namespace for classes and modules that handle all Icinga2 API calls
32
32
  module Icinga2
33
33
 
34
+ # Abstract base class for the API calls.
35
+ # Provides some helper methods
36
+ #
37
+ # @author Bodo Schulz
38
+ #
34
39
  class Client
35
40
 
36
41
  include Logging
@@ -73,8 +78,10 @@ module Icinga2
73
78
  # }
74
79
  # }
75
80
  #
76
- # i = Icinga2::Client.new config
81
+ # @icinga = Icinga2::Client.new(config)
82
+ #
77
83
  # @return [instance, #read]
84
+ #
78
85
  def initialize( settings = {} )
79
86
 
80
87
  @icinga_host = settings.dig(:icinga, :host) || 'localhost'
@@ -99,12 +106,13 @@ module Icinga2
99
106
  # @option params [Integer] :user the Icinga2 API User
100
107
  # @option params [Integer] :password the Icinga2 API Password
101
108
  # @example with Certificate
102
- # cert? name_name: 'icinga2-dashing'
109
+ # @icinga.cert?(name_name: 'icinga2-dashing')
103
110
  #
104
111
  # @example with User
105
- # cert? user: 'root' password: 'icinga'
112
+ # @icinga.cert?(user: 'root', password: 'icinga')
106
113
  #
107
114
  # @return [Bool, #read]
115
+ #
108
116
  def cert?( params = {} )
109
117
 
110
118
  node_name = params.dig(:node_name) || 'localhost'
@@ -10,10 +10,10 @@ module Icinga2
10
10
 
11
11
  # convert a Icinga2 state into a human readable state
12
12
  #
13
- # @param [String, #read] state the Icinga2 State
14
- # @param [Bool, #read] is_host if this a Host or a Service Check
13
+ # @param [String] state the Icinga2 State
14
+ # @param [Bool] is_host if this a Host or a Service Check
15
15
  #
16
- # @return [String, #read]
16
+ # @return [String]
17
17
  def self.state_to_string( state, is_host = false )
18
18
 
19
19
  state =
@@ -45,10 +45,10 @@ module Icinga2
45
45
 
46
46
  # convert a Icinga2 state into a named color
47
47
  #
48
- # @param [String, #read] state the Icinga2 State
49
- # @param [Bool, #read] is_host if this a Host or a Service Check
48
+ # @param [String] state the Icinga2 State
49
+ # @param [Bool] is_host if this a Host or a Service Check
50
50
  #
51
- # @return [String, #read]
51
+ # @return [String]
52
52
  def self.state_to_color( state, is_host = false )
53
53
 
54
54
  state =
@@ -80,9 +80,9 @@ module Icinga2
80
80
 
81
81
  # reformat a service check name
82
82
  #
83
- # @param [String, #read] name
83
+ # @param [String] name
84
84
  #
85
- # @return [String, #read]
85
+ # @return [String]
86
86
  def self.format_service( name )
87
87
  service_map = name.split('!', 2)
88
88
  service_map.join( ' - ' )