From 05d89061c02979aec4edb402b93f95d6e0d9ad4c Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 25 Jan 2013 21:36:49 -0200 Subject: Commands notify-host-by-email and notify-service-by-email are already defined by the nagios package amended by LeLutin: added missing : after default keyword and fixed style a bit. --- manifests/defaults/commands.pp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'manifests') diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp index cc8aa53..777a74e 100644 --- a/manifests/defaults/commands.pp +++ b/manifests/defaults/commands.pp @@ -129,11 +129,16 @@ class nagios::defaults::commands { default => '/usr/bin/mail' } - nagios_command { - 'notify-host-by-email': + case $::lsbdistcodename { + 'wheezy': { } + default: { + nagios_command { + 'notify-host-by-email': command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\nHost: \$HOSTNAME\$\\nState: \$HOSTSTATE\$\\nAddress: \$HOSTADDRESS\$\\nInfo: \$HOSTOUTPUT\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Host Alert: \$HOSTNAME\$ is \$HOSTSTATE\$ **\" \$CONTACTEMAIL\$"; - 'notify-service-by-email': - command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\n\\nService: \$SERVICEDESC\$\\nHost: \$HOSTALIAS\$\\nAddress: \$HOSTADDRESS\$\\nState: \$SERVICESTATE\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\\nAdditional Info:\\n\\n\$SERVICEOUTPUT\$\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Service Alert: \$HOSTALIAS\$/\$SERVICEDESC\$ is \$SERVICESTATE\$ **\" \$CONTACTEMAIL\$"; - } + 'notify-service-by-email': + command_line => "/usr/bin/printf \"%b\" \"***** Nagios *****\\n\\nNotification Type: \$NOTIFICATIONTYPE\$\\n\\nService: \$SERVICEDESC\$\\nHost: \$HOSTALIAS\$\\nAddress: \$HOSTADDRESS\$\\nState: \$SERVICESTATE\$\\n\\nDate/Time: \$LONGDATETIME\$\\n\\nAdditional Info:\\n\\n\$SERVICEOUTPUT\$\" | ${mail_cmd_location} -s \"** \$NOTIFICATIONTYPE\$ Service Alert: \$HOSTALIAS\$/\$SERVICEDESC\$ is \$SERVICESTATE\$ **\" \$CONTACTEMAIL\$"; + } + } + } } -- cgit v1.2.3 From 0b20e1e0fd001cb0b688c6bf6971c8e7c3f743c6 Mon Sep 17 00:00:00 2001 From: kwadronaut Date: Fri, 25 Jan 2013 15:18:11 +0100 Subject: adding Debian specific nrpe template (fixes stop/restart of nrpe-server) --- manifests/nrpe.pp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'manifests') diff --git a/manifests/nrpe.pp b/manifests/nrpe.pp index 5c05ed4..3ef7d07 100644 --- a/manifests/nrpe.pp +++ b/manifests/nrpe.pp @@ -8,6 +8,11 @@ class nagios::nrpe { 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' } + 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' } -- cgit v1.2.3 From f2e75a6e5143ad794275ee7c1c14577d787095cb Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 19 Apr 2015 15:18:46 -0400 Subject: Only use the private directory on CentOS Debian and ubuntu have their resource.cfg file placed in /etc/nagios3/ and when it's absent it can cause issues with the package (because the package is badly done). --- manifests/base.pp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'manifests') diff --git a/manifests/base.pp b/manifests/base.pp index 0f8b777..8f99564 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -44,17 +44,26 @@ class nagios::base { mode => 0640, owner => root, group => apache; } - file { 'nagios_private': - path => "${nagios::defaults::vars::int_cfgdir}/private/", - ensure => directory, - purge => true, - recurse => true, - notify => Service['nagios'], - mode => '0750', owner => root, group => nagios; + if $::operatingsystem == 'Centos' { + file { 'nagios_private': + ensure => directory, + path => "${nagios::defaults::vars::int_cfgdir}/private/", + purge => true, + recurse => true, + mode => '0750', + owner => 'root', + group => 'nagios', + notify => Service['nagios'], + } + + $resource_cfg_dir = "${nagios::defaults::vars::int_cfgdir}/private" + } + else { + $resource_cfg_dir = $nagios::defaults::vars::int_cfgdir } file { 'nagios_private_resource_cfg': - path => "${nagios::defaults::vars::int_cfgdir}/private/resource.cfg", + path => "${resource_cfg_dir}/resource.cfg", source => [ "puppet:///modules/site_nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}", "puppet:///modules/nagios/configs/${::operatingsystem}/private/resource.cfg.${::architecture}" ], notify => Service['nagios'], -- cgit v1.2.3 From 0db7f5c149d0529f9566dcc96acfb064178d281a Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 25 Jan 2013 18:37:45 -0200 Subject: Fixing plugin path for debian --- manifests/plugin.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'manifests') diff --git a/manifests/plugin.pp b/manifests/plugin.pp index d32606b..6d849fd 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -4,7 +4,10 @@ define nagios::plugin( ){ file{$name: path => $::hardwaremodel ? { - 'x86_64' => "/usr/lib64/nagios/plugins/${name}", + 'x86_64' => $::operatingsystem ? { + 'debian' => "/usr/lib/nagios/plugins/${name}", + default => "/usr/lib64/nagios/plugins/${name}", + }, default => "/usr/lib/nagios/plugins/${name}", }, ensure => $ensure, -- cgit v1.2.3 From 4bd026dfedc07de63ae5bd8c7ef86eaa70bb6390 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 19 Apr 2015 16:08:38 -0400 Subject: lint plugin.pp This should make it easier to read the code. --- manifests/plugin.pp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'manifests') diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 6d849fd..f2e4ed2 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -1,22 +1,27 @@ define nagios::plugin( - $source = 'absent', - $ensure = present + $source = 'absent', + $ensure = present ){ + if $::hardwaremodel == 'x86_64' and $::operatingsystem != 'debian' { + $real_path = "/usr/lib64/nagios/plugins/${name}" + } + else { + $real_path = "/usr/lib/nagios/plugins/${name}" + } + + $real_source = $source ? { + 'absent' => "puppet:///modules/nagios/plugins/${name}", + default => "puppet:///modules/${source}" + } + file{$name: - path => $::hardwaremodel ? { - 'x86_64' => $::operatingsystem ? { - 'debian' => "/usr/lib/nagios/plugins/${name}", - default => "/usr/lib64/nagios/plugins/${name}", - }, - default => "/usr/lib/nagios/plugins/${name}", - }, - ensure => $ensure, - source => $source ? { - 'absent' => "puppet:///modules/nagios/plugins/${name}", - default => "puppet:///modules/${source}" - }, - tag => 'nagios_plugin', + ensure => $ensure, + path => $real_path, + source => $real_source, + tag => 'nagios_plugin', require => Package['nagios-plugins'], - owner => root, group => 0, mode => 0755; + owner => 'root', + group => 0, + mode => '0755'; } } -- cgit v1.2.3 From 7288988a6d3f2785f5e23bd2d7a7f6c275421c00 Mon Sep 17 00:00:00 2001 From: nadir Date: Thu, 8 Nov 2012 14:42:27 +0100 Subject: unquoted boolean variables --- manifests/service.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'manifests') diff --git a/manifests/service.pp b/manifests/service.pp index 134d1f7..918ce24 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -30,8 +30,8 @@ define nagios::service ( if $check_comand == 'absent' { fail("Must pass a check_command to ${name} if it should be present") } - if ($use_nrpe == 'true') { - include nagios::command::nrpe_timeout + if ($use_nrpe == true) { + include nagios::command::nrpe_timeout if ($nrpe_args != '') { $real_check_command = "check_nrpe_timeout!$nrpe_timeout!$check_command!\"$nrpe_args\"" -- cgit v1.2.3 From df559db6f6cbe65393b2ebcc571ebdaed06e0cf3 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 19 Apr 2015 17:07:41 -0400 Subject: nagios::service typo in variable This invalidates the point of that if block since it will probably never be true that some undefined (read mis-typed) variable is set to 'absent'. --- manifests/service.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'manifests') diff --git a/manifests/service.pp b/manifests/service.pp index 918ce24..3e8f6c8 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -27,7 +27,7 @@ define nagios::service ( } if $ensure != 'absent' { - if $check_comand == 'absent' { + if $check_command == 'absent' { fail("Must pass a check_command to ${name} if it should be present") } if ($use_nrpe == true) { -- cgit v1.2.3 From 29c61a62a49f042678a16331e2fd67bb7ae1ee57 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Thu, 23 Apr 2015 16:06:27 -0400 Subject: stop defining an alias by default for hosts Since the "alias" attribute is special for puppet in that it needs to be a string that's unique throughout all of the resources on a given host's catalogue, we shouldn't always define an alias unless users really want them. This alias might (and did for some ppl) create a conflict when using a class that is named the same as $::hostname. --- manifests/target.pp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'manifests') diff --git a/manifests/target.pp b/manifests/target.pp index f9b7e13..be6c40e 100644 --- a/manifests/target.pp +++ b/manifests/target.pp @@ -3,14 +3,20 @@ class nagios::target( $parents = 'absent', $address = $::ipaddress, - $nagios_alias = $::hostname, + $nagios_alias = false, $hostgroups = 'absent' ){ @@nagios_host { $::fqdn: address => $address, - alias => $nagios_alias, use => 'generic-host', } + # Watch out with using aliases: they need to be unique throughout *all* + # resources in a given host's catalogue. + if $nagios_alias { + Nagios_host[$::fqdn] { + alias => $nagios_alias, + } + } if ($parents != 'absent') { Nagios_host["${::fqdn}"] { parents => $parents } -- cgit v1.2.3 From 53c19e4a83782daa518ac2597ff751c8ac5111a0 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Sun, 19 Apr 2015 15:43:47 -0400 Subject: require package before config files In the current state of the module, almost 100% of the time nagios doesn't install correctly since ordering of the resources is not enforced. --- manifests/base.pp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'manifests') diff --git a/manifests/base.pp b/manifests/base.pp index 8f99564..687261d 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -22,8 +22,9 @@ class nagios::base { "puppet:///modules/site_nagios/configs/nagios.cfg", "puppet:///modules/nagios/configs/${::operatingsystem}/nagios.cfg", "puppet:///modules/nagios/configs/nagios.cfg" ], - notify => Service['nagios'], - mode => 0644, owner => root, group => root; + notify => Service['nagios'], + require => Package['nagios'], + mode => 0644, owner => root, group => root; } file { 'nagios_cgi_cfg': @@ -35,12 +36,14 @@ class nagios::base { "puppet:///modules/nagios/configs/cgi.cfg" ], mode => '0644', owner => 'root', group => 0, notify => Service['apache'], + require => Package['nagios'], } file { 'nagios_htpasswd': path => "${nagios::defaults::vars::int_cfgdir}/htpasswd.users", source => [ "puppet:///modules/site_nagios/htpasswd.users", "puppet:///modules/nagios/htpasswd.users" ], + require => Package['nagios'], mode => 0640, owner => root, group => apache; } @@ -53,6 +56,7 @@ class nagios::base { mode => '0750', owner => 'root', group => 'nagios', + require => Package['nagios'], notify => Service['nagios'], } @@ -76,6 +80,7 @@ class nagios::base { purge => true, recurse => true, notify => Service['nagios'], + require => Package['nagios'], mode => '0750', owner => root, group => nagios; } Nagios_command <<||>> @@ -179,6 +184,7 @@ class nagios::base { ensure => file, replace => false, notify => Service['nagios'], + require => Package['nagios'], mode => 0644, owner => root, group => 0; } @@ -190,6 +196,7 @@ class nagios::base { recurse => true, purge => true, notify => Service['nagios'], + require => Package['nagios'], mode => 0755, owner => root, group => root; } } -- cgit v1.2.3