diff options
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/nrpe.pp | 24 | ||||
-rw-r--r-- | manifests/nrpe/base.pp | 15 | ||||
-rw-r--r-- | manifests/nrpe/command.pp | 10 |
3 files changed, 31 insertions, 18 deletions
diff --git a/manifests/nrpe.pp b/manifests/nrpe.pp index ad7dbbb..eb68189 100644 --- a/manifests/nrpe.pp +++ b/manifests/nrpe.pp @@ -1,22 +1,30 @@ # setup nrpe stuff -class nagios::nrpe { +class nagios::nrpe ( + $cfg_dir = '', + $pid_file = '', + $plugin_dir = '', + $server_address = '', + $allowed_hosts = '', +) { case $::operatingsystem { 'FreeBSD': { - if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/usr/local/etc' } - if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/spool/nagios/nrpe2.pid' } - if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/local/libexec/nagios' } + if $cfg_dir == '' { $real_cfg_dir = '/usr/local/etc' } + if $pid_file == '' { $real_pid_file = '/var/spool/nagios/nrpe2.pid' } + if $plugin_dir == '' { $real_plugin_dir = '/usr/local/libexec/nagios' } include ::nagios::nrpe::freebsd } 'Debian': { - if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/run/nagios/nrpe.pid' } - if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/lib/nagios/plugins' } + if $cfg_dir == '' { $real_cfg_dir = '/etc/nagios' } + if $pid_file == '' { $real_pid_file = '/var/run/nagios/nrpe.pid' } + if $plugin_dir == '' { $real_plugin_dir = '/usr/lib/nagios/plugins' } include ::nagios::nrpe::linux } default: { - if $nagios_nrpe_pid_file == '' { $nagios_nrpe_pid_file = '/var/run/nrpe.pid' } - if $nagios_plugin_dir == '' { $nagios_plugin_dir = '/usr/lib/nagios/plugins' } + if $cfg_dir == '' { $real_cfg_dir = '/etc/nagios' } + if $pid_file == '' { $real_pid_file = '/var/run/nrpe.pid' } + if $plugin_dir == '' { $real_plugin_dir = '/usr/lib/nagios/plugins' } case $::kernel { 'Linux': { include ::nagios::nrpe::linux } diff --git a/manifests/nrpe/base.pp b/manifests/nrpe/base.pp index fe1cd7c..fb62693 100644 --- a/manifests/nrpe/base.pp +++ b/manifests/nrpe/base.pp @@ -1,7 +1,12 @@ # basic nrpe stuff class nagios::nrpe::base { - if $nagios_nrpe_cfgdir == '' { $nagios_nrpe_cfgdir = '/etc/nagios' } + # Import all variables from entry point + $cfg_dir = $::nagios::nrpe::real_cfg_dir + $pid_file = $::nagios::nrpe::real_pid_file + $plugin_dir = $::nagios::nrpe::real_plugin_dir + $server_address = $::nagios::nrpe::server_address + $allowed_hosts = $::nagios::nrpe::allowed_hosts package{['nagios-nrpe-server', 'nagios-plugins-basic', 'libwww-perl']: ensure => installed; @@ -13,12 +18,12 @@ class nagios::nrpe::base { } file{ - [ $nagios_nrpe_cfgdir, "${nagios_nrpe_cfgdir}/nrpe.d" ]: + [ $cfg_dir, "${cfg_dir}/nrpe.d" ]: ensure => directory; } if $nagios_nrpe_dont_blame == '' { $nagios_nrpe_dont_blame = 1 } - file { "${nagios_nrpe_cfgdir}/nrpe.cfg": + file { "${cfg_dir}/nrpe.cfg": content => template('nagios/nrpe/nrpe.cfg'), owner => root, group => 0, @@ -40,14 +45,14 @@ class nagios::nrpe::base { $critical_5_threshold = 9 * $::processorcount $critical_15_threshold = 8 * $::processorcount nagios::nrpe::command {'check_load': - command_line => "${nagios_plugin_dir}/check_load -w ${warning_1_threshold},${warning_5_threshold},${warning_15_threshold} -c ${critical_1_threshold},${critical_5_threshold},${critical_15_threshold}", + command_line => "${plugin_dir}/check_load -w ${warning_1_threshold},${warning_5_threshold},${warning_15_threshold} -c ${critical_1_threshold},${critical_5_threshold},${critical_15_threshold}", } service{'nagios-nrpe-server': ensure => running, enable => true, pattern => 'nrpe', - subscribe => File["${nagios_nrpe_cfgdir}/nrpe.cfg"], + subscribe => File["${cfg_dir}/nrpe.cfg"], require => Package['nagios-nrpe-server'], } } diff --git a/manifests/nrpe/command.pp b/manifests/nrpe/command.pp index 196996c..bdd89a7 100644 --- a/manifests/nrpe/command.pp +++ b/manifests/nrpe/command.pp @@ -8,12 +8,12 @@ define nagios::nrpe::command ( fail('Either one of $command_line or $source must be given to nagios::nrpe::command.' ) } - $nagios_nrpe_cfgdir = $nagios::nrpe::base::nagios_nrpe_cfgdir + $cfg_dir = $nagios::nrpe::real_cfg_dir - file{"${nagios_nrpe_cfgdir}/nrpe.d/${name}_command.cfg": + file{"${cfg_dir}/nrpe.d/${name}_command.cfg": ensure => $ensure, notify => Service['nagios-nrpe-server'], - require => File ["${nagios_nrpe_cfgdir}/nrpe.d" ], + require => File ["${cfg_dir}/nrpe.d" ], owner => 'root', group => 0, mode => '0644'; @@ -21,12 +21,12 @@ define nagios::nrpe::command ( case $source { '': { - File["${nagios_nrpe_cfgdir}/nrpe.d/${name}_command.cfg"] { + File["${cfg_dir}/nrpe.d/${name}_command.cfg"] { content => template('nagios/nrpe/nrpe_command.erb'), } } default: { - File["${nagios_nrpe_cfgdir}/nrpe.d/${name}_command.cfg"] { + File["${cfg_dir}/nrpe.d/${name}_command.cfg"] { source => $source, } } |