diff options
author | mh <mh@immerda.ch> | 2008-11-07 20:07:18 +0000 |
---|---|---|
committer | mh <mh@immerda.ch> | 2008-11-07 20:07:18 +0000 |
commit | e031bdc42d97a0cfd9b1ed054f99d15a452f53dd (patch) | |
tree | de105a4af27aace051e3db105262fac344b637ac | |
parent | 2ea2b55a0bb33617dab68e004dfea79ec6202d91 (diff) |
removed modules dir - we don't need it
factored out classes and defines in their own files
-rw-r--r-- | files/empty/.ignore | 1 | ||||
-rw-r--r-- | manifests/defines.pp | 122 | ||||
-rw-r--r-- | manifests/init.pp | 141 | ||||
-rw-r--r-- | manifests/service/ntp.pp | 9 | ||||
-rw-r--r-- | manifests/target.pp | 6 | ||||
-rw-r--r-- | manifests/target/host.pp | 6 |
6 files changed, 144 insertions, 141 deletions
diff --git a/files/empty/.ignore b/files/empty/.ignore deleted file mode 100644 index 89cb1fe..0000000 --- a/files/empty/.ignore +++ /dev/null @@ -1 +0,0 @@ -# file needed for git - don't remove it diff --git a/manifests/defines.pp b/manifests/defines.pp new file mode 100644 index 0000000..a41dd86 --- /dev/null +++ b/manifests/defines.pp @@ -0,0 +1,122 @@ +# manifests/defines.pp + +define nagios::host( + $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 => present, + 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($ip, $nagios_alias, $use = 'generic-host', $parents = 'localhost' ) { + nagios::host{$name: + ip => $ip, + nagios_alias => $nagios_alias, + use => $use, + parents => $parents + } + + nagios::service { "check_ping_${name}": + 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( $command_line ){ + nagios_command{$name: + command_line => $command_line, + notify => Service[nagios], + } +} + +define nagios::service( + $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 = ''){ + + # 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: + 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], + } + # if no service_description is set it is a namevar + case $service_description { + '': {} + default: { + Nagios_service[$name]{ + service_description => $service_description, + } + } + } +} + +define nagios::service::ping(){ + $real_nagios_ping_rate = $nagios_ping_rate ? { + '' => '!100.0,20%!500.0,60%', + default => $nagios_ping_rate + } + + nagios::service{ "check_ping_${hostname}": + check_command => "check_ping${real_nagios_ping_rate}", + } +} + diff --git a/manifests/init.pp b/manifests/init.pp index adf943b..702e875 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -14,9 +14,7 @@ # the Free Software Foundation. # -# the directory containing all nagios configs: -$nagios_cfgdir = '/var/lib/puppet/modules/nagios' -modules_dir{ nagios: } +import 'defines.pp' class nagios { case $operatingsystem { @@ -178,140 +176,3 @@ class nagios::centos inherits nagios::base { owner => root, group => nagios, mode => '0640'; } } - -class nagios::target { - include nagios::target::host - nagios::service::ping{$fqdn:} -} - -class nagios::target::host { - nagios::host { $fqdn: parents => $nagios_parent } -} - -# defines -define nagios::host( - $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 => present, - 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($ip, $nagios_alias, $use = 'generic-host', $parents = 'localhost' ) { - nagios::host{$name: - ip => $ip, - nagios_alias => $nagios_alias, - use => $use, - parents => $parents - } - - nagios::service { "check_ping_${name}": - 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( $command_line ){ - nagios_command{$name: - command_line => $command_line, - notify => Service[nagios], - } -} - -define nagios::service( - $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 = ''){ - - # 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: - 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], - } - # if no service_description is set it is a namevar - case $service_description { - '': {} - default: { - Nagios_service[$name]{ - service_description => $service_description, - } - } - } -} - -define nagios::service::ping(){ - $real_nagios_ping_rate = $nagios_ping_rate ? { - '' => '!100.0,20%!500.0,60%', - default => $nagios_ping_rate - } - - nagios::service{ "check_ping_${hostname}": - check_command => "check_ping${real_nagios_ping_rate}", - } -} - -class nagios::service::ntp { - nagios::service{ "check_ntp_${hostname}": - check_command => "check_ntp", - host_name => $fqdn, - } -} diff --git a/manifests/service/ntp.pp b/manifests/service/ntp.pp new file mode 100644 index 0000000..ad82be3 --- /dev/null +++ b/manifests/service/ntp.pp @@ -0,0 +1,9 @@ +# manifests/service/ntp.pp + +class nagios::service::ntp { + nagios::service{ "check_ntp_${hostname}": + check_command => "check_ntp", + host_name => $fqdn, + } +} + diff --git a/manifests/target.pp b/manifests/target.pp new file mode 100644 index 0000000..07aae93 --- /dev/null +++ b/manifests/target.pp @@ -0,0 +1,6 @@ +# manifests/target.pp + +class nagios::target { + include nagios::target::host + nagios::service::ping{$fqdn:} +} diff --git a/manifests/target/host.pp b/manifests/target/host.pp new file mode 100644 index 0000000..8ba4e77 --- /dev/null +++ b/manifests/target/host.pp @@ -0,0 +1,6 @@ +# manifests/target/host.pp + +class nagios::target::host { + nagios::host { $fqdn: parents => $nagios_parent } +} + |