From 011d5e028f86e9eeba1c05e251063b45004d210e Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 13 Jun 2009 15:41:24 +0200 Subject: put everything into its own file --- manifests/base.pp | 131 ++++++++++++++++++++++++++++++ manifests/centos.pp | 47 +++++++++++ manifests/command.pp | 11 +++ manifests/defines.pp | 200 ---------------------------------------------- manifests/extra_host.pp | 25 ++++++ manifests/host.pp | 37 +++++++++ manifests/init.pp | 183 ------------------------------------------ manifests/plugin.pp | 14 ++++ manifests/service.pp | 52 ++++++++++++ manifests/service/http.pp | 41 ++++++++++ manifests/service/ping.pp | 13 +++ 11 files changed, 371 insertions(+), 383 deletions(-) create mode 100644 manifests/base.pp create mode 100644 manifests/centos.pp create mode 100644 manifests/command.pp delete mode 100644 manifests/defines.pp create mode 100644 manifests/extra_host.pp create mode 100644 manifests/host.pp create mode 100644 manifests/plugin.pp create mode 100644 manifests/service.pp create mode 100644 manifests/service/http.pp create mode 100644 manifests/service/ping.pp diff --git a/manifests/base.pp b/manifests/base.pp new file mode 100644 index 0000000..056d90f --- /dev/null +++ b/manifests/base.pp @@ -0,0 +1,131 @@ +class nagios::base { + + # needs apache to work + include apache + + package { nagios: + ensure => present, + } + + service{nagios: + ensure => running, + enable => true, + #hasstatus => true, #fixme! + require => Package[nagios], + } + + # manage nagios cfg files + file {nagios_cfg_dir: + path => "/etc/nagios/", + source => "puppet://$server/common/empty", + ensure => directory, + recurse => true, + purge => true, + notify => Service[nagios], + mode => 0755, owner => root, group => root; + } + # this file should contain all the nagios_puppet-paths: + file {nagios_main_cfg: + path => "/etc/nagios/nagios.cfg", + source => [ "puppet://$server/files/nagios/configs/${fqdn}/nagios.cfg", + "puppet://$server/files/nagios/configs/${operatingsystem}/nagios.cfg", + "puppet://$server/files/nagios/configs/nagios.cfg", + "puppet://$server/nagios/configs/${operatingsystem}/nagios.cfg", + "puppet://$server/nagios/configs/nagios.cfg" ], + notify => Service[nagios], + mode => 0644, owner => root, group => root; + } + file { nagios_cgi_cfg: + path => "/etc/nagios/cgi.cfg", + source => [ "puppet://$server/files/nagios/configs/${fqdn}/cgi.cfg", + "puppet://$server/files/nagios/configs/${operatingsystem}/cgi.cfg", + "puppet://$server/files/nagios/configs/cgi.cfg", + "puppet://$server/nagios/configs/${operatingsystem}/cgi.cfg", + "puppet://$server/nagios/configs/cgi.cfg" ], + owner => 'root', + group => 0, + mode => '0644', + notify => Service['apache'], + } + + file {"/etc/nagios/htpasswd.users": + source => [ + "puppet://$server/files/nagios/htpasswd.users", + "puppet://$server/nagios/htpasswd.users" ], + mode => 0640, owner => root, group => apache; + } + file{[ "/etc/nagios/nagios_command.cfg", + "/etc/nagios/nagios_contact.cfg", + "/etc/nagios/nagios_contactgroup.cfg", + "/etc/nagios/nagios_host.cfg", + "/etc/nagios/nagios_hostextinfo.cfg", + "/etc/nagios/nagios_hostgroup.cfg", + "/etc/nagios/nagios_hostgroupescalation.cfg", + "/etc/nagios/nagios_service.cfg", + "/etc/nagios/nagios_servicedependency.cfg", + "/etc/nagios/nagios_serviceescalation.cfg", + "/etc/nagios/nagios_serviceextinfo.cfg", + "/etc/nagios/nagios_timeperdiod.cfg" ]: + ensure => file, + replace => false, + notify => Service[nagios], + mode => 0644, owner => root, group => 0; + } + + nagios::plugin{'check_jabber_login': } + + nagios::command{ + ssh_port: + command_line => '$USER1$/check_ssh -p $ARG1$ $HOSTADDRESS$'; + # from apache2.pp + http_port: + command_line => '$USER1$/check_http -p $ARG1$ -H $HOSTADDRESS$ -I $HOSTADDRESS$'; + # from bind.pp + check_dig2: + command_line => '$USER1$/check_dig -H $HOSTADDRESS$ -l $ARG1$ --record_type=$ARG2$'; + check_ntp: + command_line => '$USER1$/check_ntp -H $HOSTADDRESS$ -w 0.5 -c 1'; + 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$'; + check_https_url: + command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$'; + check_https_url_regex: + command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -e $ARG3$'; + check_https: + command_line => '$USER1$/check_http -S -H $HOSTADDRESS$'; + check_silc: + command_line => '$USER1$/check_tcp -p 706 -H $ARG1$'; + check_jabber: + command_line => '$USER1$/check_jabber -H $ARG1$'; + check_jabber_login: + command_line => '$USER1$/check_jabber_login $ARG1$ $ARG2$', + require => Nagios::Plugin['check_jabber_login']; + } + + Nagios_command <<||>> + Nagios_contact <<||>> + Nagios_contactgroup <<||>> + Nagios_host <<||>> + Nagios_hostextinfo <<||>> + Nagios_hostgroup <<||>> + Nagios_hostgroupescalation <<||>> + Nagios_service <<||>> + Nagios_servicedependency <<||>> + Nagios_serviceescalation <<||>> + Nagios_serviceextinfo <<||>> + Nagios_timeperiod <<||>> + + if $use_munin { + include munin::plugins::nagios + } + + if $nagios_allow_external_cmd { + file{'/var/spool/nagios/cmd': + ensure => 'directory', + require => Package['nagios'], + owner => apache, group => nagios, mode => 2660; + } + } +} diff --git a/manifests/centos.pp b/manifests/centos.pp new file mode 100644 index 0000000..a5a96fb --- /dev/null +++ b/manifests/centos.pp @@ -0,0 +1,47 @@ +class nagios::centos inherits nagios::base { + package { [ 'nagios-plugins', 'nagios-plugins-smtp','nagios-plugins-http', 'nagios-plugins-ssh', 'nagios-plugins-udp', 'nagios-plugins-tcp', 'nagios-plugins-dig', 'nagios-plugins-nrpe', 'nagios-plugins-load', 'nagios-plugins-dns', 'nagios-plugins-ping', 'nagios-plugins-procs', 'nagios-plugins-users', 'nagios-plugins-ldap', 'nagios-plugins-disk', 'nagios-plugins-swap', 'nagios-plugins-nagios', 'nagios-plugins-perl', 'nagios-plugins-ntp', 'nagios-plugins-snmp' ]: + ensure => 'present', + notify => Service[nagios], + } + + Service[nagios]{ + hasstatus => true, + } + + # default cmd file from rpm + # don't forget it to add to the puppet paths + file { nagios_commands_cfg: + path => "/etc/nagios/commands.cfg", + source => [ "puppet://$server/files/nagios/configs/${fqdn}/commands.cfg", + "puppet://$server/files/nagios/configs/${operatingsystem}/commands.cfg", + "puppet://$server/nagios/configs/${operatingsystem}/commands.cfg" ], + owner => 'root', + group => 0, + mode => '0644', + notify => Service[nagios], + } + # default file from rpm + file { nagios_localhost_cfg: + path => "/etc/nagios/localhost.cfg", + source => [ "puppet://$server/files/nagios/configs/${fqdn}/localhost.cfg", + "puppet://$server/files/nagios/configs/${operatingsystem}/localhost.cfg", + "puppet://$server/nagios/configs/${operatingsystem}/localhost.cfg" ], + owner => 'root', + group => 0, + mode => '0644', + notify => Service[nagios], + } + file{"/etc/nagios/private/": + source => "puppet://$server/common/empty", + ensure => directory, + purge => true, + recurse => true, + notify => Service[nagios], + mode => '0750', owner => root, group => nagios; + } + file{"/etc/nagios/private/resource.cfg": + source => "puppet://$server/nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}", + notify => Service[nagios], + owner => root, group => nagios, mode => '0640'; + } +} diff --git a/manifests/command.pp b/manifests/command.pp new file mode 100644 index 0000000..066189c --- /dev/null +++ b/manifests/command.pp @@ -0,0 +1,11 @@ +# just a wrapper to make the notify more easy +define nagios::command( + $ensure = present, + $command_line +){ + nagios_command{$name: + ensure => $ensure, + command_line => $command_line, + notify => Service[nagios], + } +} diff --git a/manifests/defines.pp b/manifests/defines.pp deleted file mode 100644 index 154d52d..0000000 --- a/manifests/defines.pp +++ /dev/null @@ -1,200 +0,0 @@ -# manifests/defines.pp - -define nagios::host( - $ensure = present, - $ip = $fqdn, - $nagios_alias = $hostname, - $check_command = 'check-host-alive', - $max_check_attempts = 4, - $notification_interval = 120, - $notification_period = '24x7', - $notification_options = 'd,r', - $use = 'generic-host', - $nagios_contact_groups_in = $nagios_contact_groups, - $parents = 'localhost' ) -{ - $real_nagios_contact_groups = $nagios_contact_groups_in ? { - '' => 'admins', - default => $nagios_contact_groups_in - } - $real_nagios_parents = $parents ? { - '' => 'localhost', - default => $parents - } - - @@nagios_host { $name: - ensure => $ensure, - address => $ip, - alias => $nagios_alias, - check_command => $check_command, - max_check_attempts => $max_check_attempts, - notification_interval => $notification_interval, - notification_period => $notification_period, - notification_options => $notification_options, - parents => $real_nagios_parents, - contact_groups => $real_nagios_contact_groups, - use => $use, - notify => Service[nagios], - } -} - -# this will define a host which isn't managed by puppet. -# a ping serivce is automatically added -define nagios::extra_host( - $ensure = present, - $ip, - $nagios_alias, - $use = 'generic-host', - $parents = 'localhost' -) { - nagios::host{$name: - ensure => $ensure, - ip => $ip, - nagios_alias => $nagios_alias, - use => $use, - parents => $parents - } - - nagios::service { "check_ping_${name}": - ensure => $ensure, - host_name => $name, - check_command => 'check_ping!100.0,20%!500.0,60%', - host_name => $name, - service_description => "check_ping_${nagios_alias}", - } -} - -# just a wrapper to make the notify more easy -define nagios::command( - $ensure = present, - $command_line -){ - nagios_command{$name: - ensure => $ensure, - command_line => $command_line, - notify => Service[nagios], - } -} - -define nagios::service( - $ensure = present, - $check_command, - $host_name = $fqdn, - $use = 'generic-service', - $notification_period = "24x7", - $max_check_attempts = 4, - $retry_check_interval = 1, - $notification_interval = 960, - $normal_check_interval = 5, - $check_period = "24x7", - $nagios_contact_groups_in = $nagios_contact_groups, - $service_description = 'absent') -{ - - # this ensures nagios internal check, that every - # service has it's host - # temporary disabled. - # include nagios::target::host - - $real_nagios_contact_groups = $nagios_contact_groups_in ? { - '' => 'admins', - default => $nagios_contact_groups_in - } - @@nagios_service {$name: - ensure => $ensure, - check_command => $check_command, - use => $use, - host_name => $host_name, - notification_period => $notification_period, - max_check_attempts => $max_check_attempts, - retry_check_interval => $retry_check_interval, - notification_interval => $notification_interval, - normal_check_interval => $normal_check_interval, - contact_groups => $real_nagios_contact_groups, - check_period => $check_period, - notify => Service[nagios], - } - case $service_description { - 'absent': { - Nagios_service[$name]{ - service_description => $name, - } - } - default: { - Nagios_service[$name]{ - service_description => $service_description, - } - } - } -} - -define nagios::service::ping( - $ensure = present -){ - $real_nagios_ping_rate = $nagios_ping_rate ? { - '' => '!100.0,20%!500.0,60%', - default => $nagios_ping_rate - } - - nagios::service{ "check_ping_${hostname}": - ensure => $ensure, - check_command => "check_ping${real_nagios_ping_rate}", - } -} - -# ssl_mode: -# - false: only check http -# - true: check http and https -# - force: http is permanent redirect to https -# - only: check only https -define nagios::service::http( - $ensure = present, - $check_domain = 'absent', - $check_url = '/', - $check_code = 'OK', - $ssl_mode = false -){ - $real_check_domain = $check_domain ? { - 'absent' => $name, - default => $check_domain - } - case $ssl_mode { - 'force',true,'only': { - nagios::service{"https_${name}_${check_code}_${hostname}": - ensure => $ensure, - check_command => "check_https_url_regex!${real_check_domain}!${check_url}!'${check_code}'", - } - case $ssl_mode { - 'force': { - nagios::service{"httprd_${name}_${hostname}": - ensure => $ensure, - check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'301'", - } - } - } - } - } - case $ssl_mode { - false,true: { - nagios::service{"http_${name}_${check_code}_${hostname}": - ensure => $ensure, - check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'${check_code}'", - } - } - } -} - -define nagios::plugin( - $ensure = present -){ - file{$name: - path => $hardwaremodel ? { - 'x86_64' => "/usr/lib64/nagios/plugins/$name", - default => "/usr/lib/nagios/plugins/$name", - }, - ensure => $ensure, - source => "puppet://$server/nagios/plugins/$name", - require => Package['nagios-plugins'], - owner => root, group => 0, mode => 0755; - } -} diff --git a/manifests/extra_host.pp b/manifests/extra_host.pp new file mode 100644 index 0000000..7e37d3e --- /dev/null +++ b/manifests/extra_host.pp @@ -0,0 +1,25 @@ +# this will define a host which isn't managed by puppet. +# a ping serivce is automatically added +define nagios::extra_host( + $ensure = present, + $ip, + $nagios_alias, + $use = 'generic-host', + $parents = 'localhost' +) { + nagios::host{$name: + ensure => $ensure, + ip => $ip, + nagios_alias => $nagios_alias, + use => $use, + parents => $parents + } + + nagios::service { "check_ping_${name}": + ensure => $ensure, + host_name => $name, + check_command => 'check_ping!100.0,20%!500.0,60%', + host_name => $name, + service_description => "check_ping_${nagios_alias}", + } +} diff --git a/manifests/host.pp b/manifests/host.pp new file mode 100644 index 0000000..8814738 --- /dev/null +++ b/manifests/host.pp @@ -0,0 +1,37 @@ +define nagios::host( + $ensure = present, + $ip = $fqdn, + $nagios_alias = $hostname, + $check_command = 'check-host-alive', + $max_check_attempts = 4, + $notification_interval = 120, + $notification_period = '24x7', + $notification_options = 'd,r', + $use = 'generic-host', + $nagios_contact_groups_in = $nagios_contact_groups, + $parents = 'localhost' ) +{ + $real_nagios_contact_groups = $nagios_contact_groups_in ? { + '' => 'admins', + default => $nagios_contact_groups_in + } + $real_nagios_parents = $parents ? { + '' => 'localhost', + default => $parents + } + + @@nagios_host { $name: + ensure => $ensure, + address => $ip, + alias => $nagios_alias, + check_command => $check_command, + max_check_attempts => $max_check_attempts, + notification_interval => $notification_interval, + notification_period => $notification_period, + notification_options => $notification_options, + parents => $real_nagios_parents, + contact_groups => $real_nagios_contact_groups, + use => $use, + notify => Service[nagios], + } +} diff --git a/manifests/init.pp b/manifests/init.pp index 9557d2e..6eca55f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,192 +14,9 @@ # the Free Software Foundation. # -import 'defines.pp' - class nagios { case $operatingsystem { centos: { include nagios::centos } default: { fail("No such operatingsystem: $operatingsystem yet defined") } } } - -class nagios::base { - - # needs apache to work - include apache - - package { nagios: - ensure => present, - } - - service{nagios: - ensure => running, - enable => true, - #hasstatus => true, #fixme! - require => Package[nagios], - } - - # manage nagios cfg files - file {nagios_cfg_dir: - path => "/etc/nagios/", - source => "puppet://$server/common/empty", - ensure => directory, - recurse => true, - purge => true, - notify => Service[nagios], - mode => 0755, owner => root, group => root; - } - # this file should contain all the nagios_puppet-paths: - file {nagios_main_cfg: - path => "/etc/nagios/nagios.cfg", - source => [ "puppet://$server/files/nagios/configs/${fqdn}/nagios.cfg", - "puppet://$server/files/nagios/configs/${operatingsystem}/nagios.cfg", - "puppet://$server/files/nagios/configs/nagios.cfg", - "puppet://$server/nagios/configs/${operatingsystem}/nagios.cfg", - "puppet://$server/nagios/configs/nagios.cfg" ], - notify => Service[nagios], - mode => 0644, owner => root, group => root; - } - file { nagios_cgi_cfg: - path => "/etc/nagios/cgi.cfg", - source => [ "puppet://$server/files/nagios/configs/${fqdn}/cgi.cfg", - "puppet://$server/files/nagios/configs/${operatingsystem}/cgi.cfg", - "puppet://$server/files/nagios/configs/cgi.cfg", - "puppet://$server/nagios/configs/${operatingsystem}/cgi.cfg", - "puppet://$server/nagios/configs/cgi.cfg" ], - owner => 'root', - group => 0, - mode => '0644', - notify => Service['apache'], - } - - file {"/etc/nagios/htpasswd.users": - source => [ - "puppet://$server/files/nagios/htpasswd.users", - "puppet://$server/nagios/htpasswd.users" ], - mode => 0640, owner => root, group => apache; - } - - file{[ "/etc/nagios/nagios_command.cfg", - "/etc/nagios/nagios_contact.cfg", - "/etc/nagios/nagios_contactgroup.cfg", - "/etc/nagios/nagios_host.cfg", - "/etc/nagios/nagios_hostextinfo.cfg", - "/etc/nagios/nagios_hostgroup.cfg", - "/etc/nagios/nagios_hostgroupescalation.cfg", - "/etc/nagios/nagios_service.cfg", - "/etc/nagios/nagios_servicedependency.cfg", - "/etc/nagios/nagios_serviceescalation.cfg", - "/etc/nagios/nagios_serviceextinfo.cfg", - "/etc/nagios/nagios_timeperdiod.cfg" ]: - ensure => file, - replace => false, - notify => Service[nagios], - mode => 0644, owner => root, group => 0; - } - - nagios::plugin{'check_jabber_login': } - - nagios::command{ - ssh_port: - command_line => '$USER1$/check_ssh -p $ARG1$ $HOSTADDRESS$'; - # from apache2.pp - http_port: - command_line => '$USER1$/check_http -p $ARG1$ -H $HOSTADDRESS$ -I $HOSTADDRESS$'; - # from bind.pp - check_dig2: - command_line => '$USER1$/check_dig -H $HOSTADDRESS$ -l $ARG1$ --record_type=$ARG2$'; - check_ntp: - command_line => '$USER1$/check_ntp -H $HOSTADDRESS$ -w 0.5 -c 1'; - 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$'; - check_https_url: - command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$'; - check_https_url_regex: - command_line => '$USER1$/check_http --ssl -H $ARG1$ -u $ARG2$ -e $ARG3$'; - check_https: - command_line => '$USER1$/check_http -S -H $HOSTADDRESS$'; - check_silc: - command_line => '$USER1$/check_tcp -p 706 -H $ARG1$'; - check_jabber: - command_line => '$USER1$/check_jabber -H $ARG1$'; - check_jabber_login: - command_line => '$USER1$/check_jabber_login $ARG1$ $ARG2$', - require => Nagios::Plugin['check_jabber_login']; - } - - Nagios_command <<||>> - Nagios_contact <<||>> - Nagios_contactgroup <<||>> - Nagios_host <<||>> - Nagios_hostextinfo <<||>> - Nagios_hostgroup <<||>> - Nagios_hostgroupescalation <<||>> - Nagios_service <<||>> - Nagios_servicedependency <<||>> - Nagios_serviceescalation <<||>> - Nagios_serviceextinfo <<||>> - Nagios_timeperiod <<||>> - - if $use_munin { - include munin::plugins::nagios - } - - if $nagios_allow_external_cmd { - file{'/var/spool/nagios/cmd': - ensure => 'directory', - require => Package['nagios'], - owner => apache, group => nagios, mode => 2660; - } - } -} # end nagios::base - -class nagios::centos inherits nagios::base { - package { [ 'nagios-plugins', 'nagios-plugins-smtp','nagios-plugins-http', 'nagios-plugins-ssh', 'nagios-plugins-udp', 'nagios-plugins-tcp', 'nagios-plugins-dig', 'nagios-plugins-nrpe', 'nagios-plugins-load', 'nagios-plugins-dns', 'nagios-plugins-ping', 'nagios-plugins-procs', 'nagios-plugins-users', 'nagios-plugins-ldap', 'nagios-plugins-disk', 'nagios-plugins-swap', 'nagios-plugins-nagios', 'nagios-plugins-perl', 'nagios-plugins-ntp', 'nagios-plugins-snmp' ]: - ensure => 'present', - notify => Service[nagios], - } - - Service[nagios]{ - hasstatus => true, - } - - # default cmd file from rpm - # don't forget it to add to the puppet paths - file { nagios_commands_cfg: - path => "/etc/nagios/commands.cfg", - source => [ "puppet://$server/files/nagios/configs/${fqdn}/commands.cfg", - "puppet://$server/files/nagios/configs/${operatingsystem}/commands.cfg", - "puppet://$server/nagios/configs/${operatingsystem}/commands.cfg" ], - owner => 'root', - group => 0, - mode => '0644', - notify => Service[nagios], - } - # default file from rpm - file { nagios_localhost_cfg: - path => "/etc/nagios/localhost.cfg", - source => [ "puppet://$server/files/nagios/configs/${fqdn}/localhost.cfg", - "puppet://$server/files/nagios/configs/${operatingsystem}/localhost.cfg", - "puppet://$server/nagios/configs/${operatingsystem}/localhost.cfg" ], - owner => 'root', - group => 0, - mode => '0644', - notify => Service[nagios], - } - file{"/etc/nagios/private/": - source => "puppet://$server/common/empty", - ensure => directory, - purge => true, - recurse => true, - notify => Service[nagios], - mode => '0750', owner => root, group => nagios; - } - file{"/etc/nagios/private/resource.cfg": - source => "puppet://$server/nagios/configs/${operatingsystem}/private/resource.cfg.${architecture}", - notify => Service[nagios], - owner => root, group => nagios, mode => '0640'; - } -} diff --git a/manifests/plugin.pp b/manifests/plugin.pp new file mode 100644 index 0000000..eebc589 --- /dev/null +++ b/manifests/plugin.pp @@ -0,0 +1,14 @@ +define nagios::plugin( + $ensure = present +){ + file{$name: + path => $hardwaremodel ? { + 'x86_64' => "/usr/lib64/nagios/plugins/$name", + default => "/usr/lib/nagios/plugins/$name", + }, + ensure => $ensure, + source => "puppet://$server/nagios/plugins/$name", + require => Package['nagios-plugins'], + owner => root, group => 0, mode => 0755; + } +} diff --git a/manifests/service.pp b/manifests/service.pp new file mode 100644 index 0000000..42d9a4d --- /dev/null +++ b/manifests/service.pp @@ -0,0 +1,52 @@ +define nagios::service( + $ensure = present, + $check_command, + $host_name = $fqdn, + $use = 'generic-service', + $notification_period = "24x7", + $max_check_attempts = 4, + $retry_check_interval = 1, + $notification_interval = 960, + $normal_check_interval = 5, + $check_period = "24x7", + $nagios_contact_groups_in = $nagios_contact_groups, + $service_description = 'absent') +{ + + # this ensures nagios internal check, that every + # service has it's host + # temporary disabled. + # include nagios::target::host + + $real_nagios_contact_groups = $nagios_contact_groups_in ? { + '' => 'admins', + default => $nagios_contact_groups_in + } + @@nagios_service {$name: + ensure => $ensure, + check_command => $check_command, + use => $use, + host_name => $host_name, + notification_period => $notification_period, + max_check_attempts => $max_check_attempts, + retry_check_interval => $retry_check_interval, + notification_interval => $notification_interval, + normal_check_interval => $normal_check_interval, + contact_groups => $real_nagios_contact_groups, + check_period => $check_period, + notify => Service[nagios], + } + case $service_description { + 'absent': { + Nagios_service[$name]{ + service_description => $name, + } + } + default: { + Nagios_service[$name]{ + service_description => $service_description, + } + } + } +} + diff --git a/manifests/service/http.pp b/manifests/service/http.pp new file mode 100644 index 0000000..5c6cda1 --- /dev/null +++ b/manifests/service/http.pp @@ -0,0 +1,41 @@ +# ssl_mode: +# - false: only check http +# - true: check http and https +# - force: http is permanent redirect to https +# - only: check only https +define nagios::service::http( + $ensure = present, + $check_domain = 'absent', + $check_url = '/', + $check_code = 'OK', + $ssl_mode = false +){ + $real_check_domain = $check_domain ? { + 'absent' => $name, + default => $check_domain + } + case $ssl_mode { + 'force',true,'only': { + nagios::service{"https_${name}_${check_code}_${hostname}": + ensure => $ensure, + check_command => "check_https_url_regex!${real_check_domain}!${check_url}!'${check_code}'", + } + case $ssl_mode { + 'force': { + nagios::service{"httprd_${name}_${hostname}": + ensure => $ensure, + check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'301'", + } + } + } + } + } + case $ssl_mode { + false,true: { + nagios::service{"http_${name}_${check_code}_${hostname}": + ensure => $ensure, + check_command => "check_http_url_regex!${real_check_domain}!${check_url}!'${check_code}'", + } + } + } +} diff --git a/manifests/service/ping.pp b/manifests/service/ping.pp new file mode 100644 index 0000000..63a5400 --- /dev/null +++ b/manifests/service/ping.pp @@ -0,0 +1,13 @@ +define nagios::service::ping( + $ensure = present +){ + $real_nagios_ping_rate = $nagios_ping_rate ? { + '' => '!100.0,20%!500.0,60%', + default => $nagios_ping_rate + } + + nagios::service{ "check_ping_${hostname}": + ensure => $ensure, + check_command => "check_ping${real_nagios_ping_rate}", + } +} -- cgit v1.2.3