diff options
Diffstat (limited to 'manifests')
29 files changed, 329 insertions, 198 deletions
diff --git a/manifests/apache.pp b/manifests/apache.pp index c560e5b..a90d0ee 100644 --- a/manifests/apache.pp +++ b/manifests/apache.pp @@ -1,21 +1,29 @@ -class nagios::apache inherits ::apache { - $nagios_httpd = 'apache' - include nagios +class nagios::apache( + $allow_external_cmd = false, + $manage_shorewall = false, + $manage_munin = false +) { + class{'nagios': + httpd => 'apache', + allow_external_cmd => $allow_external_cmd, + manage_munin => $manage_munin, + manage_shorewall => $manage_shorewall, + } - case $operatingsystem { - 'debian': { - file { "${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf": - ensure => present, - source => ["puppet:///site-nagios/configs/${fqdn}/apache2.conf", - "puppet:///site-nagios/configs/apache2.conf", - "puppet:///nagios/configs/apache2.conf"], - } + case $::operatingsystem { + 'debian': { + file { "${nagios::defaults::vars::int_cfgdir}/apache2.conf": + ensure => present, + source => [ "puppet:///site_nagios/configs/${::fqdn}/apache2.conf", + "puppet:///site_nagios/configs/apache2.conf", + "puppet:///nagios/configs/apache2.conf"], + } - apache::config::global { "nagios3.conf": - ensure => link, - target => "${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf", - require => File["${nagios::defaults::vars::int_nagios_cfgdir}/apache2.conf"], - } - } + apache::config::global { "nagios3.conf": + ensure => link, + target => "${nagios::defaults::vars::int_cfgdir}/apache2.conf", + require => File["${nagios::defaults::vars::int_cfgdir}/apache2.conf"], + } } + } } diff --git a/manifests/base.pp b/manifests/base.pp index 589e98b..d4d6590 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -4,7 +4,7 @@ class nagios::base { package { 'nagios': alias => 'nagios', - ensure => present, + ensure => present, } service { 'nagios': @@ -16,15 +16,15 @@ class nagios::base { # this file should contain all the nagios_puppet-paths: file { 'nagios_main_cfg': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/nagios.cfg", - source => [ "puppet:///modules/site-nagios/configs/${fqdn}/nagios.cfg", - "puppet:///modules/site-nagios/configs/${operatingsystem}/nagios.cfg", - "puppet:///modules/site-nagios/configs/nagios.cfg", - "puppet:///modules/nagios/configs/${operatingsystem}/nagios.cfg", + path => "${nagios::defaults::vars::int_cfgdir}/nagios.cfg", + source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/nagios.cfg", + "puppet:///modules/site_nagios/configs/${::operatingsystem}/nagios.cfg", + "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; - } + } file { 'nagios_commands_cfg': path => "${nagios::defaults::vars::int_nagios_cfgdir}/commands.cfg", @@ -34,26 +34,25 @@ class nagios::base { } file { 'nagios_cgi_cfg': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/cgi.cfg", - source => [ "puppet:///modules/site-nagios/configs/${fqdn}/cgi.cfg", - "puppet:///modules/site-nagios/configs/${operatingsystem}/cgi.cfg", - "puppet:///modules/site-nagios/configs/cgi.cfg", - "puppet:///modules/nagios/configs/${operatingsystem}/cgi.cfg", + path => "${nagios::defaults::vars::int_cfgdir}/cgi.cfg", + source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/cgi.cfg", + "puppet:///modules/site_nagios/configs/${::operatingsystem}/cgi.cfg", + "puppet:///modules/site_nagios/configs/cgi.cfg", + "puppet:///modules/nagios/configs/${::operatingsystem}/cgi.cfg", "puppet:///modules/nagios/configs/cgi.cfg" ], mode => '0644', owner => 'root', group => 0, notify => Service['apache'], } file { 'nagios_htpasswd': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/htpasswd.users", - source => [ "puppet:///modules/site-nagios/htpasswd.users", + path => "${nagios::defaults::vars::int_cfgdir}/htpasswd.users", + source => [ "puppet:///modules/site_nagios/htpasswd.users", "puppet:///modules/nagios/htpasswd.users" ], mode => 0640, owner => root, group => apache; } file { 'nagios_private': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/", - source => "puppet:///modules/common/empty", + path => "${nagios::defaults::vars::int_cfgdir}/private/", ensure => directory, purge => true, recurse => true, @@ -62,24 +61,21 @@ class nagios::base { } file { 'nagios_private_resource_cfg': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/private/resource.cfg", - source => [ "puppet:///modules/site-nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}", - "puppet:///modules/nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}" ], + path => "${nagios::defaults::vars::int_cfgdir}/private/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'], owner => root, group => nagios, mode => '0640'; } file { 'nagios_confd': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/", - source => "puppet:///modules/common/empty", + path => "${nagios::defaults::vars::int_cfgdir}/conf.d/", ensure => directory, purge => true, recurse => true, notify => Service['nagios'], mode => '0750', owner => root, group => nagios; } - Package <<| tag == 'nagios::plugin::deploy::package' |>> - File <<| tag == 'nagios::plugin::deploy::file' |>> Nagios_command <<||>> Nagios_contactgroup <<||>> Nagios_contact <<||>> @@ -94,91 +90,90 @@ class nagios::base { Nagios_serviceextinfo <<||>> Nagios_service <<||>> Nagios_timeperiod <<||>> - File <<| tag == 'nagios_plugin' |>> Nagios_command <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_command.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_contact <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_contactgroup <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_host <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_hostdependency <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostdependency.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg", notify => Service['nagios'], } Nagios_hostescalation <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostescalation.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg", notify => Service['nagios'], } Nagios_hostextinfo <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_hostgroup <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_service <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_servicegroup <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicegroup.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg", notify => Service['nagios'], } Nagios_servicedependency <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_serviceescalation <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_serviceextinfo <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg", require => File['nagios_confd'], notify => Service['nagios'], } Nagios_timeperiod <||> { - target => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg", + target => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg", require => File['nagios_confd'], notify => Service['nagios'], } - file{[ "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_command.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contact.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_contactgroup.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_host.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostdependency.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostescalation.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostextinfo.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroup.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_hostgroupescalation.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_service.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicedependency.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceescalation.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_serviceextinfo.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_servicegroup.cfg", - "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_timeperiod.cfg" ]: + file{[ "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_command.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contact.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_contactgroup.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_host.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostdependency.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostescalation.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostextinfo.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroup.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_hostgroupescalation.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_service.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicedependency.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceescalation.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_serviceextinfo.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_servicegroup.cfg", + "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_timeperiod.cfg" ]: ensure => file, replace => false, notify => Service['nagios'], @@ -188,17 +183,11 @@ class nagios::base { # manage nagios cfg files # must be defined after exported resource overrides and cfg file defs file { 'nagios_cfgdir': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/", - source => "puppet:///modules/common/empty", + path => "${nagios::defaults::vars::int_cfgdir}/", ensure => directory, recurse => true, purge => true, notify => Service['nagios'], mode => 0755, owner => root, group => root; } - - if $use_munin { - include nagios::munin - } - } diff --git a/manifests/centos.pp b/manifests/centos.pp index 35379b8..5a2ba23 100644 --- a/manifests/centos.pp +++ b/manifests/centos.pp @@ -9,7 +9,7 @@ class nagios::centos inherits nagios::base { hasstatus => true, } - if ($nagios_allow_external_cmd) { + if $nagios::allow_external_cmd { file { '/var/spool/nagios/cmd': ensure => 'directory', require => Package['nagios'], diff --git a/manifests/debian.pp b/manifests/debian.pp index b9e87ec..bb9bb38 100644 --- a/manifests/debian.pp +++ b/manifests/debian.pp @@ -14,13 +14,13 @@ class nagios::debian inherits nagios::base { File['nagios_htpasswd', 'nagios_cgi_cfg'] { group => 'www-data' } - file { "${nagios::defaults::vars::int_nagios_cfgdir}/stylesheets": + file { "${nagios::defaults::vars::int_cfgdir}/stylesheets": ensure => directory, purge => false, recurse => true, } - if ($nagios_allow_external_cmd) { + if $nagios::allow_external_cmd { exec { 'nagios_external_cmd_perms_overrides': command => 'dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3', unless => 'dpkg-statoverride --list nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --list nagios nagios 751 /var/lib/nagios3', diff --git a/manifests/defaults/commands.pp b/manifests/defaults/commands.pp index 1213485..bb19638 100644 --- a/manifests/defaults/commands.pp +++ b/manifests/defaults/commands.pp @@ -4,7 +4,7 @@ class nagios::defaults::commands { include nagios::command::imap_pop3 # common service commands - case $operatingsystem { + case $::operatingsystem { debian,ubuntu: { nagios_command { check_dummy: @@ -66,7 +66,7 @@ class nagios::defaults::commands { check_http_url: command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$'; check_http_url_regex: - command_line => '$USER1$/check_http -H $ARG1$ -u $ARG2$ -e $ARG3$'; + command_line => '$USER1$/check_http -H $ARG1$ -p $ARG2$ -u $ARG3$ -e $ARG4$'; check_https_url: command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$'; check_https_url_regex: @@ -124,7 +124,7 @@ class nagios::defaults::commands { # notification commands - $mail_cmd_location = $operatingsystem ? { + $mail_cmd_location = $::operatingsystem ? { centos => '/bin/mail', default => '/usr/bin/mail' } diff --git a/manifests/defaults/plugins.pp b/manifests/defaults/plugins.pp index 18f8161..abd8b52 100644 --- a/manifests/defaults/plugins.pp +++ b/manifests/defaults/plugins.pp @@ -1,5 +1,4 @@ class nagios::defaults::plugins { - nagios::plugin { 'check_mysql_health': source => 'nagios/plugins/check_mysql_health'; @@ -8,5 +7,4 @@ class nagios::defaults::plugins { 'check_dnsbl': source => 'nagios/plugins/check_dnsbl'; } - } diff --git a/manifests/defaults/pnp4nagios.pp b/manifests/defaults/pnp4nagios.pp new file mode 100644 index 0000000..f6556c9 --- /dev/null +++ b/manifests/defaults/pnp4nagios.pp @@ -0,0 +1,27 @@ +class nagios::defaults::pnp4nagios { + # performance data cmds + # http://docs.pnp4nagios.org/de/pnp-0.6/config#bulk_mode_mit_npcd + nagios_command { + 'process-service-perfdata-file-pnp4nagios-bulk-npcd': + command_line => '/bin/mv /var/lib/nagios3/service-perfdata /var/spool/pnp4nagios/npcd/service-perfdata.$TIMET$'; + 'process-host-perfdata-file-pnp4nagios-bulk-npcd': + command_line => '/bin/mv /var/lib/nagios3/host-perfdata /var/spool/pnp4nagios/npcd/host-perfdata.$TIMET$' + } + + # nagios host templates + # http://docs.pnp4nagios.org/de/pnp-0.6/webfe + + # this doesn't work, see manifests/pnp4nagios.pp + #nagios_host { 'host-pnp': + # action_url => '/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_', + # register => 0, + # #ensure => absent; + #} + + #nagios_service { 'service-pnp': + # #naginatorname => 'service-pnp', + # action_url => '/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$', + # register => 0, + # ensure => absent; + #} +} diff --git a/manifests/defaults/templates.pp b/manifests/defaults/templates.pp index c97eee4..0e73c97 100644 --- a/manifests/defaults/templates.pp +++ b/manifests/defaults/templates.pp @@ -1,15 +1,15 @@ class nagios::defaults::templates { - include nagios::defaults::vars + include nagios::defaults::vars - file { 'nagios_templates': - path => "${nagios::defaults::vars::int_nagios_cfgdir}/conf.d/nagios_templates.cfg", - source => [ "puppet:///modules/site-nagios/configs/${fqdn}/nagios_templates.cfg", - "puppet:///modules/site-nagios/configs/${operatingsystem}/nagios_templates.cfg", - "puppet:///modules/site-nagios/configs/nagios_templates.cfg", - "puppet:///modules/nagios/configs/${operatingsystem}/nagios_templates.cfg", - "puppet:///modules/nagios/configs/nagios_templates.cfg" ], - notify => Service['nagios'], - mode => 0644, owner => root, group => root; - } + file { 'nagios_templates': + path => "${nagios::defaults::vars::int_cfgdir}/conf.d/nagios_templates.cfg", + source => [ "puppet:///modules/site_nagios/configs/${::fqdn}/nagios_templates.cfg", + "puppet:///modules/site_nagios/configs/${::operatingsystem}/nagios_templates.cfg", + "puppet:///modules/site_nagios/configs/nagios_templates.cfg", + "puppet:///modules/nagios/configs/${::operatingsystem}/nagios_templates.cfg", + "puppet:///modules/nagios/configs/nagios_templates.cfg" ], + notify => Service['nagios'], + mode => 0644, owner => root, group => root; + } } diff --git a/manifests/defaults/vars.pp b/manifests/defaults/vars.pp index 6302f13..87f41f8 100644 --- a/manifests/defaults/vars.pp +++ b/manifests/defaults/vars.pp @@ -1,10 +1,10 @@ class nagios::defaults::vars { - case $nagios_cfgdir { - '': { $int_nagios_cfgdir = $operatingsystem ? { + case $nagios::cfgdir { + '': { $int_cfgdir = $::operatingsystem ? { centos => '/etc/nagios/', default => '/etc/nagios3' } } - default: { $int_nagios_cfgdir = $nagios_cfgdir } + default: { $int_cfgdir = $nagios::cfgdir } } } diff --git a/manifests/init.pp b/manifests/init.pp index 1aecc3a..12d3db2 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -8,28 +8,36 @@ # Marcel Härry haerry+puppet(at)puzzle.ch # Simon Josi josi+puppet(at)puzzle.ch # -# This program is free software; you can redistribute -# it and/or modify it under the terms of the GNU -# General Public License version 3 as published by +# This program is free software; you can redistribute +# it and/or modify it under the terms of the GNU +# General Public License version 3 as published by # the Free Software Foundation. # -class nagios { - case $nagios_httpd { - 'absent': { } - 'lighttpd': { include lighttpd } - 'apache': { include apache } - default: { include apache } +class nagios( + $httpd = 'apache', + $allow_external_cmd = false, + $manage_shorewall = false, + $manage_munin = false +) { + case $nagios::httpd { + 'absent': { } + 'lighttpd': { include ::lighttpd } + 'apache': { include ::apache } + default: { include ::apache } + } + case $::operatingsystem { + 'centos': { + $cfgdir = '/etc/nagios' + include nagios::centos } - case $operatingsystem { - 'centos': { - $nagios_cfgdir = '/etc/nagios' - include nagios::centos - } - 'debian': { - $nagios_cfgdir = '/etc/nagios3' - include nagios::debian - } - default: { fail("No such operatingsystem: $operatingsystem yet defined") } + 'debian': { + $cfgdir = '/etc/nagios3' + include nagios::debian } + default: { fail("No such operatingsystem: ${::operatingsystem} yet defined") } + } + if $manage_munin { + include nagios::munin + } } diff --git a/manifests/irc_bot.pp b/manifests/irc_bot.pp index 7629b94..a034fe0 100644 --- a/manifests/irc_bot.pp +++ b/manifests/irc_bot.pp @@ -1,22 +1,22 @@ class nagios::irc_bot { - if ( ! ($nagios_nsa_server and $nagios_nsa_nickname and $nagios_nsa_channel) ) { - fail("Please provide values at least for \$nagios_nsa_server, \$nagios_nsa_nickname and \$nagios_nsa_channel") + if ( ! ($nsa_server and $nsa_nickname and $nsa_channel) ) { + fail("Please provide values at least for \$nsa_server, \$nsa_nickname and \$nsa_channel") } case $operatingsystem { centos: { - $nagios_nsa_default_socket = '/var/run/nagios-nsa/nsa.socket' - $nagios_nsa_default_pidfile = '/var/run/nagios-nsa/nsa.pid' + $nsa_default_socket = '/var/run/nagios-nsa/nsa.socket' + $nsa_default_pidfile = '/var/run/nagios-nsa/nsa.pid' include nagios::irc_bot::centos } default: { - $nagios_nsa_default_socket = '/var/run/nagios3/nsa.socket' - $nagios_nsa_default_pidfile = '/var/run/nagios3/nsa.pid' + $nsa_default_socket = '/var/run/nagios3/nsa.socket' + $nsa_default_pidfile = '/var/run/nagios3/nsa.pid' include nagios::irc_bot::base } } - if $use_shorewall { + if $nagios::manage_shorewall { include shorewall::rules::out::irc } } diff --git a/manifests/irc_bot/base.pp b/manifests/irc_bot/base.pp index c36d8e6..6fab2ac 100644 --- a/manifests/irc_bot/base.pp +++ b/manifests/irc_bot/base.pp @@ -1,29 +1,29 @@ class nagios::irc_bot::base { # Default values for the two first variables are defined in nagios::irc_bot - $nagios_nsa_socket = $nagios_nsa_socket ? { - '' => $nagios_nsa_default_socket, - default => $nagios_nsa_socket, + $nsa_socket = $nsa_socket ? { + '' => $nsa_default_socket, + default => $nsa_socket, } - $nagios_nsa_pidfile = $nagios_nsa_pidfile ? { - '' => $nagios_nsa_default_pidfile, - default => $nagios_nsa_pidfile, + $nsa_pidfile = $nsa_pidfile ? { + '' => $nsa_default_pidfile, + default => $nsa_pidfile, } - $nagios_nsa_port = $nagios_nsa_port ? { + $nsa_port = $nsa_port ? { '' => '6667', - default => $nagios_nsa_port, + default => $nsa_port, } - $nagios_nsa_realname = $nagios_nsa_realname ? { + $nsa_realname = $nsa_realname ? { '' => 'Nagios', - default => $nagios_nsa_realname, + default => $nsa_realname, } - if (! $nagios_nsa_password) { - $nagios_nsa_password = '' + if (! $nsa_password) { + $nsa_password = '' } - if (! $nagios_nsa_usenotices) { - $nagios_nsa_usenotices = '' + if (! $nsa_usenotices) { + $nsa_usenotices = '' } file { "/usr/local/bin/riseup-nagios-client.pl": diff --git a/manifests/lighttpd.pp b/manifests/lighttpd.pp index 27aff43..0f29896 100644 --- a/manifests/lighttpd.pp +++ b/manifests/lighttpd.pp @@ -1,4 +1,12 @@ -class nagios::lighttpd { - $nagios_httpd = 'lighttpd' - include nagios +class nagios::lighttpd( + $allow_external_cmd = false, + $manage_shorewall = false, + $manage_munin = false +) { + class{'nagios': + httpd => 'lighttpd', + allow_external_cmd => $allow_external_cmd, + manage_munin => $manage_munin, + manage_shorewall => $manage_shorewall, + } } diff --git a/manifests/munin.pp b/manifests/munin.pp index 92a389f..490b016 100644 --- a/manifests/munin.pp +++ b/manifests/munin.pp @@ -17,12 +17,12 @@ class nagios::munin inherits munin::plugins::base { exec { 'munin_nagios2stats_link': command => 'ln -s /usr/sbin/nagios2stats /usr/local/sbin/nagiostats', - onlyif => ["test ! -e /usr/local/sbin/nagiostats", "test -e /usr/sbin/nagios2stats"], + onlyif => ["/usr/bin/test ! -e /usr/local/sbin/nagiostats", "/usr/bin/test -e /usr/sbin/nagios2stats"], } exec { 'munin_nagios3stats_link': command => 'ln -s /usr/sbin/nagios3stats /usr/local/sbin/nagiostats', - onlyif => ["test ! -e /usr/local/sbin/nagiostats", "test -e /usr/sbin/nagios3stats"], + onlyif => ["/usr/bin/test ! -e /usr/local/sbin/nagiostats", "/usr/bin/test -e /usr/sbin/nagios3stats"], } } diff --git a/manifests/nsca/client.pp b/manifests/nsca/client.pp index 6e2c472..e58721d 100644 --- a/manifests/nsca/client.pp +++ b/manifests/nsca/client.pp @@ -1,10 +1,10 @@ class nagios::nsca::client { package { 'nsca': ensure => installed } - + file { '/etc/send_nsca.cfg': - source => [ "puppet:///modules/site-nagios/nsca/{$fqdn}/send_nsca.cfg", - "puppet:///modules/site-nagios/nsca/send_nsca.cfg", + source => [ "puppet:///modules/site_nagios/nsca/{$::fqdn}/send_nsca.cfg", + "puppet:///modules/site_nagios/nsca/send_nsca.cfg", "puppet:///modules/nagios/nsca/send_nsca.cfg" ], owner => 'nagios', group => 'nogroup', diff --git a/manifests/nsca/server.pp b/manifests/nsca/server.pp index 238e49e..bd5389d 100644 --- a/manifests/nsca/server.pp +++ b/manifests/nsca/server.pp @@ -10,8 +10,8 @@ class nagios::nsca::server { } file { '/etc/nsca.cfg': - source => [ "puppet:///modules/site-nagios/nsca/{$fqdn}/nsca.cfg", - "puppet:///modules/site-nagios/nsca/nsca.cfg", + source => [ "puppet:///modules/site_nagios/nsca/{$::fqdn}/nsca.cfg", + "puppet:///modules/site_nagios/nsca/nsca.cfg", "puppet:///modules/nagios/nsca/nsca.cfg" ], owner => 'nagios', group => 'nogroup', diff --git a/manifests/plugin.pp b/manifests/plugin.pp index abaa6e5..d32606b 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -2,15 +2,15 @@ define nagios::plugin( $source = 'absent', $ensure = present ){ - @@file{$name: - path => $hardwaremodel ? { - 'x86_64' => "/usr/lib64/nagios/plugins/$name", - default => "/usr/lib/nagios/plugins/$name", + file{$name: + path => $::hardwaremodel ? { + 'x86_64' => "/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" + 'absent' => "puppet:///modules/nagios/plugins/${name}", + default => "puppet:///modules/${source}" }, tag => 'nagios_plugin', require => Package['nagios-plugins'], diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 75f87d7..3f2a1a4 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -5,26 +5,26 @@ define nagios::plugin::deploy($source = '', $ensure = 'present', $config = '', $ default => $ensure } $real_source = $source ? { - '' => "nagios/plugins/$plugin_src", + '' => "nagios/plugins/${plugin_src}", default => $source } if !defined(Package[$require_package]) { - @@package { $require_package: + package { $require_package: ensure => installed, tag => "nagios::plugin::deploy::package"; } } - + include nagios::plugin::scriptpaths - @@file { "nagios_plugin_${name}": + file { "nagios_plugin_${name}": path => "$nagios::plugin::scriptpaths::script_path/${name}", - source => "puppet://$server/modules/$real_source", + source => "puppet:///modules/${real_source}", mode => 0755, owner => root, group => 0, require => Package[$require_package], tag => "nagios::plugin::deploy::file"; } # register the plugin - @@nagios::plugin{$name: ensure => $ensure, require => Package['nagios-plugins'] } + nagios::plugin{$name: ensure => $ensure, require => Package['nagios-plugins'] } } diff --git a/manifests/plugin/scriptpaths.pp b/manifests/plugin/scriptpaths.pp index 6065709..9cd4b5d 100644 --- a/manifests/plugin/scriptpaths.pp +++ b/manifests/plugin/scriptpaths.pp @@ -1,5 +1,5 @@ class nagios::plugin::scriptpaths { - case $hardwaremodel { + case $::hardwaremodel { x86_64: { $script_path = "/usr/lib64/nagios/plugins/" } default: { $script_path = "/usr/lib/nagios/plugins" } } diff --git a/manifests/plugins/jabber.pp b/manifests/plugins/jabber.pp new file mode 100644 index 0000000..380a5c0 --- /dev/null +++ b/manifests/plugins/jabber.pp @@ -0,0 +1,10 @@ +class nagios::plugins::jabber { + + # for check_jabber_login + require rubygems::xmpp4r + + nagios::plugin { 'check_jabber_login': + source => 'nagios/plugins/check_jabber_login' + } +} + diff --git a/manifests/pnp4nagios.pp b/manifests/pnp4nagios.pp new file mode 100644 index 0000000..7c960a7 --- /dev/null +++ b/manifests/pnp4nagios.pp @@ -0,0 +1,57 @@ +class nagios::pnp4nagios { + include nagios::defaults::pnp4nagios + + package { pnp4nagios: + ensure => installed } + + + # unfortunatly i didn't find a way to use nagios_host and nagios_service definition, because + # imho puppet can't handle the "name" variable needed in these 2 definitions + # so we need to copy a file here. + + file { 'pnp4nagios-templates.cfg': + path => "${nagios::defaults::vars::int_cfgdir}/conf.d/pnp4nagios-templates.cfg", + source => [ "puppet:///modules/site-nagios/pnp4nagios/pnp4nagios-templates.cfg", + "puppet:///modules/nagios/pnp4nagios/pnp4nagios-templates.cfg" ], + mode => 0644, owner => root, group => root, + notify => Service['nagios'], + } + + file { 'apache.conf': + path => "/etc/pnp4nagios/apache.conf", + source => [ "puppet:///modules/site-nagios/pnp4nagios/apache.conf", + "puppet:///modules/nagios/pnp4nagios/apache.conf" ], + mode => 0644, owner => root, group => root, + notify => Service['apache'], + require => Package['pnp4nagios'], + } + + # run npcd as daemon + + file { '/etc/default/npcd': + path => "/etc/default/npcd", + source => [ "puppet:///modules/site-nagios/pnp4nagios/npcd", + "puppet:///modules/nagios/pnp4nagios/npcd" ], + mode => 0644, owner => root, group => root, + notify => Service['npcd']; + } + + service { 'npcd': + ensure => running, + enable => true, + hasstatus => true, + require => Package['pnp4nagios'], + } + + # modify action.gif + + file { '/usr/share/nagios3/htdocs/images/action.gif': + path => "/usr/share/nagios3/htdocs/images/action.gif", + source => [ "puppet:///modules/site-nagios/pnp4nagios/action.gif", + "puppet:///modules/nagios/pnp4nagios/action.gif" ], + mode => 0644, owner => root, group => root, + notify => Service['nagios']; + } + + +} diff --git a/manifests/pnp4nagios/popup.pp b/manifests/pnp4nagios/popup.pp new file mode 100644 index 0000000..a8de7c7 --- /dev/null +++ b/manifests/pnp4nagios/popup.pp @@ -0,0 +1,17 @@ +class nagios::pnp4nagios::popup inherits nagios::pnp4nagios { + File['pnp4nagios-templates.cfg']{ + source => [ "puppet:///modules/site-nagios/pnp4nagios/pnp4nagios-popup-templates.cfg", + "puppet:///modules/nagios/pnp4nagios/pnp4nagios-popup-templates.cfg" ], + } + + file { "/usr/share/nagios3/htdocs/ssi": + ensure => directory } + + file { 'status-header.ssi': + path => "/usr/share/nagios3/htdocs/ssi/status-header.ssi", + source => [ "puppet:///modules/site-nagios/pnp4nagios/status-header.ssi", + "puppet:///modules/nagios/pnp4nagios/status-header.ssi"], + mode => 0644, owner => root, group => root, + notify => Service['nagios'], + } +} diff --git a/manifests/service.pp b/manifests/service.pp index 55b2254..71f78b0 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,6 +1,6 @@ define nagios::service ( $ensure = present, - $host_name = $fqdn, + $host_name = $::fqdn, $check_command, $check_period = '', $normal_check_interval = '', @@ -19,7 +19,7 @@ define nagios::service ( # TODO: this resource should normally accept all nagios_host parameters - $real_name = "${hostname}_${name}" + $real_name = "${::hostname}_${name}" if ($use_nrpe == 'true') { include nagios::command::nrpe_timeout diff --git a/manifests/service/http.pp b/manifests/service/http.pp index 8fd5059..ef63abb 100644 --- a/manifests/service/http.pp +++ b/manifests/service/http.pp @@ -6,6 +6,7 @@ define nagios::service::http( $ensure = present, $check_domain = 'absent', + $port = '80', $check_url = '/', $check_code = 'OK', $use = 'generic-service', @@ -27,7 +28,7 @@ define nagios::service::http( nagios::service{"httprd_${name}": ensure => $ensure, use => $use, - check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'301'", + check_command => "check_http_url_regex!${real_check_domain}!${port}!${check_url}!'301'", } } } @@ -38,7 +39,7 @@ define nagios::service::http( nagios::service{"http_${name}_${check_code}": ensure => $ensure, use => $use, - check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'${check_code}'", + check_command => "check_http_url_regex!${real_check_domain}!${port}!${check_url}!'${check_code}'", } } } diff --git a/manifests/service/mysql.pp b/manifests/service/mysql.pp index 2fde402..94881d8 100644 --- a/manifests/service/mysql.pp +++ b/manifests/service/mysql.pp @@ -1,11 +1,11 @@ -# Checks a mysql instance via tcp or socket +# Checks a mysql instance via tcp or socket define nagios::service::mysql( $ensure = present, $check_host = 'absent', $check_port = '3306', $check_username = 'nagios', - $check_password = $nagios_mysql_password, + $check_password = trocla("mysql_nagios_${::fqdn}",'plain','length: 32'), $check_database = 'information_schema', $check_warning = undef, $check_critical = undef, @@ -28,7 +28,7 @@ define nagios::service::mysql( if $check_warning != undef { $real_check_warning = "!--warning $check_warning" } - + if $check_critical != undef { $real_check_critical = "!--critical $check_critical" } @@ -51,7 +51,7 @@ define nagios::service::mysql( } } } - + nagios::service { "mysql_health_${name}": ensure => $ensure, check_command => "check_mysql_health!${real_check_host}!${check_port}!${check_username}!${check_password}!${check_health_mode}!${check_database}${real_check_name}${real_check_warning}${real_check_critical}", diff --git a/manifests/service/ntp.pp b/manifests/service/ntp.pp index eca255a..b3cde2a 100644 --- a/manifests/service/ntp.pp +++ b/manifests/service/ntp.pp @@ -1,9 +1,9 @@ # manifests/service/ntp.pp class nagios::service::ntp { - nagios::service{ "check_ntp": - check_command => "check_ntp_time", - host_name => $fqdn, - } + nagios::service{ "check_ntp": + check_command => "check_ntp_time", + host_name => $::fqdn, + } } diff --git a/manifests/service/ping.pp b/manifests/service/ping.pp index c705c68..f1c8d87 100644 --- a/manifests/service/ping.pp +++ b/manifests/service/ping.pp @@ -1,13 +1,9 @@ define nagios::service::ping( - $ensure = present + $ensure = present, + $ping_rate = '!100.0,20%!500.0,60%' ){ - $real_nagios_ping_rate = $nagios_ping_rate ? { - '' => '!100.0,20%!500.0,60%', - default => $nagios_ping_rate - } - - nagios::service{ "check_ping": - ensure => $ensure, - check_command => "check_ping${real_nagios_ping_rate}", - } + nagios::service{ "check_ping": + ensure => $ensure, + check_command => "check_ping${ping_rate}", + } } diff --git a/manifests/target.pp b/manifests/target.pp index 675ac1a..f9b7e13 100644 --- a/manifests/target.pp +++ b/manifests/target.pp @@ -1,15 +1,22 @@ # manifests/target.pp -class nagios::target { +class nagios::target( + $parents = 'absent', + $address = $::ipaddress, + $nagios_alias = $::hostname, + $hostgroups = 'absent' +){ + @@nagios_host { $::fqdn: + address => $address, + alias => $nagios_alias, + use => 'generic-host', + } - @@nagios_host { "${fqdn}": - address => $ipaddress, - alias => $hostname, - use => 'generic-host', - } - - if ($nagios_parents != '') { - Nagios_host["${fqdn}"] { parents => $nagios_parents } - } + if ($parents != 'absent') { + Nagios_host["${::fqdn}"] { parents => $parents } + } + if ($hostgroups != 'absent') { + Nagios_host["${::fqdn}"] { hostgroups => $hostgroups } + } } diff --git a/manifests/target/fqdn.pp b/manifests/target/fqdn.pp index acac5d6..6bb16c1 100644 --- a/manifests/target/fqdn.pp +++ b/manifests/target/fqdn.pp @@ -1,5 +1,10 @@ -class nagios::target::fqdn inherits nagios::target { - - Nagios_host["${fqdn}"] { address => "${fqdn}" } - +class nagios::target::fqdn( + $hostgroups = 'absent', + $parents = 'absent' +) { + class{'nagios::target': + address => $::fqdn, + hostgroups => $hostgroups, + parents => $parents + } } |