added base contacts and additional contacts

This commit is contained in:
Arne Teuke
2017-07-26 12:16:25 +01:00
parent 099828e47a
commit 85ade68820
15 changed files with 328 additions and 216 deletions

View File

@@ -0,0 +1,35 @@
## cd_nagios::nagios::objects::add_contact.pp
# Module name: cd_nagios
# Author: Arne Teuke (arne_teuke@ConfDroid.com)
# # License:
# This file is part of cd_nagios.
#
# cd_nagios is used for providing automatic configuration of Nagios
# Copyright (C) 2016 ConfDroid (copyright@ConfDroid.com)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# @summary Define manages additional contacts known to NAGIOS through external
# Puppet rules, and populates /etc/nagios/conf.d/nagios_add_contact.cfg.
# @example
################################################################################
define cd_nagios::nagios::objects::add_contact (
$ng_contact_name = undef,
$ng_contact_use = 'generic-contact',
$ng_contact_alias = undef,
$ng_contact_email = undef,
$ng_contact_groups = undef,
) {
}

View File

@@ -0,0 +1,69 @@
## cd_nagios::nagios::objects::add_contact_rules.pp
# Module name: cd_nagios
# Author: Arne Teuke (arne_teuke@ConfDroid.com)
# # License:
# This file is part of cd_nagios.
#
# cd_nagios is used for providing automatic configuration of Nagios
# Copyright (C) 2016 ConfDroid (copyright@ConfDroid.com)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# @summary Class manages /etc/nagios/conf.d/nagios_add_contact.cfg through
# concat.
# @example
# cd_nagios::nagios::objects::add_contact { 'example_user':
# ng_contact_name => 'example_user',
# ng_contact_alias => 'Example User',
# ng_contact_groups => 'admins',
# ng_contact_email => 'example@example.net',
# }
################################################################################
class cd_nagios::nagios::objects::add_contact_rules (
) inherits cd_nagios::params {
if $::fqdn == $ng_nagios_server {
# manage /etc/nagios/conf.d/nagios_add_contacts.cfg
concat { $ng_target_add_contact:
ensure => present,
path => $ng_target_add_contact,
owner => $ng_user,
group => $ng_user,
mode => '0640',
selrange => s0,
selrole => object_r,
seltype => nagios_etc_t,
seluser => system_u,
notify => Service[$ng_service],
}
# manage file header
concat::fragment { 'header':
target => $ng_target_add_contact,
content => template($ng_contacts_head_erb),
order => '000',
}
# example rule for testing
cd_nagios::nagios::objects::add_contact { 'example_user':
ng_contact_name => 'example_user',
ng_contact_alias => 'Example User',
ng_contact_groups => 'admins',
ng_contact_email => 'example@example.net',
}
}
}

View File

@@ -0,0 +1,34 @@
## cd_nagios::server::nagios::objects::config.pp
# Module name: cd_nagios
# Author: Arne Teuke (arne_teuke@ConfDroid.com)
# # License:
# This file is part of cd_nagios.
#
# cd_nagios is used for providing automatic configuration of Nagios
# Copyright (C) 2016 ConfDroid (copyright@ConfDroid.com)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# @summary Class manages the nagios objects definitions.
#############################################################################
class cd_nagios::nagios::objects::config (
) inherits cd_nagios::params {
if $::fqdn == $ng_nagios_server {
require cd_nagios::nagios::objects::commands
require cd_nagios::nagios::objects::template_rules
require cd_nagios::nagios::objects::add_contact_rules
}
}

View File

@@ -0,0 +1,97 @@
## cd_nagios::nagios::objects::contacts.pp
# Module name: cd_nagios
# Author: Arne Teuke (arne_teuke@ConfDroid.com)
# # License:
# This file is part of cd_nagios.
#
# cd_nagios is used for providing automatic configuration of Nagios
# Copyright (C) 2016 ConfDroid (copyright@ConfDroid.com)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# @summary Class manages basic contacts known to NAGIOS through Puppet exports,
# and populates /etc/nagios/conf.d/nagios_base_contacts.cfg.
# @example
# @@nagios_contact { 'admin':
# ensure => present,
# alias => 'Nagios Admin',
# contact_name => 'admin',
# contactgroups => 'admins',
# email => "admin@${::domain}",
# can_submit_commands => '1',
# register => '1',
# use => 'generic-contact',
# target => $ng_target_base_contact,
# owner => 'root',
# group => 'nagios',
# mode => '0664',
# }
################################################################################
class cd_nagios::nagios::objects::contacts (
) inherits cd_nagios::params {
if $::fqdn == $ng_nagios_server {
# admin contact
@@nagios_contact { 'admin':
ensure => present,
alias => 'Nagios Admin',
contact_name => 'admin',
contactgroups => 'admins',
email => "admin@${::domain}",
can_submit_commands => '1',
register => '1',
use => 'generic-contact',
target => $ng_target_base_contact,
owner => $ng_user,
group => $ng_user,
mode => '0640',
}
# ops contact
@@nagios_contact { 'ops':
ensure => present,
alias => 'Operations',
contact_name => 'ops',
contactgroups => 'operations',
email => "ops@${::domain}",
can_submit_commands => '1',
register => '1',
use => 'generic-contact',
target => $ng_target_base_contact,
owner => $ng_user,
group => $ng_user,
mode => '0640',
}
# support contact
@@nagios_contact { 'support':
ensure => present,
alias => 'support',
contact_name => 'support',
contactgroups => 'support',
email => "support@${::domain}",
can_submit_commands => '1',
register => '1',
use => 'generic-contact',
target => $ng_target_base_contact,
owner => $ng_user,
group => $ng_user,
mode => '0640',
}
}
}

View File

@@ -18,7 +18,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# @summary Class manages /etc/nagios/conf.d/templates.cfg through concat.
# @summary Class manages /etc/nagios/conf.d/nagios_templates.cfg through
# concat.
# @example cd_nagios::nagios::objects::templates { 'generic contact':
# ng_template_object => 'contact',
# ng_template_object_name => 'generic-contact',

View File

@@ -25,7 +25,7 @@
# i.e. `generic-contact`, `generic-host`, `generic-service`.
# @param [string] ng_svc_notification_period Period in which to send out
# notifications for service events, i.e. `24x7`.
# @param [string] ng_svc_notification_period Period in which to send out
# @param [string] ng_host_notification_period Period in which to send out
# notifications for host events , i.e. `24x7`.
# @param [string] ng_service_notification_options What service events to send
# out notifications for:
@@ -77,6 +77,7 @@
# retries for the defined object.
# @param [string] ng_max_check_attempts how often to check the defined object
# maximal.
# @param [string] ng_check_command The command to use for host checks.
# @param [string] ng_notification_options see `ng_service_notification_options`
# and `ng_host_notification_options`.
# @param [string] ng_contact_groups contact groups for the defined oject.
@@ -112,7 +113,6 @@ $ng_template_object_use = undef,
$ng_notifications_enabled = '1',
$ng_event_handler_enabled = '1',
$ng_flap_detection_enabled = '1',
$ng_failure_prediction_enabled = '1',
$ng_process_perf_data = '1',
$ng_retain_status_information = '1',
$ng_retain_nonstatus_information = '1',
@@ -122,7 +122,7 @@ $ng_check_period = '24x7',
$ng_check_interval = '5',
$ng_retry_interval = '1',
$ng_max_check_attempts = '10',
$ng_check_command = 'check-host-alive',
$ng_host_check_command = 'check-host-alive',
$ng_notification_options = undef,
$ng_contact_groups = 'admins',
$ng_active_checks_enabled = '1',