added service description and add_hostgroup_rules
This commit is contained in:
@@ -21,6 +21,12 @@
|
|||||||
# @summary Define manages additional contacts known to NAGIOS through external
|
# @summary Define manages additional contacts known to NAGIOS through external
|
||||||
# Puppet rules, and populates /etc/nagios/conf.d/nagios_add_contact.cfg.
|
# Puppet rules, and populates /etc/nagios/conf.d/nagios_add_contact.cfg.
|
||||||
# @example
|
# @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',
|
||||||
|
# }
|
||||||
################################################################################
|
################################################################################
|
||||||
define cd_nagios::nagios::objects::add_contact (
|
define cd_nagios::nagios::objects::add_contact (
|
||||||
|
|
||||||
|
|||||||
64
manifests/nagios/objects/add_hostgroup_rules.pp
Normal file
64
manifests/nagios/objects/add_hostgroup_rules.pp
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
## cd_nagios::nagios::objects::add_hostgroup_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_hostgroups_add.cfg and
|
||||||
|
# additional hostgroups through external Puppet rules via define.
|
||||||
|
# @example
|
||||||
|
# cd_nagios::nagios::objects::add_hostgroups { 'example_hostgroup':
|
||||||
|
# ng_hostgroup_name => 'example_hostgroup',
|
||||||
|
# ng_hostgroup_alias => 'Example Hostgroup',
|
||||||
|
# }
|
||||||
|
################################################################################
|
||||||
|
class cd_nagios::nagios::objects::add_hostgroup_rules (
|
||||||
|
|
||||||
|
|
||||||
|
) inherits cd_nagios::params {
|
||||||
|
|
||||||
|
if $::fqdn == $ng_nagios_server {
|
||||||
|
|
||||||
|
# manage /etc/nagios_conf.d/nagios_hostgroups_add.cfg
|
||||||
|
|
||||||
|
concat { $ng_tgt_hostgroup_add:
|
||||||
|
ensure => present,
|
||||||
|
path => $ng_tgt_hostgroup_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 { 'hostgroups_header':
|
||||||
|
target => $ng_tgt_hostgroup_add,
|
||||||
|
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',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
49
manifests/nagios/objects/add_hostgroups.pp
Normal file
49
manifests/nagios/objects/add_hostgroups.pp
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
## cd_nagios::nagios::objects::add_hostgroups.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_hostgroups_add through
|
||||||
|
# extermal Puppet rules.
|
||||||
|
# @example
|
||||||
|
# cd_nagios::nagios::objects::add_hostgroups { 'example_hostgroup':
|
||||||
|
# ng_hostgroup_name => 'example_hostgroup',
|
||||||
|
# ng_hostgroup_alias => 'Example Hostgroup',
|
||||||
|
# }
|
||||||
|
###############################################################################
|
||||||
|
define cd_nagios::nagios::objects::add_hostgroups (
|
||||||
|
|
||||||
|
$ng_hostgroup_name = undef,
|
||||||
|
$ng_hostgroup_alias = undef,
|
||||||
|
$ng_hostgroup_register = '1',
|
||||||
|
|
||||||
|
) {
|
||||||
|
|
||||||
|
$ng_nagios_server = $::cd_nagios::params::ng_nagios_server
|
||||||
|
$ng_tgt_hostgroup_add = $::cd_nagios::params::ng_tgt_hostgroup_add
|
||||||
|
$ng_tgt_hostgrp_head_erb = $::cd_nagios::params::ng_tgt_hostgrp_head_erb
|
||||||
|
|
||||||
|
|
||||||
|
if $::fqdn == $ng_nagios_server {
|
||||||
|
|
||||||
|
concat::fragment { $name:
|
||||||
|
target => $ng_tgt_hostgroup_add,
|
||||||
|
content => template($ng_tgt_hostgrp_head_erb),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,6 +33,7 @@ class cd_nagios::nagios::objects::config (
|
|||||||
require cd_nagios::nagios::objects::contactgroups
|
require cd_nagios::nagios::objects::contactgroups
|
||||||
require cd_nagios::nagios::objects::add_contactgroups_rules
|
require cd_nagios::nagios::objects::add_contactgroups_rules
|
||||||
require cd_nagios::nagios::objects::hostgroups
|
require cd_nagios::nagios::objects::hostgroups
|
||||||
|
require cd_nagios::nagios::objects::add_hostgroup_rules
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# CentOS servers
|
# CentOS servers
|
||||||
@@ -65,7 +65,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# SuSE servers
|
# SuSE servers
|
||||||
@@ -78,7 +78,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Unix servers
|
# Unix servers
|
||||||
@@ -91,7 +91,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Solaris servers
|
# Solaris servers
|
||||||
@@ -104,7 +104,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# AIX servers
|
# AIX servers
|
||||||
@@ -117,7 +117,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Windows servers
|
# Windows servers
|
||||||
@@ -130,7 +130,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Netware servers
|
# Netware servers
|
||||||
@@ -143,7 +143,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# DB servers
|
# DB servers
|
||||||
@@ -156,7 +156,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Oracle servers
|
# Oracle servers
|
||||||
@@ -169,7 +169,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# MySQL servers
|
# MySQL servers
|
||||||
@@ -182,7 +182,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# MSSQL servers
|
# MSSQL servers
|
||||||
@@ -195,7 +195,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# NOSQL servers
|
# NOSQL servers
|
||||||
@@ -208,7 +208,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Hadoop servers
|
# Hadoop servers
|
||||||
@@ -221,7 +221,7 @@ class cd_nagios::nagios::objects::hostgroups (
|
|||||||
group => $ng_user,
|
group => $ng_user,
|
||||||
mode => '0640',
|
mode => '0640',
|
||||||
register => '1',
|
register => '1',
|
||||||
target => $ng_target_hostgroup,
|
target => $ng_target_hostgroup_base,
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -965,7 +965,9 @@ $ng_templates_rule_erb = 'cd_nagios/nagios/templates_cfg_rule.erb'
|
|||||||
$ng_target_timeperiods = "${ng_conf_d_dir}/timeperiods.cfg"
|
$ng_target_timeperiods = "${ng_conf_d_dir}/timeperiods.cfg"
|
||||||
$ng_target_localhost = "${ng_conf_d_dir}/nagios_localhost.cfg"
|
$ng_target_localhost = "${ng_conf_d_dir}/nagios_localhost.cfg"
|
||||||
$ng_target_host = "${ng_conf_d_dir}/nagios_host.cfg"
|
$ng_target_host = "${ng_conf_d_dir}/nagios_host.cfg"
|
||||||
$ng_target_hostgroup = "${ng_conf_d_dir}/nagios_hostgroups_base.cfg"
|
$ng_target_hostgroup_base = "${ng_conf_d_dir}/nagios_hostgroups_base.cfg"
|
||||||
|
$ng_tgt_hostgroup_add = "${ng_conf_d_dir}/nagios_hostgroups_add.cfg"
|
||||||
|
$ng_tgt_hostgrp_head_erb = 'cd_nagios/nagios/hostgroups_cfg_head.erb'
|
||||||
$ng_target_hostdep = "${ng_conf_d_dir}/nagios_hostdependency.cfg"
|
$ng_target_hostdep = "${ng_conf_d_dir}/nagios_hostdependency.cfg"
|
||||||
$ng_target_hostesc = "${ng_conf_d_dir}/nagios_hostescalation.cfg"
|
$ng_target_hostesc = "${ng_conf_d_dir}/nagios_hostescalation.cfg"
|
||||||
$ng_target_hostext = "${ng_conf_d_dir}/nagios_hostextinfo.cfg"
|
$ng_target_hostext = "${ng_conf_d_dir}/nagios_hostextinfo.cfg"
|
||||||
|
|||||||
@@ -42,11 +42,12 @@ class cd_nagios::server::service (
|
|||||||
use => 'generic-service',
|
use => 'generic-service',
|
||||||
host_name => $::fqdn,
|
host_name => $::fqdn,
|
||||||
notification_period => '24x7',
|
notification_period => '24x7',
|
||||||
|
service_description => "${::hostname}_nagios_service",
|
||||||
target => $ng_target_service,
|
target => $ng_target_service,
|
||||||
owner => 'nagios',
|
owner => 'nagios',
|
||||||
group => 'nagios',
|
group => 'nagios',
|
||||||
mode => '660',
|
mode => '0660',
|
||||||
contacts => 'DevOps',
|
contacts => 'ops',
|
||||||
}
|
}
|
||||||
|
|
||||||
resources { [ 'nagios_host',
|
resources { [ 'nagios_host',
|
||||||
|
|||||||
5
templates/nagios/hostgroups_cfg_head.erb
Normal file
5
templates/nagios/hostgroups_cfg_head.erb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
###############################################################################
|
||||||
|
########## nagios_hostgroups_add.cfg created by Puppet ##########
|
||||||
|
########## manual changes are overwritten! ##########
|
||||||
|
###############################################################################
|
||||||
|
# rules are created below by external puppet rules.
|
||||||
6
templates/nagios/hostgroups_cfg_rule.erb
Normal file
6
templates/nagios/hostgroups_cfg_rule.erb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
define hostgroup {
|
||||||
|
hostgroup_name <%= @ng_hostgroup_name %>
|
||||||
|
alias <%= @ng_hostgroup_alias %>
|
||||||
|
register <%= @ng_hostgroup_register %>
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user