Puppet Class: nagios::nsca::client

Defined in:
manifests/nsca/client.pp

Overview

Class: nagios::nsca::client

Installs the nsca client and configures nagios to send status information to the central nsca server.

Example usage:

include nagios
include nagios::nsca::client

Parameters:

  • nsca_server (Any)


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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'manifests/nsca/client.pp', line 11

class nagios::nsca::client(
  $nsca_server,
) {

  include ::nagios::params

  if !defined (Package['nsca']) {
    package {'nsca':
      ensure => installed;
    }
  }

  if $::osfamily == 'RedHat' {
    if !defined (Package['nsca-client']) {
      package { 'nsca-client': ensure => installed }
    }
  }

  # variables used in ERB template
  $nsca_cfg = "${nagios::params::rootdir}/send_nsca.cfg"

  file { "${nagios::params::rootdir}/send_nsca.cfg":
    ensure  => file,
    owner   => root,
    group   => nagios,
    mode    => '0640',
    content => template('nagios/send_nsca.cfg.erb'),
    require => [Package['nsca'], Package['nagios']],
    notify  => Service['nagios'],
  }

  file {'/usr/local/bin/submit_ocsp':
    ensure  => file,
    owner   => root,
    group   => root,
    mode    => '0755',
    content => template('nagios/submit_ocsp.erb'),
    require => File["${nagios::params::rootdir}/send_nsca.cfg"],
  }

  file {'/usr/local/bin/submit_ochp':
    ensure  => file,
    owner   => root,
    group   => root,
    mode    => '0755',
    content => template('nagios/submit_ochp.erb'),
    require => File["${nagios::params::rootdir}/send_nsca.cfg"],
  }

  file { "${nagios::params::resourcedir}/command-submit_ocsp.cfg":
    ensure => file,
    owner  => 'root',
    mode   => '0644',
  }

  nagios_command {'submit_ocsp':
    ensure       => present,
    command_line => '/usr/local/bin/submit_ocsp $HOSTNAME$ \'$SERVICEDESC$\' $SERVICESTATEID$ \'$SERVICEOUTPUT$\'',
    target       => "${nagios::params::resourcedir}/command-submit_ocsp.cfg",
    notify       => Exec['nagios-restart'],
    require      => File["${nagios::params::resourcedir}/command-submit_ocsp.cfg"],
  }

  file { "${nagios::params::resourcedir}/command-submit_ochp.cfg":
    ensure => file,
    owner  => 'root',
    mode   => '0644',
  }

  nagios_command {'submit_ochp':
    ensure       => present,
    command_line => '/usr/local/bin/submit_ochp $HOSTNAME$ $HOSTSTATE$ \'$HOSTOUTPUT$\'',
    target       => "${nagios::params::resourcedir}/command-submit_ochp.cfg",
    notify       => Exec['nagios-restart'],
    require      => File["${nagios::params::resourcedir}/command-submit_ochp.cfg"],
  }

  concat::fragment {'submit_ocsp':
    target  => $nagios::params::conffile,
    content => "ocsp_command=submit_ocsp\n",
  }

  concat::fragment {'submit_ochp':
    target  => $nagios::params::conffile,
    content => "ochp_command=submit_ochp\n",
  }

  #TODO: remove this resource in a while
  file { '/etc/send_nsca.cfg': ensure => absent }

}