Defined Type: nagios::service

Defined in:
manifests/service.pp

Overview

Define: nagios::service

Wrap around the original nagios_service

  • To be able to export with the correct tag automatically

  • To be able to use defaults overridden or from facts

Parameters:

  • check_command (Any)
  • ensure (Any) (defaults to: undef)
  • server (Any) (defaults to: $nagios::client::server)
  • host_name (Any) (defaults to: $nagios::client::host_name)
  • service_description (Any) (defaults to: $name)
  • servicegroups (Any) (defaults to: undef)
  • check_interval (Any) (defaults to: $nagios::client::service_check_interval)
  • check_period (Any) (defaults to: $nagios::client::service_check_period)
  • contact_groups (Any) (defaults to: $nagios::client::service_contact_groups)
  • first_notification_delay (Any) (defaults to: $nagios::client::service_first_notification_delay)
  • max_check_attempts (Any) (defaults to: $nagios::client::service_max_check_attempts)
  • notification_period (Any) (defaults to: $nagios::client::service_notification_period)
  • use (Any) (defaults to: $nagios::client::service_use)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'manifests/service.pp', line 7

define nagios::service (
  $check_command,
  $ensure                   = undef,
  $server                   = $nagios::client::server,
  $host_name                = $nagios::client::host_name,
  $service_description      = $name,
  $servicegroups            = undef,
  $check_interval           = $nagios::client::service_check_interval,
  $check_period             = $nagios::client::service_check_period,
  $contact_groups           = $nagios::client::service_contact_groups,
  $first_notification_delay = $nagios::client::service_first_notification_delay,
  $max_check_attempts       = $nagios::client::service_max_check_attempts,
  $notification_period      = $nagios::client::service_notification_period,
  $use                      = $nagios::client::service_use,
) {

  # Work around being passed undefined variables resulting in ''
  $final_check_interval = $check_inteval ? {
    ''      => $nagios::client::service_check_interval,
    undef   => $nagios::client::service_check_interval,
    default => $check_interval,
  }
  $final_check_period = $check_period ? {
    ''      => $nagios::client::service_check_period,
    undef   => $nagios::client::service_check_period,
    default => $check_period,
  }
  $final_max_check_attempts = $max_check_attempts ? {
    ''      => $nagios::client::service_max_check_attempts,
    undef   => $nagios::client::service_max_check_attempts,
    default => $max_check_attempts,
  }
  $final_notification_period = $notification_period ? {
    ''      => $nagios::client::service_notification_period,
    undef   => $nagios::client::service_notification_period,
    default => $notification_period,
  }
  $final_use = $use ? {
    ''      => $nagios::client::service_use,
    undef   => $nagios::client::service_use,
    default => $use,
  }

  # Support an array of tags for multiple nagios servers
  $service_tag = regsubst($server,'^(.+)$','nagios-\1')
  @@nagios_service { $title:
    ensure                   => $ensure,
    host_name                => $host_name,
    check_command            => $check_command,
    service_description      => $service_description,
    servicegroups            => $servicegroups,
    check_interval           => $check_interval,
    check_period             => $final_check_period,
    contact_groups           => $contact_groups,
    first_notification_delay => $first_notification_delay,
    max_check_attempts       => $final_max_check_attempts,
    notification_period      => $final_notification_period,
    use                      => $final_use,
    tag                      => $service_tag,
  }

}