Configure Nagios to manage service status alerts
* configure Nagios server and Nagios CGI * create a Nagios "virtual" hostname pointing to the management VIP * create service passive checks corresponding to OpenStack service statutes sent by LMA collector * create one Contact with an email for alert notifications Note: we ship our own Nagios manifest due to the fact that all manifests around the place are either not compatible for masterless Puppet environment or not well tested for both Ubuntu and CentOS. Furthermore, this plugin probably doesn't require all Nagios configuration features. implements blueprint lma-infra-alerting-plugin Change-Id: I6faa3a0274b5b7f345a240d9d0ac7925de8a9919
This commit is contained in:
parent
ca1dd3bd3f
commit
1f4d2f8352
|
@ -0,0 +1,54 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
$management_vip = hiera('management_vip')
|
||||
$env_id = hiera('deployment_id')
|
||||
|
||||
$plugin = hiera('lma_infrastructure_alerting')
|
||||
$password = $plugin['nagios_password']
|
||||
$email = $plugin['email']
|
||||
$notify_warning = $plugin['notify_warning']
|
||||
$notify_critical = $plugin['notify_critical']
|
||||
$notify_unknown = $plugin['notify_unknown']
|
||||
$notify_recovery = $plugin['notify_recovery']
|
||||
|
||||
$ceilometer = hiera('ceilometer')
|
||||
$services = {}
|
||||
if $ceilometer['enabled'] {
|
||||
$services['openstack.ceilometer.status'] = true
|
||||
}
|
||||
|
||||
$storage_options = hiera('storage')
|
||||
if $storage_options['objects_ceph']{
|
||||
$services['openstack.radosgw.status'] = true
|
||||
}else{
|
||||
$services['openstack.swift.status'] = true
|
||||
}
|
||||
|
||||
if $plugin['node_name'] == hiera('user_node_name') {
|
||||
class { 'lma_infra_alerting':
|
||||
openstack_deployment_name => $env_id,
|
||||
openstack_management_vip => $management_vip,
|
||||
additional_services => keys($services),
|
||||
# UI password
|
||||
password => $password,
|
||||
# notifications options
|
||||
contact_email => $email,
|
||||
notify_warning => $notify_warning,
|
||||
notify_critical => $notify_critical,
|
||||
notify_recovery => $notify_recovery,
|
||||
notify_unknown => $notify_unknown,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
|
@ -0,0 +1,48 @@
|
|||
LMA Infrastructure Alerting module for Puppet
|
||||
=============================================
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Puppet module for configuring the Alerting system of the LMA
|
||||
(Logging, Monitoring and Alerting) toolchain.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
To deploy Nagios server on a host to handle service status alerts
|
||||
received from the LMA collector.
|
||||
|
||||
```puppet
|
||||
# Configure the common components of the collector service
|
||||
class {'lma_infra_alerting::nagios':
|
||||
openstack_deployment_name => 'openstack-prod',
|
||||
openstack_management_vip => '1.1.1.1',
|
||||
password => 'supersecret',
|
||||
services => ['nova'],
|
||||
contact_email => 'foo@42.fr',
|
||||
notify_critical => true,
|
||||
notify_warning => false,
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Licensed under the terms of the Apache License, version 2.0.
|
||||
|
||||
Contact
|
||||
-------
|
||||
|
||||
Swann Croiset, <scroiset@mirantis.com>
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
See the Contact section.
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Configure Nagios server and Nagios CGI
|
||||
# Add services status monitoring and contact for notifications
|
||||
#
|
||||
class lma_infra_alerting (
|
||||
$openstack_management_vip = undef,
|
||||
$openstack_deployment_name = '',
|
||||
$user = $lma_infra_alerting::params::nagios_http_user,
|
||||
$password = $lma_infra_alerting::params::nagios_http_password,
|
||||
$additional_services = [],
|
||||
$contact_email = $lma_infra_alerting::params::nagios_contact_email,
|
||||
$notify_warning = true,
|
||||
$notify_critical = true,
|
||||
$notify_recovery = true,
|
||||
$notify_unknown = true,
|
||||
) inherits lma_infra_alerting::params {
|
||||
|
||||
validate_array($additional_services)
|
||||
|
||||
$nagios_openstack_vhostname = $lma_infra_alerting::params::nagios_openstack_hostname_prefix
|
||||
$vhostname = "${nagios_openstack_vhostname}-env${$openstack_deployment_name}"
|
||||
|
||||
$core_openstack_services = $lma_infra_alerting::params::openstack_core_services
|
||||
$all_openstack_services = union($core_openstack_services, $additional_services)
|
||||
|
||||
# Install and configure nagios server
|
||||
class { 'lma_infra_alerting::nagios':
|
||||
http_user => $user,
|
||||
http_password => $password,
|
||||
}
|
||||
|
||||
# Configure services
|
||||
class { 'lma_infra_alerting::nagios::service_status':
|
||||
ip => $openstack_management_vip,
|
||||
hostname => $vhostname,
|
||||
services => $all_openstack_services,
|
||||
require => Class['lma_infra_alerting::nagios'],
|
||||
}
|
||||
|
||||
# Configure contacts
|
||||
class { 'lma_infra_alerting::nagios::contact':
|
||||
email => $contact_email,
|
||||
notify_warning => $notify_warning,
|
||||
notify_critical => $notify_critical,
|
||||
notify_recovery => $notify_recovery,
|
||||
notify_unknown => $notify_unknown,
|
||||
require => Class['lma_infra_alerting::nagios::service_status'],
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Class: lma_infra_alerting::nagios
|
||||
#
|
||||
# Configure Nagios server with LMA requirements
|
||||
#
|
||||
|
||||
class lma_infra_alerting::nagios (
|
||||
$http_user = $lma_infra_alerting::params::nagios_http_user,
|
||||
$http_password = $lma_infra_alerting::params::nagios_http_password,
|
||||
) inherits lma_infra_alerting::params {
|
||||
|
||||
class { '::nagios':
|
||||
# Mandatory parameters for LMA requirements
|
||||
accept_passive_service_checks => $lma_infra_alerting::params::nagios_accept_passive_service_checks,
|
||||
enable_notifications => $lma_infra_alerting::params::nagios_enable_notifications,
|
||||
check_service_freshness => $lma_infra_alerting::params::nagios_check_service_freshness,
|
||||
check_external_commands => $lma_infra_alerting::params::nagios_check_external_commands,
|
||||
command_check_interval => $lma_infra_alerting::params::nagios_command_check_interval,
|
||||
interval_length => $lma_infra_alerting::params::nagios_interval_length,
|
||||
|
||||
# Not required to set these parameters but either usefull or better for LMA
|
||||
accept_passive_host_checks => $lma_infra_alerting::params::nagios_accept_passive_host_checks,
|
||||
use_syslog => $lma_infra_alerting::params::nagios_use_syslog,
|
||||
enable_flap_detection => $lma_infra_alerting::params::nagios_enable_flap_detection,
|
||||
debug_level => $lma_infra_alerting::params::nagios_debug_level,
|
||||
process_performance_data => $lma_infra_alerting::params::nagios_process_performance_data,
|
||||
}
|
||||
|
||||
class { '::nagios::cgi':
|
||||
cgi_user => $http_user,
|
||||
cgi_password => $http_password,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Class: lma_infra_alerting::nagios::contact
|
||||
#
|
||||
# Configure Nagios contactgroup and contact
|
||||
#
|
||||
|
||||
class lma_infra_alerting::nagios::contact(
|
||||
$ensure = present,
|
||||
$email = $lma_infra_alerting::params::nagios_contact_email,
|
||||
$notify_warning = true,
|
||||
$notify_critical = true,
|
||||
$notify_recovery = true,
|
||||
$notify_unknown = true,
|
||||
$notify_flapping = false,
|
||||
$notify_schedule = false,
|
||||
|
||||
) inherits lma_infra_alerting::params{
|
||||
validate_string($email)
|
||||
|
||||
$contact_groups = $lma_infra_alerting::params::nagios_contactgroup
|
||||
nagios::contactgroup { $contact_groups:
|
||||
ensure => $ensure,
|
||||
prefix => $lma_infra_alerting::params::nagios_config_filename_prefix,
|
||||
}
|
||||
|
||||
$service_notifs = {}
|
||||
$host_notifs = {}
|
||||
if $notify_warning {
|
||||
$service_notifs['w'] = true
|
||||
}
|
||||
if $notify_critical {
|
||||
$service_notifs['c'] = true
|
||||
$host_notifs['d'] = true
|
||||
}
|
||||
if $notify_recovery {
|
||||
$service_notifs['r'] = true
|
||||
$host_notifs['r'] = true
|
||||
}
|
||||
if $notify_unknown {
|
||||
$service_notifs['u'] = true
|
||||
$host_notifs['u'] = true
|
||||
}
|
||||
if $notify_flapping {
|
||||
$service_notifs['f'] = true
|
||||
$host_notifs['f'] = true
|
||||
}
|
||||
if $notify_schedule {
|
||||
$service_notifs['s'] = true
|
||||
$host_notifs['s'] = true
|
||||
}
|
||||
|
||||
$service_notify_options = keys($service_notifs)
|
||||
if count($service_notify_options) == 0 {
|
||||
$_service_notify_options = 'n'
|
||||
}else{
|
||||
$_service_notify_options = join($service_notify_options, ',')
|
||||
}
|
||||
$host_notify_options = keys($host_notifs)
|
||||
if count($host_notify_options) == 0 {
|
||||
$_host_notify_options = 'n'
|
||||
}else{
|
||||
$_host_notify_options = join($host_notify_options, ',')
|
||||
}
|
||||
|
||||
$alias = regsubst($email, '@', '_AT_')
|
||||
$contact_name = "${contact_groups}_${alias}"
|
||||
nagios::contact { $contact_name:
|
||||
ensure => $ensure,
|
||||
prefix => $lma_infra_alerting::params::nagios_config_filename_prefix,
|
||||
properties => {
|
||||
email => $email,
|
||||
alias => $alias,
|
||||
contactgroups => $contact_groups,
|
||||
service_notification_options => $_service_notify_options,
|
||||
host_notification_options => $_host_notify_options,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Configure a Nagios host object and configure related services with passive
|
||||
# checks.
|
||||
#
|
||||
class lma_infra_alerting::nagios::service_status (
|
||||
$ensure = present,
|
||||
$ip = undef,
|
||||
$hostname = undef,
|
||||
$services = [],
|
||||
){
|
||||
|
||||
validate_string($ip, $hostname)
|
||||
validate_array($services)
|
||||
|
||||
$nagios_config_dir = $nagios::params::config_dir
|
||||
$contact_group = $lma_infra_alerting::params::nagios_contactgroup
|
||||
|
||||
nagios::host { $hostname:
|
||||
ensure => $ensure,
|
||||
prefix => $lma_infra_alerting::params::nagios_config_filename_prefix,
|
||||
properties => {
|
||||
host_name => $hostname,
|
||||
address => $ip,
|
||||
contact_groups => $contact_group,
|
||||
active_checks_enabled => 1,
|
||||
passive_checks_enabled => 0,
|
||||
use => $lma_infra_alerting::params::nagios_generic_host_template,
|
||||
}
|
||||
}
|
||||
|
||||
nagios::service { $services:
|
||||
ensure => $ensure,
|
||||
prefix => $lma_infra_alerting::params::nagios_config_filename_prefix,
|
||||
properties => {
|
||||
host_name => $hostname,
|
||||
active_checks_enabled => 0,
|
||||
process_perf_data => 0,
|
||||
passive_checks_enabled => 1,
|
||||
contact_groups => $contact_group,
|
||||
max_check_attempts => $lma_infra_alerting::params::nagios_max_check_attempts_service_status,
|
||||
check_interval => $lma_infra_alerting::params::nagios_check_interval_service_status,
|
||||
retry_interval => $lma_infra_alerting::params::nagios_check_interval_service_status,
|
||||
freshness_threshold => $lma_infra_alerting::params::nagios_freshness_threshold_service_status,
|
||||
use => $lma_infra_alerting::params::nagios_generic_service_template,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
class lma_infra_alerting::params {
|
||||
|
||||
## Default configuration of Nagios
|
||||
#
|
||||
$nagios_http_user = 'nagiosadmin'
|
||||
$nagios_http_password = ''
|
||||
$nagios_cmd_check_ssh = 'check_ssh'
|
||||
|
||||
$nagios_contactgroup = 'openstack'
|
||||
$nagios_contact_email = 'root@localhost'
|
||||
|
||||
# All configuration files for nagios will be prepended with this prefix
|
||||
$nagios_config_filename_prefix = 'lma_'
|
||||
|
||||
## Override Nagios server configuration
|
||||
#
|
||||
# Nagios check periodically all commands received by HTTP.
|
||||
# We must enable external command and and its frequency must be coherent with
|
||||
# the service status forwarded by the LMA collector.
|
||||
$nagios_check_external_commands = true
|
||||
$nagios_command_check_interval = '10s'
|
||||
# The 'time unit' for all check_interval and check_retry (service and host).
|
||||
$nagios_interval_length = '60'
|
||||
$nagios_check_service_freshness = true
|
||||
$nagios_enable_notifications = true
|
||||
$nagios_accept_passive_service_checks = true
|
||||
|
||||
# Following parameters are not mandatory but are usefull and better for LMA
|
||||
$nagios_accept_passive_host_checks = false
|
||||
$nagios_use_syslog = true
|
||||
$nagios_enable_flap_detection = true
|
||||
$nagios_debug_level = 0
|
||||
$nagios_process_performance_data = false
|
||||
|
||||
## Service statutes
|
||||
#
|
||||
# Following parameters check and retry intervals are the number of
|
||||
# "time units" to wait before scheduling a (re)check.
|
||||
# (see $nagios_interval_length)
|
||||
$nagios_check_interval_service_status = 1
|
||||
# Send notifications not before 2 check attempts (avoid flapping)
|
||||
$nagios_max_check_attempts_service_status = 2
|
||||
# Force an active check (to force UNKNOWN state) if LMA Collector doesn't
|
||||
# push status since the last minute + 5 seconds.
|
||||
# Additional 5 seconds is IMPORTANT to avoid flapping when restarting heka,
|
||||
# because statutes are not sent during the first minute (pacemaker check)
|
||||
$nagios_freshness_threshold_service_status = 65
|
||||
$nagios_generic_host_template = 'generic-host'
|
||||
$nagios_generic_service_template = 'generic-service'
|
||||
|
||||
## Important parameters to maintain coherent with the LMA Collector
|
||||
#
|
||||
# Following service names must be coherent with the
|
||||
# nagios encoder plugin names.
|
||||
$openstack_core_services = [
|
||||
'openstack.horizon.status',
|
||||
'openstack.keystone.status',
|
||||
'openstack.nova.status',
|
||||
'openstack.glance.status',
|
||||
'openstack.cinder.status',
|
||||
'openstack.neutron.status',
|
||||
'openstack.heat.status',
|
||||
]
|
||||
|
||||
# The hostname must match with
|
||||
# lma_collector::params::nagios_hostname_service_status.
|
||||
# The numeric prefix is used to orderer the display in Nagios UI
|
||||
$nagios_openstack_hostname_prefix = '00-openstack-services'
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "lma_infra_alerting",
|
||||
"version": "0.0.1",
|
||||
"author": "Swann Croiset <scroiset@mirantis.com>",
|
||||
"summary": "Puppet module for alerting system of LMA toolchain",
|
||||
"license": "Apache License 2.0",
|
||||
"source": "git://git.openstack.org/cgit/stackforge/fuel-plugin-infrastructure-alerting.git",
|
||||
"project_page": "none",
|
||||
"issues_url": "none",
|
||||
"operatingsystem_support": [
|
||||
{
|
||||
"operatingsystem": "Ubuntu",
|
||||
"operatingsystemrelease": ["14.04"]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "CentOS",
|
||||
"operatingsystemrelease": ["6"]
|
||||
}
|
||||
],
|
||||
"description": "Puppet module for configuring Alerting systems of the LMA toolchain",
|
||||
"dependencies": [
|
||||
{"name": "puppetlabs/stdlib", "version_requirement": "4.x"},
|
||||
{"name": "nagios", "version_requirement": ">= 0.0.1"}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
Nagios module for Puppet
|
||||
========================
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Puppet module for configuring Nagios server and Nagios CGI.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
To deploy Nagios server on a host and activate the web interface.
|
||||
|
||||
```puppet
|
||||
class {'::nagios':
|
||||
accept_passive_service_checks => true,
|
||||
accept_passive_host_checks => false,
|
||||
use_syslog => true,
|
||||
enable_notifications => true,
|
||||
}
|
||||
|
||||
class { 'nagios::cgi':
|
||||
cgi_user => $http_user,
|
||||
cgi_password => $http_password,
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Licensed under the terms of the Apache License, version 2.0.
|
||||
|
||||
Contact
|
||||
-------
|
||||
|
||||
Swann Croiset, <scroiset@mirantis.com>
|
||||
|
||||
Support
|
||||
-------
|
||||
|
||||
See the Contact section.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
define command{
|
||||
command_name notify-service-by-email-with-long-service-output
|
||||
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Resource: nagios::cgi
|
||||
#
|
||||
# Install and configure Nagios web interface
|
||||
#
|
||||
class nagios::cgi (
|
||||
$cgi_user = $nagios::params::cgi_user,
|
||||
$cgi_password = $nagios::params::cgi_password,
|
||||
$cgi_htpasswd_file = $nagios::params::cgi_htpasswd_file,
|
||||
){
|
||||
|
||||
include nagios::params
|
||||
#TODO: use apache puppet module
|
||||
$apache_service_name = $nagios::params::apache_service_name
|
||||
|
||||
$package_name = $nagios::params::nagios_cgi_package
|
||||
package { $package_name:
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
# Configure apache
|
||||
# TODO http port and vhost
|
||||
package {$apache_service_name:
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
service {$apache_service_name:
|
||||
ensure => running,
|
||||
require => Package[$apache_service_name],
|
||||
}
|
||||
|
||||
# TODO: update cgi config to allow this specific user to access UI
|
||||
htpasswd { $cgi_user:
|
||||
# TODO randomize salt?
|
||||
cryptpasswd => ht_md5($cgi_password, 'salt'),
|
||||
target => $cgi_htpasswd_file,
|
||||
# notify => Service[$apache_service_name],
|
||||
require => Package[$package_name],
|
||||
}
|
||||
|
||||
# TODO: CentOS compatibility
|
||||
$apache_user = 'www-data'
|
||||
|
||||
user { $apache_user:
|
||||
groups => 'nagios',
|
||||
require => Package[$apache_service_name],
|
||||
}
|
||||
|
||||
# fix a permission issue with Ubuntu
|
||||
# TODO: CentOS compatibility
|
||||
file { '/var/lib/nagios3/rw':
|
||||
ensure => directory,
|
||||
mode => '0650',
|
||||
require => Package[$package_name],
|
||||
}
|
||||
|
||||
file { $cgi_htpasswd_file:
|
||||
owner => root,
|
||||
group => $apache_user,
|
||||
mode => '0640',
|
||||
require => Htpasswd[$cgi_user],
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Resource: nagios::command
|
||||
#
|
||||
# Manage a Nagios command object
|
||||
#
|
||||
# == Parameters
|
||||
# path: the directory conf.d of nagios
|
||||
# prefix: an optional prefix of the filename(s)
|
||||
# onefile: all objects are defined in one file if true else one file per service and cmd.
|
||||
# properties: properties of the nagios_host resource.
|
||||
|
||||
define nagios::command (
|
||||
$path = $nagios::params::config_dir,
|
||||
$prefix = '',
|
||||
$onefile = true,
|
||||
$properties = {},
|
||||
$defaults = {},
|
||||
$ensure = present,
|
||||
){
|
||||
|
||||
validate_hash($properties, $defaults)
|
||||
$opts = {}
|
||||
|
||||
if $onefile {
|
||||
$target = "${path}/${prefix}commands.cfg"
|
||||
}else{
|
||||
$target = "${path}/${prefix}command_${name}.cfg"
|
||||
}
|
||||
$opts['target'] = $target
|
||||
$opts['notify'] = Class['nagios::server_service']
|
||||
$opts['ensure'] = $ensure
|
||||
|
||||
if $properties['command_name'] == undef {
|
||||
$opts['command_name'] = $name
|
||||
}
|
||||
|
||||
$params = {
|
||||
"${name}" => merge($properties, $opts),
|
||||
}
|
||||
|
||||
create_resources(nagios_command, $params, $defaults)
|
||||
|
||||
if ! defined(File[$target]){
|
||||
file { $target:
|
||||
ensure => $ensure,
|
||||
mode => '0644',
|
||||
require => Nagios_Command[$name],
|
||||
notify => Class['nagios::server_service'],
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Resource: nagios::contact
|
||||
#
|
||||
# Create contact Nagios object
|
||||
#
|
||||
define nagios::contact (
|
||||
$path = $nagios::params::config_dir,
|
||||
$prefix = '',
|
||||
$onefile = true,
|
||||
$properties = {},
|
||||
$ensure = present,
|
||||
$defaults = {},
|
||||
){
|
||||
|
||||
validate_hash($properties, $defaults)
|
||||
$opts = {}
|
||||
|
||||
# default decent properties
|
||||
if empty($defaults){
|
||||
$_defaults = {
|
||||
'host_notifications_enabled' => 1,
|
||||
'service_notifications_enabled' => 1,
|
||||
'service_notification_period' => $nagios::params::service_notification_period,
|
||||
'host_notification_period' => $nagios::params::host_notification_period,
|
||||
}
|
||||
}else{
|
||||
$_defaults = $defaults
|
||||
}
|
||||
|
||||
if is_array($properties['contactgroups']){
|
||||
$opts['contactgroups'] = join($contact_groups, ',')
|
||||
}else{
|
||||
$opts['contactgroups'] = $properties['contactgroups']
|
||||
}
|
||||
|
||||
if $properties['service_notification_commands'] == undef {
|
||||
$opts['service_notification_commands'] = $nagios::params::service_notification_commands
|
||||
}
|
||||
if is_array($properties['service_notification_commands']) {
|
||||
$opts['service_notification_commands'] = join($properties['service_notification_commands'], ',')
|
||||
}
|
||||
if $properties['host_notification_commands'] == undef {
|
||||
$opts['host_notification_commands'] = $nagios::params::host_notification_commands
|
||||
}
|
||||
if is_array($properties['host_notification_commands']) {
|
||||
$opts['host_notification_commands'] = join($properties['host_notification_commands'], ',')
|
||||
}
|
||||
|
||||
if $onefile {
|
||||
$target = "${path}/${prefix}contacts.cfg"
|
||||
}else{
|
||||
$target = "${path}/${prefix}contact_${name}.cfg"
|
||||
}
|
||||
$opts['target'] = $target
|
||||
$opts['notify'] = Class['nagios::server_service']
|
||||
$opts['ensure'] = $ensure
|
||||
|
||||
if $properties['command_name'] == undef {
|
||||
$command_name = $name
|
||||
}else{
|
||||
$command_name = $properties['command_name']
|
||||
}
|
||||
$params = {
|
||||
"${command_name}" => merge($properties, $opts),
|
||||
}
|
||||
create_resources(nagios_contact, $params, $_defaults)
|
||||
|
||||
if ! defined(File[$target]){
|
||||
file { $target:
|
||||
ensure => $ensure,
|
||||
mode => '0644',
|
||||
notify => Class['nagios::server_service'],
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Resource: nagios::contactgroup
|
||||
#
|
||||
# Create contact_group Nagios object
|
||||
#
|
||||
define nagios::contactgroup (
|
||||
$path = $nagios::params::config_dir,
|
||||
$prefix = '',
|
||||
$onefile = true,
|
||||
$ensure = present,
|
||||
){
|
||||
|
||||
if $onefile {
|
||||
$target = "${path}/${prefix}contactgroups.cfg"
|
||||
}else{
|
||||
$target = "${path}/${prefix}contactgroup_${name}.cfg"
|
||||
}
|
||||
nagios_contactgroup{ $name:
|
||||
ensure => $ensure,
|
||||
target => $target,
|
||||
notify => Class['nagios::server_service'],
|
||||
}
|
||||
|
||||
if ! defined(File[$target]){
|
||||
file { $target:
|
||||
ensure => $ensure,
|
||||
mode => '0644',
|
||||
notify => Class['nagios::server_service'],
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Resource: nagios::host
|
||||
#
|
||||
# Manage a Nagios host object
|
||||
#
|
||||
# == Parameters
|
||||
# path: the directory conf.d of nagios
|
||||
# prefix: an optional prefix of the filename(s)
|
||||
# onefile: all objects are defined in one file if true else one file per service and cmd.
|
||||
# properties: properties of the nagios_host resource.
|
||||
|
||||
define nagios::host (
|
||||
$path = $nagios::params::config_dir,
|
||||
$prefix = '',
|
||||
$onefile = true,
|
||||
$properties = {},
|
||||
$defaults = {},
|
||||
$ensure = present,
|
||||
){
|
||||
|
||||
validate_hash($properties, $defaults)
|
||||
$opts = {}
|
||||
|
||||
if is_array($properties['contact_groups']){
|
||||
$opts['contact_groups'] = join($properties['contact_groups'], ',')
|
||||
}else{
|
||||
$opts['contact_groups'] = $properties['contact_groups']
|
||||
}
|
||||
|
||||
if $onefile {
|
||||
$target = "${path}/${prefix}hosts.cfg"
|
||||
}else{
|
||||
$target = "${path}/${prefix}host_${name}.cfg"
|
||||
}
|
||||
$opts['target'] = $target
|
||||
$opts['ensure'] = $ensure
|
||||
$opts['notify'] = Class['nagios::server_service']
|
||||
|
||||
if $properties['host_name'] == undef {
|
||||
$opts['host_name'] = $name
|
||||
$host_name = $name
|
||||
}else{
|
||||
$host_name = $properties['host_name']
|
||||
}
|
||||
if $properties['display_name'] == undef {
|
||||
$opts['display_name'] = $name
|
||||
}
|
||||
|
||||
$params = {
|
||||
"${host_name}" => merge($properties, $opts),
|
||||
}
|
||||
|
||||
create_resources(nagios_host, $params, $defaults)
|
||||
|
||||
if ! defined(File[$target]){
|
||||
file { $target:
|
||||
ensure => $properties['ensure'],
|
||||
mode => '0644',
|
||||
require => Nagios_Host[$host_name],
|
||||
notify => Class['nagios::server_service'],
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Update inline the main nagios configuration
|
||||
#
|
||||
class nagios(
|
||||
$service_name = $nagios::params::nagios_service_name,
|
||||
$main_config = $nagios::params::main_conf_file,
|
||||
$use_syslog = true,
|
||||
$log_rotation_method = $nagios::params::log_rotation_method,
|
||||
$accept_passive_service_checks = false,
|
||||
$accept_passive_host_checks = false,
|
||||
$execute_service_checks = true,
|
||||
$execute_host_checks = true,
|
||||
$enable_notifications = true,
|
||||
$enable_event_handlers = true,
|
||||
$enable_flap_detection = true,
|
||||
$debug_level = 0,
|
||||
$process_performance_data = true,
|
||||
$check_service_freshness = false,
|
||||
$service_freshness_check_interval = $nagios::params::service_freshness_check_interval,
|
||||
$check_host_freshness = false,
|
||||
$max_concurrent_checks = $nagios::params::max_concurrent_checks,
|
||||
$host_freshness_check_interval = $nagios::params::host_freshness_check_interval,
|
||||
$additional_freshness_latency = $nagios::params::additional_freshness_latency,
|
||||
$check_external_commands = false,
|
||||
$command_check_interval = $nagios::params::command_check_interval,
|
||||
$interval_length = $nagios::params::interval_length,
|
||||
) inherits nagios::params {
|
||||
|
||||
include nagios::params
|
||||
include nagios::server_service
|
||||
|
||||
$config_dir = $nagios::params::config_dir
|
||||
|
||||
package { $service_name:
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
package { $nagios::params::nagios_plugin_package:
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
file {"${config_dir}/cmd_notify-service-by-email-with-long-service-output.cfg":
|
||||
ensure => present,
|
||||
source => 'puppet:///modules/nagios/cmd_notify_service_by_email.cfg',
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
require => Package[$service_name],
|
||||
}
|
||||
|
||||
# TODO enable external_command (option + chmod)
|
||||
$passive_service_check = bool2num($accept_passive_service_checks)
|
||||
$passive_host_check = bool2num($accept_passive_host_checks)
|
||||
$service_checks = bool2num($execute_service_checks)
|
||||
$host_checks = bool2num($execute_host_checks)
|
||||
$syslog = bool2num($use_syslog)
|
||||
$notif = bool2num($enable_notifications)
|
||||
$event = bool2num($enable_event_handlers)
|
||||
$flap = bool2num($enable_flap_detection)
|
||||
$perf_data = bool2num($process_performance_data)
|
||||
$service_freshness = bool2num($check_service_freshness)
|
||||
$host_freshness = bool2num($check_host_freshness)
|
||||
$external_command = bool2num($check_external_commands)
|
||||
|
||||
augeas{ $main_config:
|
||||
incl => $main_config,
|
||||
lens => 'nagioscfg.lns',
|
||||
changes => [
|
||||
"set interval_length ${interval_length}",
|
||||
"set accept_passive_service_checks ${passive_service_check}",
|
||||
"set execute_service_checks ${service_checks}",
|
||||
"set accept_passive_host_checks ${passive_host_check}",
|
||||
"set execute_host_checks ${host_checks}",
|
||||
"set use_syslog ${syslog}",
|
||||
"set enable_notifications ${notif}",
|
||||
"set enable_event_handlers ${event}",
|
||||
"set enable_flap_detection ${flap}",
|
||||
"set process_performance_data ${perf_data}",
|
||||
"set debug_level ${debug_level}",
|
||||
"set check_service_freshness ${service_freshness}",
|
||||
"set check_host_freshness ${host_freshness}",
|
||||
"set service_freshness_check_interval ${service_freshness_check_interval}",
|
||||
"set check_external_commands ${external_command}",
|
||||
"set command_check_interval ${command_check_interval}",
|
||||
],
|
||||
notify => Class['nagios::server_service'],
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
class nagios::params {
|
||||
$config_dir = '/etc/nagios3/conf.d'
|
||||
$main_conf_file = '/etc/nagios3/nagios.cfg'
|
||||
$nagios_service_name = 'nagios3'
|
||||
|
||||
# plugins
|
||||
$nagios_plugin_package = 'nagios-plugins'
|
||||
$nagios_pluigin_dir = '/usr/lib/nagios/plugins'
|
||||
|
||||
# CGI
|
||||
$nagios_cgi_package = 'nagios3-cgi'
|
||||
$cgi_htpasswd_file = '/etc/nagios3/htpasswd.users'
|
||||
$apache_service_name = 'apache2'
|
||||
$cgi_user = 'nagiosadmin'
|
||||
$cgi_password = undef
|
||||
|
||||
# Nagios server configurations
|
||||
$nagios_debug = false
|
||||
$command_check_interval = '60s'
|
||||
$interval_length = '60'
|
||||
$service_freshness_check_interval = '60'
|
||||
$host_freshness_check_interval = '60'
|
||||
$additional_freshness_latency = '15'
|
||||
$log_rotation_method = 'd'
|
||||
$max_concurrent_checks = 0 # no limit
|
||||
|
||||
# default Nagios contact
|
||||
$default_contact_groups = ['admins']
|
||||
$default_contact_email = 'root@localhost'
|
||||
$default_contact_alias = 'Admin'
|
||||
|
||||
$service_notification_period = '24x7'
|
||||
$host_notification_period = '24x7'
|
||||
$service_notification_options = 'w,u,c,r'
|
||||
$host_notification_options = 'd,r'
|
||||
$service_notification_commands = ['notify-service-by-email-with-long-service-output']
|
||||
$host_notification_commands = ['notify-host-by-email']
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Class: nagios::server_service
|
||||
#
|
||||
# Manage the Nagios daemon
|
||||
#
|
||||
# Example:
|
||||
# myresource { 'foo':
|
||||
# notify => Class['nagios::server_service']
|
||||
#}
|
||||
#
|
||||
class nagios::server_service(
|
||||
$service_name = $nagios::params::nagios_service_name,
|
||||
$service_ensure = 'running',
|
||||
$service_enable = true,
|
||||
$service_manage = true,
|
||||
) inherits nagios::params {
|
||||
|
||||
validate_bool($service_enable)
|
||||
validate_bool($service_manage)
|
||||
|
||||
if $service_manage {
|
||||
service {$service_name:
|
||||
ensure => $service_ensure,
|
||||
require => Package[$service_name],
|
||||
enable => $service_enable,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Resource: nagios::service
|
||||
#
|
||||
# Manage a Nagios service object attached to the Nagios host
|
||||
#
|
||||
# == Parameters
|
||||
# path: the directory conf.d of nagios
|
||||
# prefix: an optional prefix of the filename(s)
|
||||
# onefile: all objects are defined in one file if true else one file per service and cmd.
|
||||
# properties: properties of the nagios_service resource.
|
||||
#
|
||||
define nagios::service (
|
||||
$path = $nagios::params::config_dir,
|
||||
$prefix = '',
|
||||
$onefile = true,
|
||||
$properties = {},
|
||||
$defaults = {},
|
||||
$ensure = present,
|
||||
){
|
||||
|
||||
validate_hash($properties, $defaults)
|
||||
validate_string($properties['host_name'])
|
||||
$opts = {}
|
||||
|
||||
if is_array($properties['contact_groups']){
|
||||
$opts['contact_groups'] = join($properties['contact_groups'], ',')
|
||||
}else{
|
||||
$opts['contact_groups'] = $properties['contact_groups']
|
||||
}
|
||||
|
||||
if is_array($properties['hostgroup_name']){
|
||||
$opts['hostgroup_name'] = join($properties['hostgroup_name'], ',')
|
||||
}else{
|
||||
$opts['hostgroup_name'] = $properties['hostgroup_name']
|
||||
}
|
||||
|
||||
if $onefile {
|
||||
$target = "${path}/${prefix}services.cfg"
|
||||
}else{
|
||||
$target = "${path}/${prefix}service_${name}.cfg"
|
||||
}
|
||||
$opts['target'] = $target
|
||||
$opts['notify'] = Class['nagios::server_service']
|
||||
$opts['ensure'] = $ensure
|
||||
|
||||
if $properties['passive_checks_enabled']{
|
||||
# set default params for passive checks if not provided
|
||||
if $properties['max_check_attempts'] == undef {
|
||||
$opts['max_check_attempts'] = 1
|
||||
}
|
||||
if $properties['check_freshness'] == undef {
|
||||
$opts['check_freshness'] = 1
|
||||
}
|
||||
}else{
|
||||
if $properties['max_check_attempts'] == undef {
|
||||
$opts['max_check_attempts'] = 3
|
||||
}
|
||||
if $properties['check_freshness'] == undef {
|
||||
$opts['check_freshness'] = 0
|
||||
}
|
||||
if $properties['freshness_threshold'] == undef {
|
||||
$opts['freshness_threshold'] = 0
|
||||
}
|
||||
}
|
||||
|
||||
if $properties['service_description'] == undef {
|
||||
$opts['service_description'] = $name
|
||||
}
|
||||
|
||||
if $properties['check_command'] == undef {
|
||||
# create default command to report UNKNOWN state
|
||||
$_check_command = "return-unknown-${name}"
|
||||
$opts['check_command'] = $_check_command
|
||||
$final_properties = merge($properties, $opts)
|
||||
$timeout_freshness = $final_properties['freshness_threshold'] * $final_properties['max_check_attempts']
|
||||
nagios::command { $_check_command:
|
||||
prefix => "${prefix}services_",
|
||||
properties => {
|
||||
command_line => "${nagios::params::nagios_plugin_dir}/check_dummy 3 'No data recieved since at least ${timeout_freshness} seconds'",
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$final_properties = merge($properties, $opts)
|
||||
}
|
||||
|
||||
$service_name = "${properties[host_name]}_${name}"
|
||||
$params = {
|
||||
"${service_name}" => $final_properties,
|
||||
}
|
||||
create_resources(nagios_service, $params, $defaults)
|
||||
|
||||
if ! defined(File[$target]){
|
||||
file { $target:
|
||||
ensure => $ensure,
|
||||
mode => '0644',
|
||||
require => Nagios_Service[$service_name],
|
||||
notify => Class['nagios::server_service'],
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "nagios",
|
||||
"version": "0.0.1",
|
||||
"author": "Swann Croiset <scroiset@mirantis.com>",
|
||||
"summary": "Puppet module for Nagios",
|
||||
"license": "Apache License 2.0",
|
||||
"source": "git://git.openstack.org/cgit/stackforge/fuel-plugin-infrastructure-alerting.git",
|
||||
"project_page": "none",
|
||||
"issues_url": "none",
|
||||
"operatingsystem_support": [
|
||||
{
|
||||
"operatingsystem": "Ubuntu",
|
||||
"operatingsystemrelease": ["14.04"]
|
||||
},
|
||||
{
|
||||
"operatingsystem": "CentOS",
|
||||
"operatingsystemrelease": ["6"]
|
||||
}
|
||||
],
|
||||
"description": "Puppet module for configuring Nagios server and Nagios CGI",
|
||||
"dependencies": [
|
||||
{"name": "puppetlabs/stdlib", "version_requirement": "4.x"},
|
||||
{"name": "leinaddm/htpasswd", "version_requirement": ">= 0.0.3"}
|
||||
]
|
||||
}
|
|
@ -54,9 +54,9 @@ download_packages \
|
|||
http://mirrors.kernel.org/ubuntu/pool/main/w/whois/whois_5.1.1_amd64.deb
|
||||
|
||||
|
||||
|
||||
rm -rf "${MODULES_DIR:?}"/{stdlib,htpasswd}
|
||||
mkdir -p "${MODULES_DIR}"/{stdlib,htpasswd}
|
||||
|
||||
wget -qO- "${FUEL_LIB_TARBALL_URL}" | \
|
||||
tar -C "${MODULES_DIR}" --strip-components=3 -zxvf - \
|
||||
fuel-library-${FUEL_LIB_VERSION}/deployment/puppet/stdlib
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# TODO: check environment coherence
|
||||
# The following tasks are executed in the order they are declared
|
||||
- role: ['base-os']
|
||||
stage: post_deployment/8100
|
||||
|
@ -6,3 +7,11 @@
|
|||
puppet_manifest: /etc/puppet/modules/osnailyfacter/modular/netconfig/netconfig.pp
|
||||
puppet_modules: /etc/puppet/modules
|
||||
timeout: 720
|
||||
|
||||
- role: ['base-os']
|
||||
stage: post_deployment/8100
|
||||
type: puppet
|
||||
parameters:
|
||||
puppet_manifest: puppet/manifests/nagios.pp
|
||||
puppet_modules: puppet/modules
|
||||
timeout: 600
|
||||
|
|
Loading…
Reference in New Issue