summaryrefslogtreecommitdiff
path: root/manifests/service.pp
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2010-05-05 23:22:10 +0200
committermh <mh@immerda.ch>2010-05-05 23:22:10 +0200
commit33b091b896fbb0b54ee9968c452ef2a8867893d8 (patch)
tree863c61e2de0c258c859527e14e86b47ffd8f0bb1 /manifests/service.pp
parent77f601607093b7fb22f3498574d0dedd2cbe01d9 (diff)
parent5d5ec8c28d0fe39359af8db159b14faeae397e1f (diff)
merged with lavamind
Diffstat (limited to 'manifests/service.pp')
-rw-r--r--manifests/service.pp97
1 files changed, 55 insertions, 42 deletions
diff --git a/manifests/service.pp b/manifests/service.pp
index bb9b187..3e732b7 100644
--- a/manifests/service.pp
+++ b/manifests/service.pp
@@ -1,56 +1,69 @@
-define nagios::service(
+define nagios::service (
$ensure = present,
- $check_command = absent,
$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')
+ $check_command,
+ $check_period = '',
+ $normal_check_interval = '',
+ $retry_check_interval = '',
+ $max_check_attempts = '',
+ $notification_interval = '',
+ $notification_period = '',
+ $notification_options = '',
+ $contact_groups = '',
+ $use = 'absent',
+ $service_description = 'absent' )
{
- if $ensure == present and $check_command == absent {
- fail("You have to define \$check_command if nagios::service shoudl be present!")
- }
+ # TODO: this resource should normally accept all nagios_host parameters
- # this ensures nagios internal check, that every
- # service has it's host
- # temporary disabled.
- # include nagios::target::host
+ $real_name = "${hostname}_${name}"
- $real_nagios_contact_groups = $nagios_contact_groups_in ? {
- '' => 'admins',
- default => $nagios_contact_groups_in
- }
- @@nagios_service {$name:
+ @@nagios_service { "${real_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,
- }
- }
+
+ if ($check_period != '') {
+ Nagios_service["${real_name}"] { check_period => $check_period }
+ }
+
+ if ($normal_check_interval != '') {
+ Nagios_service["${real_name}"] { normal_check_interval => $normal_check_interval }
+ }
+
+ if ($retry_check_interval != '') {
+ Nagios_service["${real_name}"] { retry_check_interval => $retry_check_interval }
+ }
+
+ if ($max_check_attempts != '') {
+ Nagios_service["${real_name}"] { max_check_attempts => $max_check_attempts }
+ }
+
+ if ($notification_interval != '') {
+ Nagios_service["${real_name}"] { notification_interval => $notification_interval }
+ }
+
+ if ($notification_period != '') {
+ Nagios_service["${real_name}"] { notification_period => $notification_period }
+ }
+
+ if ($notification_options != '') {
+ Nagios_service["${real_name}"] { notification_options => $notification_options }
}
+
+ if ($use == 'absent') {
+ Nagios_service["${real_name}"] { use => 'generic-service' }
+ } else {
+ Nagios_service["${real_name}"] { use => $use }
+ }
+
+ if ($service_description == 'absent') {
+ Nagios_service["${real_name}"] { service_description => $name }
+ } else {
+ Nagios_service["${real_name}"] { service_description => $service_description }
+ }
+
}