Puppet Class: nagios::client
- Inherits:
- nagios::params
- Defined in:
- manifests/client.pp
Overview
Configures nagios client and sets up basic checks
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'manifests/client.pp', line 2
class nagios::client (
$nrpe = true,
$nsca = true,
$selinux = true,
$firewall = true,
$basic_checks = true,
$auto_os_hostgroup = true,
$auto_virt_hostgroup = true,
$hostgroups = [],
$parent = undef,
$alias = undef,
$nrpe_package = $nagios::params::nrpe_package,
$nsca_client_package = $nagios::params::nsca_client_package,
$nrpe_service = $nagios::params::nrpe_service,
$nrpe_config = $nagios::params::nrpe_config,
$nrpe_d = $nagios::params::nrpe_d,
$nrpe_plugin_package = $nagios::params::nrpe_plugin_package,
) inherits nagios::params {
if ($nsca) {
class { '::nagios::client::nsca':
nsca_client_package => $nsca_client_package,
firewall => $firewall,
}
}
if ($nrpe) {
class { '::nagios::client::nrpe':
nrpe_package => $nrpe_package,
nrpe_service => $nrpe_service,
nrpe_config => $nrpe_config,
nrpe_d => $nrpe_d,
selinux => $selinux,
}
}
if $::osfamily == 'RedHat' {
package { ['nagios-plugins',
'nagios-plugins-all',
'nagios-plugins-bonding',
'nagios-plugins-perl']:
ensure => installed,
require => Class['epel'],
}
}
if $::operatingsystem == 'Ubuntu' {
package { ['nagios-plugins',
'nagios-plugins-basic',
'nagios-plugins-standard',
'nagios-plugins-extra']:
ensure => installed,
}
}
# Create a hostgroup for our OS
if ($auto_os_hostgroup) {
@@nagios::hostgroup { "${::fqdn}-os":
hostgroup => downcase("${::operatingsystem}-${::operatingsystemmajrelease}"),
hostgroupalias => "${::operatingsystem} ${::operatingsystemmajrelease}",
tag => hiera('nagios_server'),
}
$os_hostgroup = downcase("${::operatingsystem}-${::operatingsystemmajrelease}")
}
# Create a hostgroup for our platform
if ($auto_virt_hostgroup) {
@@nagios::hostgroup { "${::fqdn}-virtual":
hostgroup => downcase($::virtual),
hostgroupalias => $::virtual,
tag => hiera('nagios_server'),
}
$virt_hostgroup = downcase($::virtual)
}
# Make final array of hostgroups
$final_hostgroups = delete_undef_values([
$hostgroups,
$os_hostgroup,
$virt_hostgroup,
])
# Define the host in nagios, including parent hypervisor, if there is one
$ilom = hiera('ilom', undef)
if ($ilom) {
$ilomnotes = "iLOM address: ${ilom}"
} else {
$ilomnotes = undef
}
@@nagios_host { $::fqdn:
ensure => present,
address => $::ipaddress,
alias => $alias,
use => 'generic-host',
action_url => "/nagios/pnp4nagios/graph?host=${::fqdn}",
notes => $ilomnotes,
parents => $parent,
hostgroups => join($final_hostgroups, ','),
icon_image_alt => $::operatingsystem,
icon_image => "${::operatingsystem}.png",
statusmap_image => "${::operatingsystem}.gd2",
tag => hiera('nagios_server'),
target => "/etc/nagios/conf.d/${::fqdn}-host.cfg",
}
# Optionally install some basic checks
if ($basic_checks) {
class { '::nagios::client::checks':
nrpe => $nrpe,
}
}
# Install supplementary nrpe config
# First we template a couple of useful values
$warnload = $::processorcount*7
$critload = $::processorcount*10
$lib = $::architecture ? {
'i386' => 'lib',
'x86_64' => 'lib64',
default => 'lib',
}
}
|