added servicegroup control
This commit is contained in:
@@ -52,6 +52,7 @@ Configuration
|
||||
* manage Nagios main contacts through Puppet exports. Additional contacts can be created through external Puppet rules via define, to avoid having to alter the module code.
|
||||
* manage Nagios main contactgroups through Puppet exports. Additional contact groups can be created through external Puppet rules via define, to avoid having to alter the module code.
|
||||
* manage Nagios main hostgroups through Puppet exports. Additional host groups can be created through external Puppet rules via define, to avoid having to alter the module code.
|
||||
* manage Nagios main servicegroups through Puppet exports. Additional service groups can be created through external Puppet rules via define, to avoid having to alter the module code.
|
||||
* configure NRPE on clients (optional)
|
||||
* configure firewall (optional)
|
||||
* configure selinux policies (optional)
|
||||
|
||||
@@ -56,11 +56,5 @@ class cd_nagios::nagios::objects::add_contactgroups_rules (
|
||||
content => template($ng_cntctgrps_head_erb),
|
||||
order => '000',
|
||||
}
|
||||
|
||||
cd_nagios::nagios::objects::add_contactgroups { 'example_group':
|
||||
ng_contactgroup_name => 'example_group',
|
||||
ng_contactgroup_alias => 'Example Group',
|
||||
ng_contactgroup_register => '1',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,10 +55,5 @@ class cd_nagios::nagios::objects::add_hostgroup_rules (
|
||||
content => template($ng_tgt_hostgrp_head_erb),
|
||||
order => '000',
|
||||
}
|
||||
|
||||
cd_nagios::nagios::objects::add_hostgroups { 'example_hostgroup':
|
||||
ng_hostgroup_name => 'example_hostgroup',
|
||||
ng_hostgroup_alias => 'Example Hostgroup',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
64
manifests/nagios/objects/add_servicegroup_rules.pp
Normal file
64
manifests/nagios/objects/add_servicegroup_rules.pp
Normal file
@@ -0,0 +1,64 @@
|
||||
## cd_nagios::nagios::objects::add_servicegroup_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_servicegroups_add.cfg and
|
||||
# additional servicegroups through external Puppet rules via define.
|
||||
# @example
|
||||
# cd_nagios::nagios::objects::add_servicegroups { 'example_servicegroup':
|
||||
# ng_servicegroup_name => 'example_servicegroup',
|
||||
# ng_servicegroup_alias => 'Example Servicegroup',
|
||||
# }
|
||||
################################################################################
|
||||
class cd_nagios::nagios::objects::add_servicegroup_rules (
|
||||
|
||||
|
||||
) inherits cd_nagios::params {
|
||||
|
||||
if $::fqdn == $ng_nagios_server {
|
||||
|
||||
# manage /etc/nagios_conf.d/nagios_servicegroups_add.cfg
|
||||
|
||||
concat { $ng_tgt_servicegroup_add:
|
||||
ensure => present,
|
||||
path => $ng_tgt_servicegroup_add,
|
||||
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 { 'servicegroups_header':
|
||||
target => $ng_tgt_servicegroup_add,
|
||||
content => template($ng_tgt_svcgrp_head_erb),
|
||||
order => '000',
|
||||
}
|
||||
|
||||
cd_nagios::nagios::objects::add_servicegroups { 'example_servicegroup':
|
||||
ng_servicegroup_name => 'example_servicegroup',
|
||||
ng_servicegroup_alias => 'Example Servicegroup',
|
||||
}
|
||||
}
|
||||
}
|
||||
48
manifests/nagios/objects/add_servicegroups.pp
Normal file
48
manifests/nagios/objects/add_servicegroups.pp
Normal file
@@ -0,0 +1,48 @@
|
||||
## cd_nagios::nagios::objects::add_servicegroups.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 populates /etc/nagios/conf.d/nagios_servicegroups_add through
|
||||
# extermal Puppet rules.
|
||||
# @example
|
||||
# cd_nagios::nagios::objects::add_servicegroups { 'example_servicegroup':
|
||||
# ng_servicegroup_name => 'example_servicegroup',
|
||||
# ng_servicegroup_alias => 'Example servicegroup',
|
||||
# }
|
||||
###############################################################################
|
||||
define cd_nagios::nagios::objects::add_servicegroups (
|
||||
|
||||
$ng_servicegroup_name = undef,
|
||||
$ng_servicegroup_alias = undef,
|
||||
$ng_servicegroup_register = '1',
|
||||
|
||||
) {
|
||||
|
||||
$ng_nagios_server = $::cd_nagios::params::ng_nagios_server
|
||||
$ng_tgt_servicegroup_add = $::cd_nagios::params::ng_tgt_servicegroup_add
|
||||
$ng_tgt_svcgrp_rule_erb = $::cd_nagios::params::ng_tgt_svcgrp_rule_erb
|
||||
|
||||
if $::fqdn == $ng_nagios_server {
|
||||
|
||||
concat::fragment { $name:
|
||||
target => $ng_tgt_servicegroup_add,
|
||||
content => template($ng_tgt_svcgrp_rule_erb),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ class cd_nagios::nagios::objects::config (
|
||||
require cd_nagios::nagios::objects::add_contactgroups_rules
|
||||
require cd_nagios::nagios::objects::hostgroups
|
||||
require cd_nagios::nagios::objects::add_hostgroup_rules
|
||||
|
||||
require cd_nagios::nagios::objects::servicegroups
|
||||
require cd_nagios::nagios::objects::add_servicegroup_rules
|
||||
}
|
||||
}
|
||||
|
||||
70
manifests/nagios/objects/servicegroups.pp
Normal file
70
manifests/nagios/objects/servicegroups.pp
Normal file
@@ -0,0 +1,70 @@
|
||||
## cd_nagios::nagios::objects::servicegroups.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 hostgroups known to NAGIOS through Puppet
|
||||
# exports, and populates /etc/nagios/conf.d/nagios_base_hostgroups.cfg.
|
||||
################################################################################
|
||||
class cd_nagios::nagios::objects::servicegroups (
|
||||
|
||||
|
||||
) inherits cd_nagios::params {
|
||||
|
||||
if $::fqdn == $ng_nagios_server {
|
||||
|
||||
# network services
|
||||
|
||||
@@nagios_servicegroup { 'network-services':
|
||||
ensure => present,
|
||||
servicegroup_name => 'network-services',
|
||||
alias => 'Network Services',
|
||||
owner => $ng_user,
|
||||
group => $ng_user,
|
||||
mode => '0640',
|
||||
register => '1',
|
||||
target => $ng_target_svcgrp_base,
|
||||
}
|
||||
|
||||
# linux services
|
||||
|
||||
@@nagios_servicegroup { 'linux-services':
|
||||
ensure => present,
|
||||
servicegroup_name => 'linux-services',
|
||||
alias => 'Linux Services',
|
||||
owner => $ng_user,
|
||||
group => $ng_user,
|
||||
mode => '0640',
|
||||
register => '1',
|
||||
target => $ng_target_svcgrp_base,
|
||||
}
|
||||
|
||||
# database services
|
||||
|
||||
@@nagios_servicegroup { 'database-services':
|
||||
ensure => present,
|
||||
servicegroup_name => 'database-services',
|
||||
alias => 'Database Services',
|
||||
owner => $ng_user,
|
||||
group => $ng_user,
|
||||
mode => '0640',
|
||||
register => '1',
|
||||
target => $ng_target_svcgrp_base,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -892,6 +892,8 @@ $ng_check_workers = '',
|
||||
$ng_host_down_svc_checks = '0',
|
||||
$ng_enable_load_ctl_options = false,
|
||||
$ng_loadctl_options = 'jobs_max=100;backoff_limit=10;rampup_change=5',
|
||||
$ng_nagios_service_cmd = 'check_nagios!/var/log/nagios/status.dat!5!/usr/sbin/nagios',
|
||||
|
||||
) {
|
||||
|
||||
# installation section
|
||||
@@ -973,9 +975,12 @@ $ng_target_hostdep = "${ng_conf_d_dir}/nagios_hostdependency.cfg"
|
||||
$ng_target_hostesc = "${ng_conf_d_dir}/nagios_hostescalation.cfg"
|
||||
$ng_target_hostext = "${ng_conf_d_dir}/nagios_hostextinfo.cfg"
|
||||
$ng_target_service = "${ng_conf_d_dir}/nagios_service.cfg"
|
||||
$ng_target_servicegroup = "${ng_conf_d_dir}/nagios_servicegroup.cfg"
|
||||
$ng_target_base_contact = "${ng_conf_d_dir}/nagios_base_contact.cfg"
|
||||
$ng_target_add_contact = "${ng_conf_d_dir}/nagios_add_contact.cfg"
|
||||
$ng_target_svcgrp_base = "${ng_conf_d_dir}/nagios_servicegroups_base.cfg"
|
||||
$ng_tgt_servicegroup_add = "${ng_conf_d_dir}/nagios_servicegroups_add.cfg"
|
||||
$ng_tgt_svcgrp_head_erb = 'cd_nagios/nagios/svcgroups_cfg_head.erb'
|
||||
$ng_tgt_hostgrp_rule_erb = 'cd_nagios/nagios/svcgroups_cfg_rule.erb'
|
||||
$ng_target_base_contact = "${ng_conf_d_dir}/nagios_contact_base.cfg"
|
||||
$ng_target_add_contact = "${ng_conf_d_dir}/nagios_contact_add.cfg"
|
||||
$ng_contacts_head_erb = 'cd_nagios/nagios/contacts_cfg_head.erb'
|
||||
$ng_contacts_rule_erb = 'cd_nagios/nagios/contacts_cfg_rule.erb'
|
||||
$ng_tgt_contactgroup_base = "${ng_conf_d_dir}/nagios_contactgroup_base.cfg"
|
||||
|
||||
@@ -54,13 +54,13 @@ class cd_nagios::server::service (
|
||||
notify => Service ['nagios'],
|
||||
}
|
||||
|
||||
@@nagios_service { "check_nagios_localhost":
|
||||
check_command => 'check_nagios!/var/log/nagios/status.dat!5!/usr/sbin/nagios',
|
||||
@@nagios_service { 'check_nagios_localhost':
|
||||
check_command => $ng_nagios_service_cmd,
|
||||
use => 'generic-service',
|
||||
host_name => 'localhost',
|
||||
notification_period => '24x7',
|
||||
service_description => 'localhost_nagios_service',
|
||||
target => $ng_target_service,
|
||||
service_description => 'localhost_nagios_service',
|
||||
target => $ng_target_service,
|
||||
owner => $ng_user,
|
||||
group => $ng_user,
|
||||
mode => '0640',
|
||||
|
||||
5
templates/nagios/svcgroups_cfg_head.erb
Normal file
5
templates/nagios/svcgroups_cfg_head.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
###############################################################################
|
||||
########## nagios_servicegroups_add.cfg created by Puppet ##########
|
||||
########## manual changes are overwritten! ##########
|
||||
###############################################################################
|
||||
# rules are created below by external puppet rules.
|
||||
6
templates/nagios/svcgroups_cfg_rule.erb
Normal file
6
templates/nagios/svcgroups_cfg_rule.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
define servicegroup {
|
||||
servicegroup_name <%= @ng_servicegroup_name %>
|
||||
alias <%= @ng_servicegroup_alias %>
|
||||
register <%= @ng_servicegroup_register %>
|
||||
}
|
||||
Reference in New Issue
Block a user