Defined Type: nagios::service::nsca

Defined in:
manifests/service/nsca.pp

Overview

Definition: nagios::service::nsca

Define a service resource on the local nagios instance and export the same resource to a remote nagios nsca server.

Example:

nagios::service::nsca { 'check process':
  ensure                => present,
  command_line          => '/usr/lib/nagios/plugins/check_procs',
  normal_check_interval => 5,
  package               => 'nagios-plugins-procs',
  export_for            => 'nagios-nsca.example.com',
}

Parameters:

  • export_for (Any)
  • command_line (Any)
  • codename (Any)
  • ensure (Any) (defaults to: present)
  • service_description (Any) (defaults to: false)
  • host_name (Any) (defaults to: false)
  • contact_groups (Any) (defaults to: undef)
  • service_groups (Any) (defaults to: undef)
  • normal_check_interval (Any) (defaults to: undef)
  • retry_check_interval (Any) (defaults to: undef)
  • max_check_attempts (Any) (defaults to: undef)
  • use_active (Any) (defaults to: 'generic-service-active')
  • use_passive (Any) (defaults to: 'generic-service-passive')
  • package (Any) (defaults to: false)


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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'manifests/service/nsca.pp', line 16

define nagios::service::nsca (
  $export_for,
  $command_line,
  $codename,
  $ensure                = present,
  $service_description   = false,
  $host_name             = false,
  $contact_groups        = undef,
  $service_groups        = undef,
  $normal_check_interval = undef,
  $retry_check_interval  = undef,
  $max_check_attempts    = undef,
  $use_active            = 'generic-service-active',
  $use_passive           = 'generic-service-passive',
  $package               = false,
  ) {

  include ::nagios::params

  $fname = regsubst($name, '\W', '_', 'G')

  $nagios_host_name = $host_name ? {
    false    => $::hostname,
    default  => $host_name,
  }

  nagios::service::local { $name:
    ensure                => $ensure,
    use                   => $use_active,
    command_line          => $command_line,
    codename              => $codename,
    host_name             => $nagios_host_name,
    contact_groups        => $contact_groups,
    service_groups        => $service_groups,
    normal_check_interval => $normal_check_interval,
    retry_check_interval  => $retry_check_interval,
    max_check_attempts    => $max_check_attempts,
    service_description   => $service_description,
  }

  @@nagios_service { "@@${name} on ${::hostname}":
    ensure                => $ensure,
    use                   => $use_passive,
    host_name             => $nagios_host_name,
    tag                   => $export_for,
    target                => "${nagios::params::resourcedir}/collected-service-${fname}_on_${::hostname}.cfg",
    notify                => Exec['nagios-restart'],
    contact_groups        => $contact_groups,
    servicegroups         => $service_groups,
    normal_check_interval => $normal_check_interval,
    retry_check_interval  => $retry_check_interval,
    max_check_attempts    => $max_check_attempts,
    service_description   => $service_description,
  }

  @@file { "${nagios::params::resourcedir}/collected-service-${fname}_on_${::hostname}.cfg":
    ensure => $ensure,
    owner  => 'root',
    mode   => '0644',
    tag    => $export_for,
  }

  if $package {
    if !defined(Package[$package]) {
      package { $package:
        ensure => present,
      }
    }
  }
}