cloud-mu 3.6.10 → 3.6.11
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/Berksfile +2 -3
- data/Berksfile.lock +11 -14
- data/bin/mu-aws-setup +16 -4
- data/bin/mu-configure +2 -1
- data/cloud-mu.gemspec +2 -2
- data/cookbooks/mu-firewall/Berksfile +1 -1
- data/cookbooks/mu-firewall/attributes/default.rb +2 -2
- data/cookbooks/mu-firewall/metadata.rb +3 -3
- data/cookbooks/mu-firewall/recipes/default.rb +11 -2
- data/cookbooks/mu-master/Berksfile +1 -1
- data/cookbooks/mu-master/attributes/default.rb +14 -1
- data/cookbooks/mu-master/files/default/389ds-perl/ASDialogs.pm +173 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminMigration.pm +569 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminServer.pm +952 -0
- data/cookbooks/mu-master/files/default/389ds-perl/AdminUtil.pm +983 -0
- data/cookbooks/mu-master/files/default/389ds-perl/ConfigDSDialogs.pm +449 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSCreate.pm +1551 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSDialogs.pm +233 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSMigration.pm +1175 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUpdate.pm +534 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUpdateDialogs.pm +152 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DSUtil.pm +1710 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Dialog.pm +249 -0
- data/cookbooks/mu-master/files/default/389ds-perl/DialogManager.pm +212 -0
- data/cookbooks/mu-master/files/default/389ds-perl/FileConn.pm +461 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Inf.pm +268 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Migration.pm +327 -0
- data/cookbooks/mu-master/files/default/389ds-perl/RegDSDialogs.pm +94 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Resource.pm +137 -0
- data/cookbooks/mu-master/files/default/389ds-perl/Setup.pm +240 -0
- data/cookbooks/mu-master/files/default/389ds-perl/SetupDialogs.pm +243 -0
- data/cookbooks/mu-master/files/default/389ds-perl/SetupLog.pm +82 -0
- data/cookbooks/mu-master/files/default/setCertName.ldif +4 -0
- data/cookbooks/mu-master/libraries/mu.rb +2 -2
- data/cookbooks/mu-master/metadata.rb +1 -1
- data/cookbooks/mu-master/recipes/389ds.rb +71 -32
- data/cookbooks/mu-master/recipes/basepackages.rb +5 -0
- data/cookbooks/mu-master/recipes/default.rb +16 -5
- data/cookbooks/mu-master/recipes/init.rb +36 -3
- data/cookbooks/mu-master/recipes/ssl-certs.rb +6 -0
- data/cookbooks/mu-master/recipes/sssd.rb +85 -62
- data/cookbooks/mu-master/recipes/update_nagios_only.rb +7 -1
- data/cookbooks/mu-master/templates/default/389-directory-setup.inf.erb +11 -26
- data/cookbooks/mu-master/templates/default/sssd.conf.erb +18 -8
- data/cookbooks/mu-tools/files/default/Mu_CA.pem +33 -0
- data/cookbooks/mu-tools/metadata.rb +0 -1
- data/cookbooks/mu-tools/recipes/set_local_fw.rb +7 -1
- data/cookbooks/mu-tools/templates/amazon/sshd_config.erb +5 -1
- data/cookbooks/nagios/CHANGELOG.md +679 -0
- data/cookbooks/nagios/LICENSE +201 -0
- data/cookbooks/nagios/README.md +340 -0
- data/cookbooks/nagios/attributes/config.rb +163 -0
- data/cookbooks/nagios/attributes/default.rb +204 -0
- data/cookbooks/nagios/libraries/base.rb +311 -0
- data/cookbooks/nagios/libraries/command.rb +68 -0
- data/cookbooks/nagios/libraries/contact.rb +229 -0
- data/cookbooks/nagios/libraries/contactgroup.rb +111 -0
- data/cookbooks/{firewall/recipes/disable_firewall.rb → nagios/libraries/custom_option.rb} +20 -7
- data/cookbooks/nagios/libraries/data_bag_helper.rb +23 -0
- data/cookbooks/nagios/libraries/default.rb +90 -0
- data/cookbooks/nagios/libraries/helpers.rb +229 -0
- data/cookbooks/nagios/libraries/host.rb +410 -0
- data/cookbooks/nagios/libraries/hostdependency.rb +178 -0
- data/cookbooks/nagios/libraries/hostescalation.rb +170 -0
- data/cookbooks/nagios/libraries/hostgroup.rb +117 -0
- data/cookbooks/nagios/libraries/nagios.rb +277 -0
- data/cookbooks/nagios/libraries/resource.rb +59 -0
- data/cookbooks/nagios/libraries/service.rb +449 -0
- data/cookbooks/nagios/libraries/servicedependency.rb +213 -0
- data/cookbooks/nagios/libraries/serviceescalation.rb +193 -0
- data/cookbooks/nagios/libraries/servicegroup.rb +142 -0
- data/cookbooks/nagios/libraries/timeperiod.rb +159 -0
- data/cookbooks/nagios/libraries/users_helper.rb +54 -0
- data/cookbooks/nagios/metadata.json +44 -0
- data/cookbooks/nagios/metadata.rb +22 -0
- data/cookbooks/nagios/recipes/_load_databag_config.rb +153 -0
- data/cookbooks/nagios/recipes/_load_default_config.rb +241 -0
- data/cookbooks/nagios/recipes/apache.rb +114 -0
- data/cookbooks/nagios/recipes/default.rb +41 -0
- data/cookbooks/nagios/recipes/nginx.rb +114 -0
- data/cookbooks/nagios/recipes/pagerduty.rb +95 -0
- data/cookbooks/nagios/recipes/server.rb +182 -0
- data/cookbooks/nagios/recipes/server_package.rb +85 -0
- data/cookbooks/nagios/recipes/server_source.rb +137 -0
- data/cookbooks/nagios/resources/command.rb +34 -0
- data/cookbooks/nagios/resources/conf.rb +52 -0
- data/cookbooks/nagios/resources/contact.rb +34 -0
- data/cookbooks/nagios/resources/contactgroup.rb +35 -0
- data/cookbooks/nagios/resources/host.rb +35 -0
- data/cookbooks/nagios/resources/hostdependency.rb +35 -0
- data/cookbooks/nagios/resources/hostescalation.rb +36 -0
- data/cookbooks/nagios/resources/hostgroup.rb +35 -0
- data/cookbooks/nagios/resources/resource.rb +34 -0
- data/cookbooks/nagios/resources/service.rb +35 -0
- data/cookbooks/nagios/resources/servicedependency.rb +35 -0
- data/cookbooks/nagios/resources/serviceescalation.rb +35 -0
- data/cookbooks/nagios/resources/servicegroup.rb +35 -0
- data/cookbooks/nagios/resources/timeperiod.rb +35 -0
- data/cookbooks/nagios/templates/apache2.conf.erb +102 -0
- data/cookbooks/nagios/templates/cgi.cfg.erb +266 -0
- data/cookbooks/nagios/templates/commands.cfg.erb +13 -0
- data/cookbooks/nagios/templates/contacts.cfg.erb +37 -0
- data/cookbooks/nagios/templates/hostgroups.cfg.erb +25 -0
- data/cookbooks/nagios/templates/hosts.cfg.erb +15 -0
- data/cookbooks/nagios/templates/htpasswd.users.erb +6 -0
- data/cookbooks/nagios/templates/nagios.cfg.erb +22 -0
- data/cookbooks/nagios/templates/nginx.conf.erb +80 -0
- data/cookbooks/nagios/templates/pagerduty.cgi.erb +185 -0
- data/cookbooks/nagios/templates/resource.cfg.erb +27 -0
- data/cookbooks/nagios/templates/servicedependencies.cfg.erb +15 -0
- data/cookbooks/nagios/templates/servicegroups.cfg.erb +14 -0
- data/cookbooks/nagios/templates/services.cfg.erb +14 -0
- data/cookbooks/nagios/templates/spawn-fcgi.erb +10 -0
- data/cookbooks/nagios/templates/templates.cfg.erb +31 -0
- data/cookbooks/nagios/templates/timeperiods.cfg.erb +13 -0
- data/extras/platform_berksfile_base +3 -3
- data/extras/python_rpm/build.sh +4 -4
- data/extras/python_rpm/muthon.spec +2 -4
- data/extras/vault_tools/export_vaults.sh +11 -1
- data/install/installer +1 -1
- data/modules/mu/kittens.rb +27523 -0
- data/modules/mu/master/ldap.rb +48 -31
- data/modules/mu/master.rb +69 -0
- data/modules/mu/mu.yaml.rb +351 -0
- data/modules/mu/providers/aws/firewall_rule.rb +3 -1
- data/modules/mu/providers/aws.rb +11 -5
- data/modules/mu.rb +5 -4
- metadata +99 -48
- data/cookbooks/firewall/CHANGELOG.md +0 -488
- data/cookbooks/firewall/LICENSE +0 -202
- data/cookbooks/firewall/README.md +0 -366
- data/cookbooks/firewall/TODO.md +0 -6
- data/cookbooks/firewall/attributes/default.rb +0 -5
- data/cookbooks/firewall/attributes/firewalld.rb +0 -8
- data/cookbooks/firewall/attributes/iptables.rb +0 -17
- data/cookbooks/firewall/attributes/ufw.rb +0 -12
- data/cookbooks/firewall/attributes/windows.rb +0 -8
- data/cookbooks/firewall/libraries/helpers.rb +0 -105
- data/cookbooks/firewall/libraries/helpers_firewalld.rb +0 -116
- data/cookbooks/firewall/libraries/helpers_firewalld_dbus.rb +0 -72
- data/cookbooks/firewall/libraries/helpers_iptables.rb +0 -112
- data/cookbooks/firewall/libraries/helpers_nftables.rb +0 -170
- data/cookbooks/firewall/libraries/helpers_ufw.rb +0 -142
- data/cookbooks/firewall/libraries/helpers_windows.rb +0 -129
- data/cookbooks/firewall/libraries/provider_firewall_firewalld.rb +0 -179
- data/cookbooks/firewall/libraries/provider_firewall_iptables.rb +0 -171
- data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu.rb +0 -200
- data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu1404.rb +0 -200
- data/cookbooks/firewall/libraries/provider_firewall_rule.rb +0 -34
- data/cookbooks/firewall/libraries/provider_firewall_ufw.rb +0 -138
- data/cookbooks/firewall/libraries/provider_firewall_windows.rb +0 -126
- data/cookbooks/firewall/libraries/resource_firewall.rb +0 -26
- data/cookbooks/firewall/libraries/resource_firewall_rule.rb +0 -52
- data/cookbooks/firewall/metadata.json +0 -40
- data/cookbooks/firewall/metadata.rb +0 -15
- data/cookbooks/firewall/recipes/default.rb +0 -76
- data/cookbooks/firewall/recipes/firewalld.rb +0 -87
- data/cookbooks/firewall/resources/firewalld.rb +0 -28
- data/cookbooks/firewall/resources/firewalld_config.rb +0 -39
- data/cookbooks/firewall/resources/firewalld_helpers.rb +0 -106
- data/cookbooks/firewall/resources/firewalld_icmptype.rb +0 -88
- data/cookbooks/firewall/resources/firewalld_ipset.rb +0 -104
- data/cookbooks/firewall/resources/firewalld_policy.rb +0 -115
- data/cookbooks/firewall/resources/firewalld_service.rb +0 -98
- data/cookbooks/firewall/resources/firewalld_zone.rb +0 -118
- data/cookbooks/firewall/resources/nftables.rb +0 -71
- data/cookbooks/firewall/resources/nftables_rule.rb +0 -113
- data/cookbooks/firewall/templates/default/ufw/default.erb +0 -13
- /data/cookbooks/{firewall → nagios}/chefignore +0 -0
- /data/cookbooks/{firewall → nagios}/renovate.json +0 -0
@@ -0,0 +1,410 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Sander Botman <sbotman@schubergphilis.com>
|
3
|
+
# Cookbook:: nagios
|
4
|
+
# Library:: host
|
5
|
+
#
|
6
|
+
# Copyright:: 2014, Sander Botman
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
require_relative 'base'
|
22
|
+
|
23
|
+
class Nagios
|
24
|
+
#
|
25
|
+
# This class holds all methods with regard to host options,
|
26
|
+
# that are used within nagios configurations.
|
27
|
+
#
|
28
|
+
class Host < Nagios::Base
|
29
|
+
attr_reader :host_name,
|
30
|
+
:parents,
|
31
|
+
:hostgroups,
|
32
|
+
:contacts,
|
33
|
+
:contact_groups,
|
34
|
+
:custom_options
|
35
|
+
|
36
|
+
attr_accessor :alias,
|
37
|
+
:display_name,
|
38
|
+
:address,
|
39
|
+
:check_command,
|
40
|
+
:initial_state,
|
41
|
+
:max_check_attempts,
|
42
|
+
:check_interval,
|
43
|
+
:retry_interval,
|
44
|
+
:active_checks_enabled,
|
45
|
+
:passive_checks_enabled,
|
46
|
+
:check_period,
|
47
|
+
:obsess_over_host,
|
48
|
+
:check_freshness,
|
49
|
+
:freshness_threshold,
|
50
|
+
:event_handler,
|
51
|
+
:event_handler_enabled,
|
52
|
+
:low_flap_threshold,
|
53
|
+
:high_flap_threshold,
|
54
|
+
:flap_detection_enabled,
|
55
|
+
:flap_detection_options,
|
56
|
+
:process_perf_data,
|
57
|
+
:retain_status_information,
|
58
|
+
:retain_nonstatus_information,
|
59
|
+
:notification_interval,
|
60
|
+
:first_notification_delay,
|
61
|
+
:notification_period,
|
62
|
+
:notification_options,
|
63
|
+
:notifications_enabled,
|
64
|
+
:stalking_options,
|
65
|
+
:notes,
|
66
|
+
:notes_url,
|
67
|
+
:action_url,
|
68
|
+
:icon_image,
|
69
|
+
:icon_image_alt,
|
70
|
+
:vrml_image,
|
71
|
+
:statusmap_image,
|
72
|
+
:_2d_coords,
|
73
|
+
:_3d_coords
|
74
|
+
|
75
|
+
def initialize(host_name)
|
76
|
+
@host_name = hostname(host_name)
|
77
|
+
@hostgroups = {}
|
78
|
+
@parents = {}
|
79
|
+
@contacts = {}
|
80
|
+
@contact_groups = {}
|
81
|
+
@check_period = nil
|
82
|
+
@notification_period = nil
|
83
|
+
@custom_options = {}
|
84
|
+
super()
|
85
|
+
end
|
86
|
+
|
87
|
+
def check_period
|
88
|
+
get_timeperiod(@check_period)
|
89
|
+
end
|
90
|
+
|
91
|
+
# contacts
|
92
|
+
# This is a list of the short names of the contacts that should be notified
|
93
|
+
# whenever there are problems (or recoveries) with this host.
|
94
|
+
# Multiple contacts should be separated by commas.
|
95
|
+
# Useful if you want notifications to go to just a few people and don't want
|
96
|
+
# to configure contact groups.
|
97
|
+
# You must specify at least one contact or contact group in each host definition.
|
98
|
+
def contacts_list
|
99
|
+
@contacts.values.map(&:to_s).sort.join(',')
|
100
|
+
end
|
101
|
+
|
102
|
+
# contact_groups
|
103
|
+
# This is a list of the short names of the contact groups that should be notified
|
104
|
+
# whenever there are problems (or recoveries) with this host.
|
105
|
+
# Multiple contact groups should be separated by commas.
|
106
|
+
# You must specify at least one contact or contact group in each host definition.
|
107
|
+
def contact_groups_list
|
108
|
+
@contact_groups.values.map(&:to_s).sort.join(',')
|
109
|
+
end
|
110
|
+
|
111
|
+
def definition
|
112
|
+
configured = configured_options
|
113
|
+
custom_options.each { |_, v| configured[v.to_s] = v.value }
|
114
|
+
get_definition(configured, 'host')
|
115
|
+
end
|
116
|
+
|
117
|
+
# hostgroups
|
118
|
+
# This directive is used to identify the short name(s) of the hostgroup(s)
|
119
|
+
# that the host belongs to. Multiple hostgroups should be separated by commas.
|
120
|
+
# This directive may be used as an alternative to (or in addition to)
|
121
|
+
# using the members directive in hostgroup definitions.
|
122
|
+
def hostgroups_list
|
123
|
+
@hostgroups.values.map(&:to_s).sort.join(',')
|
124
|
+
end
|
125
|
+
|
126
|
+
def import(hash)
|
127
|
+
update_options(hash)
|
128
|
+
update_members(hash, 'parents', Nagios::Host)
|
129
|
+
update_members(hash, 'contacts', Nagios::Contact)
|
130
|
+
update_members(hash, 'contact_groups', Nagios::Contactgroup)
|
131
|
+
update_members(hash, 'hostgroups', Nagios::Hostgroup, true)
|
132
|
+
end
|
133
|
+
|
134
|
+
def notification_period
|
135
|
+
get_timeperiod(@notification_period)
|
136
|
+
end
|
137
|
+
|
138
|
+
def notifications
|
139
|
+
@notifications_enabled
|
140
|
+
end
|
141
|
+
|
142
|
+
def notifications=(arg)
|
143
|
+
@notifications_enabled = check_bool(arg)
|
144
|
+
end
|
145
|
+
|
146
|
+
# parents
|
147
|
+
# This directive is used to define a comma-delimited list of short names of
|
148
|
+
# the "parent" hosts for this particular host. Parent hosts are typically routers,
|
149
|
+
# switches, firewalls, etc. that lie between the monitoring host and a remote hosts.
|
150
|
+
# A router, switch, etc. which is closest to the remote host is considered
|
151
|
+
# to be that host's "parent".
|
152
|
+
# If this host is on the same network segment as the host doing the monitoring
|
153
|
+
# (without any intermediate routers, etc.) the host is considered to be on the local
|
154
|
+
# network and will not have a parent host.
|
155
|
+
def parents_list
|
156
|
+
@parents.values.map(&:to_s).sort.join(',')
|
157
|
+
end
|
158
|
+
|
159
|
+
def push(obj)
|
160
|
+
case obj
|
161
|
+
when Nagios::Hostgroup
|
162
|
+
push_object(obj, @hostgroups)
|
163
|
+
when Nagios::Host
|
164
|
+
push_object(obj, @parents)
|
165
|
+
when Nagios::Contact
|
166
|
+
push_object(obj, @contacts)
|
167
|
+
when Nagios::Contactgroup
|
168
|
+
push_object(obj, @contact_groups)
|
169
|
+
when Nagios::Timeperiod
|
170
|
+
@check_period = obj
|
171
|
+
@notification_period = obj
|
172
|
+
when Nagios::CustomOption
|
173
|
+
push_object(obj, @custom_options)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def pop(obj)
|
178
|
+
return if obj == self
|
179
|
+
case obj
|
180
|
+
when Nagios::Hostgroup
|
181
|
+
if @hostgroups.key?(obj.to_s)
|
182
|
+
pop_object(obj, @hostgroups)
|
183
|
+
obj.pop(self)
|
184
|
+
end
|
185
|
+
when Nagios::Host
|
186
|
+
if @parents.key?(obj.to_s)
|
187
|
+
pop_object(obj, @parents)
|
188
|
+
obj.pop(self)
|
189
|
+
end
|
190
|
+
when Nagios::Contact
|
191
|
+
if @contacts.key?(obj.to_s)
|
192
|
+
pop_object(obj, @contacts)
|
193
|
+
obj.pop(self)
|
194
|
+
end
|
195
|
+
when Nagios::Contactgroup
|
196
|
+
if @contact_groups.key?(obj.to_s)
|
197
|
+
pop_object(obj, @contact_groups)
|
198
|
+
obj.pop(self)
|
199
|
+
end
|
200
|
+
when Nagios::Timeperiod
|
201
|
+
@check_period = nil if @check_period == obj
|
202
|
+
@notification_period = nil if @notification_period == obj
|
203
|
+
when Nagios::CustomOption
|
204
|
+
if @custom_options.key?(obj.to_s)
|
205
|
+
pop_object(obj, @custom_options)
|
206
|
+
obj.pop(self)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def self.create(name)
|
212
|
+
Nagios.instance.find(Nagios::Host.new(name))
|
213
|
+
end
|
214
|
+
|
215
|
+
def to_s
|
216
|
+
host_name
|
217
|
+
end
|
218
|
+
|
219
|
+
# check the integer options
|
220
|
+
# default = nil
|
221
|
+
|
222
|
+
def max_check_attempts=(int)
|
223
|
+
@max_check_attempts = check_integer(int)
|
224
|
+
end
|
225
|
+
|
226
|
+
def check_interval=(int)
|
227
|
+
@check_interval = check_integer(int)
|
228
|
+
end
|
229
|
+
|
230
|
+
def retry_interval=(int)
|
231
|
+
@retry_interval = check_integer(int)
|
232
|
+
end
|
233
|
+
|
234
|
+
def freshness_threshold=(int)
|
235
|
+
@freshness_threshold = check_integer(int)
|
236
|
+
end
|
237
|
+
|
238
|
+
def low_flap_threshold=(int)
|
239
|
+
@low_flap_threshold = check_integer(int)
|
240
|
+
end
|
241
|
+
|
242
|
+
def high_flap_threshold=(int)
|
243
|
+
@high_flap_threshold = check_integer(int)
|
244
|
+
end
|
245
|
+
|
246
|
+
def notification_interval=(int)
|
247
|
+
@notification_interval = check_integer(int)
|
248
|
+
end
|
249
|
+
|
250
|
+
def first_notification_delay=(int)
|
251
|
+
@first_notification_delay = check_integer(int)
|
252
|
+
end
|
253
|
+
|
254
|
+
# check the True/False options
|
255
|
+
# default = nil
|
256
|
+
|
257
|
+
def active_checks_enabled=(arg)
|
258
|
+
@active_checks_enabled = check_bool(arg)
|
259
|
+
end
|
260
|
+
|
261
|
+
def passive_checks_enabled=(arg)
|
262
|
+
@passive_checks_enabled = check_bool(arg)
|
263
|
+
end
|
264
|
+
|
265
|
+
def obsess_over_host=(arg)
|
266
|
+
@obsess_over_host = check_bool(arg)
|
267
|
+
end
|
268
|
+
|
269
|
+
def check_freshness=(arg)
|
270
|
+
@check_freshness = check_bool(arg)
|
271
|
+
end
|
272
|
+
|
273
|
+
def event_handler_enabled=(arg)
|
274
|
+
@event_handler_enabled = check_bool(arg)
|
275
|
+
end
|
276
|
+
|
277
|
+
def flap_detection_enabled=(arg)
|
278
|
+
@flap_detection_enabled = check_bool(arg)
|
279
|
+
end
|
280
|
+
|
281
|
+
def process_perf_data=(arg)
|
282
|
+
@process_perf_data = check_bool(arg)
|
283
|
+
end
|
284
|
+
|
285
|
+
def retain_status_information=(arg)
|
286
|
+
@retain_status_information = check_bool(arg)
|
287
|
+
end
|
288
|
+
|
289
|
+
def retain_nonstatus_information=(arg)
|
290
|
+
@retain_nonstatus_information = check_bool(arg)
|
291
|
+
end
|
292
|
+
|
293
|
+
def notifications_enabled=(arg)
|
294
|
+
@notifications_enabled = check_bool(arg)
|
295
|
+
end
|
296
|
+
|
297
|
+
# check other options
|
298
|
+
|
299
|
+
# initial_state
|
300
|
+
# By default Nagios will assume that all hosts are in UP states when it starts.
|
301
|
+
# You can override the initial state for a host by using this directive.
|
302
|
+
# Valid options are:
|
303
|
+
# o = UP,
|
304
|
+
# d = DOWN,
|
305
|
+
# u = UNREACHABLE.
|
306
|
+
def initial_state=(arg)
|
307
|
+
@initial_state = check_state_options(arg, %w(o d u), 'initail_state')
|
308
|
+
end
|
309
|
+
|
310
|
+
# flap_detection_options
|
311
|
+
# This directive is used to determine what host states the flap detection logic will use for this host.
|
312
|
+
# Valid options are a combination of one or more of the following:
|
313
|
+
# o = UP states,
|
314
|
+
# d = DOWN states,
|
315
|
+
# u = UNREACHABLE states.
|
316
|
+
def flap_detection_options=(arg)
|
317
|
+
@flap_detection_options = check_state_options(arg, %w(o d u), 'flap_detection_options')
|
318
|
+
end
|
319
|
+
|
320
|
+
# stalking_options
|
321
|
+
# This directive determines which host states "stalking" is enabled for.
|
322
|
+
# Valid options are a combination of one or more of the following:
|
323
|
+
# o = stalk on UP states,
|
324
|
+
# d = stalk on DOWN states,
|
325
|
+
# u = stalk on UNREACHABLE states.
|
326
|
+
def stalking_options=(arg)
|
327
|
+
@stalking_options = check_state_options(arg, %w(o d u), 'stalking_options')
|
328
|
+
end
|
329
|
+
|
330
|
+
# notification_options
|
331
|
+
# This directive is used to determine when notifications for the host should be sent out.
|
332
|
+
# Valid options are a combination of one or more of the following:
|
333
|
+
# d = send notifications on a DOWN state,
|
334
|
+
# u = send notifications on an UNREACHABLE state,
|
335
|
+
# r = send notifications on recoveries (OK state),
|
336
|
+
# f = send notifications when the host starts and stops flapping
|
337
|
+
# s = send notifications when scheduled downtime starts and ends.
|
338
|
+
# If you specify n (none) as an option, no host notifications will be sent out.
|
339
|
+
# If you do not specify any notification options, Nagios will assume that you want notifications
|
340
|
+
# to be sent out for all possible states.
|
341
|
+
# Example: If you specify d,r in this field, notifications will only be sent out when the host
|
342
|
+
# goes DOWN and when it recovers from a DOWN state.
|
343
|
+
|
344
|
+
def notification_options=(arg)
|
345
|
+
@notification_options = check_state_options(arg, %w(d u r f s n), 'notification_options')
|
346
|
+
end
|
347
|
+
|
348
|
+
private
|
349
|
+
|
350
|
+
def config_options
|
351
|
+
{
|
352
|
+
'name' => 'name',
|
353
|
+
'use' => 'use',
|
354
|
+
'host_name' => 'host_name',
|
355
|
+
'hostgroups_list' => 'hostgroups',
|
356
|
+
'alias' => 'alias',
|
357
|
+
'display_name' => 'display_name',
|
358
|
+
'address' => 'address',
|
359
|
+
'parents_list' => 'parents',
|
360
|
+
'check_command' => 'check_command',
|
361
|
+
'initial_state' => 'initial_state',
|
362
|
+
'max_check_attempts' => 'max_check_attempts',
|
363
|
+
'check_interval' => 'check_interval',
|
364
|
+
'retry_interval' => 'retry_interval',
|
365
|
+
'active_checks_enabled' => 'active_checks_enabled',
|
366
|
+
'passive_checks_enabled' => 'passive_checks_enabled',
|
367
|
+
'check_period' => 'check_period',
|
368
|
+
'obsess_over_host' => 'obsess_over_host',
|
369
|
+
'check_freshness' => 'check_freshness',
|
370
|
+
'freshness_threshold' => 'freshness_threshold',
|
371
|
+
'event_handler' => 'event_handler',
|
372
|
+
'event_handler_enabled' => 'event_handler_enabled',
|
373
|
+
'low_flap_threshold' => 'low_flap_threshold',
|
374
|
+
'high_flap_threshold' => 'high_flap_threshold',
|
375
|
+
'flap_detection_enabled' => 'flap_detection_enabled',
|
376
|
+
'flap_detection_options' => 'flap_detection_options',
|
377
|
+
'process_perf_data' => 'process_perf_data',
|
378
|
+
'retain_status_information' => 'retain_status_information',
|
379
|
+
'retain_nonstatus_information' => 'retain_nonstatus_information',
|
380
|
+
'contacts_list' => 'contacts',
|
381
|
+
'contact_groups_list' => 'contact_groups',
|
382
|
+
'notification_interval' => 'notification_interval',
|
383
|
+
'first_notification_delay' => 'first_notification_delay',
|
384
|
+
'notification_period' => 'notification_period',
|
385
|
+
'notification_options' => 'notification_options',
|
386
|
+
'notifications_enabled' => 'notifications_enabled',
|
387
|
+
'notifications' => nil,
|
388
|
+
'stalking_options' => 'stalking_options',
|
389
|
+
'notes' => 'notes',
|
390
|
+
'notes_url' => 'notes_url',
|
391
|
+
'action_url' => 'action_url',
|
392
|
+
'icon_image' => 'icon_image',
|
393
|
+
'icon_image_alt' => 'icon_image_alt',
|
394
|
+
'vrml_image' => 'vrml_image',
|
395
|
+
'statusmap_image' => 'statusmap_image',
|
396
|
+
'_2d_coords' => '2d_coords',
|
397
|
+
'_3d_coords' => '3d_coords',
|
398
|
+
'register' => 'register',
|
399
|
+
}
|
400
|
+
end
|
401
|
+
|
402
|
+
def merge_members(obj)
|
403
|
+
obj.parents.each { |m| push(m) }
|
404
|
+
obj.contacts.each { |m| push(m) }
|
405
|
+
obj.contact_groups.each { |m| push(m) }
|
406
|
+
obj.hostgroups.each { |m| push(m) }
|
407
|
+
obj.custom_options.each { |_, m| push(m) }
|
408
|
+
end
|
409
|
+
end
|
410
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Sander Botman <sbotman@schubergphilis.com>
|
3
|
+
# Cookbook:: nagios
|
4
|
+
# Library:: hostdependency
|
5
|
+
#
|
6
|
+
# Copyright:: 2014, Sander Botman
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
|
20
|
+
require_relative 'base'
|
21
|
+
|
22
|
+
class Nagios
|
23
|
+
#
|
24
|
+
# This class holds all methods with regard to hostdependency options,
|
25
|
+
# that are used within nagios configurations.
|
26
|
+
#
|
27
|
+
class Hostdependency < Nagios::Base
|
28
|
+
attr_reader :dependent_name,
|
29
|
+
:dependency_period,
|
30
|
+
:dependent_host_name,
|
31
|
+
:dependent_hostgroup_name,
|
32
|
+
:host_name,
|
33
|
+
:hostgroup_name
|
34
|
+
|
35
|
+
attr_accessor :inherits_parent,
|
36
|
+
:execution_failure_criteria,
|
37
|
+
:notification_failure_criteria
|
38
|
+
|
39
|
+
def initialize(name)
|
40
|
+
@dependent_name = name
|
41
|
+
@host_name = {}
|
42
|
+
@hostgroup_name = {}
|
43
|
+
@dependent_host_name = {}
|
44
|
+
@dependent_hostgroup_name = {}
|
45
|
+
super()
|
46
|
+
end
|
47
|
+
|
48
|
+
def definition
|
49
|
+
get_definition(configured_options, 'hostdependency')
|
50
|
+
end
|
51
|
+
|
52
|
+
def dependent_host_name_list
|
53
|
+
@dependent_host_name.values.map(&:to_s).sort.join(',')
|
54
|
+
end
|
55
|
+
|
56
|
+
def dependent_hostgroup_name_list
|
57
|
+
@dependent_hostgroup_name.values.map(&:to_s).sort.join(',')
|
58
|
+
end
|
59
|
+
|
60
|
+
def host_name_list
|
61
|
+
@host_name.values.map(&:to_s).sort.join(',')
|
62
|
+
end
|
63
|
+
|
64
|
+
def hostgroup_name_list
|
65
|
+
@hostgroup_name.values.map(&:to_s).sort.join(',')
|
66
|
+
end
|
67
|
+
|
68
|
+
def import(hash)
|
69
|
+
update_options(hash)
|
70
|
+
update_members(hash, 'host_name', Nagios::Host)
|
71
|
+
update_members(hash, 'hostgroup_name', Nagios::Hostgroup)
|
72
|
+
update_dependency_members(hash, 'dependent_host_name', Nagios::Host)
|
73
|
+
update_dependency_members(hash, 'dependent_hostgroup_name', Nagios::Hostgroup)
|
74
|
+
end
|
75
|
+
|
76
|
+
def push(obj)
|
77
|
+
case obj
|
78
|
+
when Nagios::Host
|
79
|
+
push_object(obj, @host_name)
|
80
|
+
when Nagios::Hostgroup
|
81
|
+
push_object(obj, @hostgroup_name)
|
82
|
+
when Nagios::Timeperiod
|
83
|
+
@dependency_period = obj
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def push_dependency(obj)
|
88
|
+
case obj
|
89
|
+
when Nagios::Host
|
90
|
+
push_object(obj, @dependent_host_name)
|
91
|
+
when Nagios::Hostgroup
|
92
|
+
push_object(obj, @dependent_hostgroup_name)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def pop(obj)
|
97
|
+
return if obj == self
|
98
|
+
case obj
|
99
|
+
when Nagios::Host
|
100
|
+
if @host_name.key?(obj.to_s)
|
101
|
+
pop_object(obj, @host_name)
|
102
|
+
pop(self, obj)
|
103
|
+
end
|
104
|
+
when Nagios::Hostgroup
|
105
|
+
if @hostgroup_name.key?(obj.to_s)
|
106
|
+
pop_object(obj, @hostgroup_name)
|
107
|
+
pop(self, obj)
|
108
|
+
end
|
109
|
+
when Nagios::Timeperiod
|
110
|
+
@dependency_period = nil if @dependency_period == obj
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def pop_dependency(obj)
|
115
|
+
return if obj == self
|
116
|
+
case obj
|
117
|
+
when Nagios::Host
|
118
|
+
if @dependent_host_name.key?(obj.to_s)
|
119
|
+
pop_object(obj, @dependent_host_name)
|
120
|
+
pop(self, obj)
|
121
|
+
end
|
122
|
+
when Nagios::Hostgroup
|
123
|
+
if @dependent_hostgroup_name.key?(obj.to_s)
|
124
|
+
pop_object(obj, @dependent_hostgroup_name)
|
125
|
+
pop(self, obj)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.create(name)
|
131
|
+
Nagios.instance.find(Nagios::Hostdependency.new(name))
|
132
|
+
end
|
133
|
+
|
134
|
+
def to_s
|
135
|
+
dependent_name
|
136
|
+
end
|
137
|
+
|
138
|
+
# check the True/False options
|
139
|
+
# default = nil
|
140
|
+
|
141
|
+
def inherits_parent=(arg)
|
142
|
+
@inherits_parent = check_bool(arg)
|
143
|
+
end
|
144
|
+
|
145
|
+
# check other options
|
146
|
+
|
147
|
+
def execution_failure_criteria=(arg)
|
148
|
+
@execution_failure_criteria = check_state_options(arg, %w(o d u p n), 'execution_failure_criteria')
|
149
|
+
end
|
150
|
+
|
151
|
+
def notification_failure_criteria=(arg)
|
152
|
+
@notification_failure_criteria = check_state_options(arg, %w(o d u p n), 'notification_failure_criteria')
|
153
|
+
end
|
154
|
+
|
155
|
+
private
|
156
|
+
|
157
|
+
def config_options
|
158
|
+
{
|
159
|
+
'dependent_name' => nil,
|
160
|
+
'dependency_period' => 'dependency_period',
|
161
|
+
'dependent_host_name_list' => 'dependent_host_name',
|
162
|
+
'dependent_hostgroup_name_list' => 'dependent_hostgroup_name',
|
163
|
+
'host_name_list' => 'host_name',
|
164
|
+
'hostgroup_name_list' => 'hostgroup_name',
|
165
|
+
'inherits_parent' => 'inherits_parent',
|
166
|
+
'execution_failure_criteria' => 'execution_failure_criteria',
|
167
|
+
'notification_failure_criteria' => 'notification_failure_criteria',
|
168
|
+
}
|
169
|
+
end
|
170
|
+
|
171
|
+
def merge_members(obj)
|
172
|
+
obj.host_name.each { |m| push(m) }
|
173
|
+
obj.hostgroup_name.each { |m| push(m) }
|
174
|
+
obj.dependent_host_name.each { |m| push_dependency(m) }
|
175
|
+
obj.dependent_hostgroup_name.each { |m| push_dependency(m) }
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|