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.
@@ -9,11 +9,11 @@ module Icinga2
9
9
  # major part of version
10
10
  MAJOR = 0
11
11
  # minor part of version
12
- MINOR = 7
12
+ MINOR = 8
13
13
  # tiny part of version
14
- TINY = 0
14
+ TINY = 1
15
15
  # patch part
16
- PATCH = 1
16
+ PATCH = 2
17
17
 
18
18
  end
19
19
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icinga2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.1
4
+ version: 0.8.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bodo Schulz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-08 00:00:00.000000000 Z
11
+ date: 2017-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -174,6 +174,7 @@ files:
174
174
  - doc/notifications.md
175
175
  - doc/servicegroups.md
176
176
  - doc/services.md
177
+ - doc/statistics.md
177
178
  - doc/status.md
178
179
  - doc/top-level-namespace.html
179
180
  - doc/usergroups.md
@@ -185,10 +186,11 @@ files:
185
186
  - lib/icinga2/hostgroups.rb
186
187
  - lib/icinga2/hosts.rb
187
188
  - lib/icinga2/network.rb
189
+ - lib/icinga2/network.rb-SAVE
188
190
  - lib/icinga2/notifications.rb
189
191
  - lib/icinga2/servicegroups.rb
190
192
  - lib/icinga2/services.rb
191
- - lib/icinga2/status.rb
193
+ - lib/icinga2/statistics.rb
192
194
  - lib/icinga2/tools.rb
193
195
  - lib/icinga2/usergroups.rb
194
196
  - lib/icinga2/users.rb
@@ -1,210 +0,0 @@
1
-
2
- # frozen_string_literal: true
3
-
4
- module Icinga2
5
-
6
- # namespace for status handling
7
- module Status
8
-
9
- # return Icinga2 Application data
10
- #
11
- # @example
12
- # @icinga.application_data
13
- #
14
- # @return [Hash]
15
- #
16
- def application_data
17
-
18
- Network.get(host: nil,
19
- url: format( '%s/v1/status/IcingaApplication', @icinga_api_url_base ),
20
- headers: @headers,
21
- options: @options)
22
- end
23
-
24
- # return Icinga2 CIB
25
- #
26
- # @example
27
- # @icinga.cib_data
28
- #
29
- # @return [Hash]
30
- #
31
- def cib_data
32
-
33
- Network.get(host: nil,
34
- url: format( '%s/v1/status/CIB', @icinga_api_url_base ),
35
- headers: @headers,
36
- options: @options)
37
-
38
- end
39
-
40
- #
41
- #
42
- #
43
- def status_data
44
-
45
- data = Network.get_raw(host: nil,
46
- url: format( '%s/v1/status', @icinga_api_url_base ),
47
- headers: @headers,
48
- options: @options)
49
-
50
- return nil unless data.dig(:status) != 200
51
-
52
- data.dig('results')
53
-
54
- end
55
-
56
- # return Icinga2 API Listener
57
- #
58
- # @example
59
- # @icinga.api_listener
60
- #
61
- # @return [Hash]
62
- #
63
- def api_listener
64
-
65
- Network.get(host: nil,
66
- url: format( '%s/v1/status/ApiListener', @icinga_api_url_base ),
67
- headers: @headers,
68
- options: @options)
69
-
70
- end
71
-
72
- # return queue statistics from the api
73
- #
74
- # @example
75
- # @icinga.work_queue_statistics
76
- #
77
- # @return [Hash]
78
- #
79
- def work_queue_statistics
80
-
81
- stats = {}
82
- data = Network.get_raw(host: nil,
83
- url: format( '%s/v1/status', @icinga_api_url_base ),
84
- headers: @headers,
85
- options: @options)
86
-
87
- return stats if data.nil?
88
-
89
- data = data.dig(:data)
90
-
91
- json_rpc_data = data.dig('ApiListener', 'api', 'json_rpc')
92
- graphite_data = data.dig('GraphiteWriter', 'graphitewriter', 'graphite')
93
- ido_mysql_data = data.dig('IdoMysqlConnection', 'idomysqlconnection', 'ido-mysql')
94
-
95
- a = {}
96
- a['json_rpc'] = json_rpc_data if(json_rpc_data.is_a?(Hash))
97
- a['graphite'] = graphite_data if(graphite_data.is_a?(Hash))
98
- a['ido-mysql'] = ido_mysql_data if(ido_mysql_data.is_a?(Hash))
99
-
100
- key_list = %w[work_queue_item_rate query_queue_item_rate]
101
-
102
- a.each do |k,v|
103
- key_list.each do |key|
104
- if( v.include?( key ))
105
- attr_name = format('%s queue rate', k)
106
- stats[attr_name] = v[key].to_f.round(3)
107
- end
108
- end
109
- end
110
-
111
- stats
112
- end
113
-
114
-
115
- # extract many datas from application_data and cib_data
116
- # and store them in global variables
117
- #
118
- def extract_data
119
-
120
- a_data = application_data
121
-
122
- if( a_data.is_a?(Hash) )
123
-
124
- a_data = a_data.dig('status','icingaapplication','app')
125
-
126
- unless( a_data.nil? )
127
-
128
- # extract
129
- # - version
130
- @version, @revision = parse_version(a_data.dig('version'))
131
-
132
- # - node_name
133
- @node_name = a_data.dig('node_name')
134
-
135
- # - start_time
136
- @start_time = Time.at(a_data.dig('program_start').to_f)
137
- end
138
- end
139
-
140
- c_data = cib_data
141
-
142
- if( c_data.is_a?(Hash) )
143
-
144
- c_data = c_data.dig('status')
145
-
146
- unless( c_data.nil? )
147
-
148
- # extract
149
- # - uptime
150
- uptime = c_data.dig('uptime').round(2)
151
- @uptime = Time.at(uptime).utc.strftime('%H:%M:%S')
152
-
153
- # - avg_latency / avg_execution_time
154
- @avg_latency = c_data.dig('avg_latency').round(2)
155
- @avg_execution_time = c_data.dig('avg_execution_time').round(2)
156
-
157
- # - hosts
158
- @hosts_up = c_data.dig('num_hosts_up').to_i
159
- @hosts_down = c_data.dig('num_hosts_down').to_i
160
- @hosts_in_downtime = c_data.dig('num_hosts_in_downtime').to_i
161
- @hosts_acknowledged = c_data.dig('num_hosts_acknowledged').to_i
162
-
163
- h_objects = host_objects
164
- all_hosts = h_objects.dig(:nodes)
165
-
166
- @hosts_all = all_hosts.size
167
- @hosts_problems = host_problems
168
- @hosts_problems_down = handled_problems(h_objects, Icinga2::HOSTS_DOWN)
169
-
170
- # calculate host problems adjusted by handled problems
171
- # count togther handled host problems
172
- # @hosts_handled_problems = @hosts_handled_warning_problems + @hosts_handled_critical_problems + @hosts_handled_unknown_problems
173
- # @hosts_down_adjusted = @hosts_down - @hosts_handled_problems
174
-
175
- # - services
176
- @services_ok = c_data.dig('num_services_ok').to_i
177
- @services_warning = c_data.dig('num_services_warning').to_i
178
- @services_critical = c_data.dig('num_services_critical').to_i
179
- @services_unknown = c_data.dig('num_services_unknown').to_i
180
- @services_in_downtime = c_data.dig('num_services_in_downtime').to_i
181
- @services_acknowledged = c_data.dig('num_services_acknowledged').to_i
182
-
183
- s_objects = service_objects
184
- all_services = s_objects.dig(:nodes)
185
-
186
- @services_all = all_services.size
187
- @services_problems = service_problems
188
- @services_handled_warning_problems = handled_problems(s_objects, Icinga2::SERVICE_STATE_WARNING)
189
- @services_handled_critical_problems = handled_problems(s_objects, Icinga2::SERVICE_STATE_CRITICAL)
190
- @services_handled_unknown_problems = handled_problems(s_objects, Icinga2::SERVICE_STATE_UNKNOWN)
191
-
192
- # calculate service problems adjusted by handled problems
193
- @services_warning_adjusted = @services_warning - @services_handled_warning_problems
194
- @services_critical_adjusted = @services_critical - @services_handled_critical_problems
195
- @services_unknown_adjusted = @services_unknown - @services_handled_unknown_problems
196
-
197
-
198
- # - check stats
199
- @hosts_active_checks_1min = c_data.dig('active_host_checks_1min')
200
- @hosts_passive_checks_1min = c_data.dig('passive_host_checks_1min')
201
- @services_active_checks_1min = c_data.dig('active_service_checks_1min')
202
- @services_passive_checks_1min = c_data.dig('passive_service_checks_1min')
203
-
204
- @service_problems, @service_problems_severity = problem_services
205
- end
206
- end
207
- end
208
-
209
- end
210
- end