Defined Type: icinga::baseservices

Defined in:
manifests/baseservices.pp

Overview

Define icinga::baseservices

Use this to define Nagios basic service objects that will be used for to all nodes All local disks, memory, cpu, local users… It’s automatically loaded in icinga::target

This is an exported resource.

Parameters:

  • host_name (Any) (defaults to: $fqdn)
  • service_description (Any) (defaults to: '')
  • use (Any) (defaults to: 'generic-service')
  • template (Any) (defaults to: '')
  • ensure (Any) (defaults to: 'present')


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
# File 'manifests/baseservices.pp', line 10

define icinga::baseservices (
  $host_name           = $fqdn,
  $service_description = '',
  $use                 = 'generic-service',
  $template            = '',
  $ensure              = 'present'
  ) {

  include icinga::target

  $real_template = $template ? {
    ''      => $::osfamily ? {
      windows => 'icinga/baseserviceswin.erb',
      default => 'icinga/baseservices.erb',
    },
    default => $template,
  }

  case $::icinga_filemode {

    'concat': {
      if $ensure == 'present' {
        @@concat::fragment { "icinga-${host_name}-baseservices":
          target  => "${icinga::target::customconfigdir}/hosts/${host_name}.cfg",
          order   => 02,
          notify  => Service['icinga'],
          content => template( $real_template ),
          tag     => "icinga_check_${icinga::target::magic_tag}",
        }
      }
    }

    'pupmod-concat': {
      if $ensure == 'present' {
        @@concat_fragment { "icinga-${host_name}+100_baseservices.tmp":
          content => template( $real_template ),
        }
      }
    }

    default: {
      @@file { "${icinga::target::customconfigdir}/services/${host_name}-00-baseservices.cfg":
        ensure  => $ensure,
        mode    => '0644',
        owner   => 'root',
        group   => 'root',
        notify  => Service['icinga'],
        content => template( $real_template ),
        tag     => "icinga_check_${icinga::target::magic_tag}",
      }
    }

  }

}