Defined Type: nagios::host

Defined in:
manifests/host.pp

Overview

Define: nagios::host

Wrap around the original nagios_host :

  • To be able to export with the default tag

  • To be able to use defaults set by the module

Note: the original nagios_host “alias” parameter is named “host_alias” here since otherwise it’s interpreted as the puppet “alias” metaparameter.

Parameters:

  • server (Any) (defaults to: $nagios::client::server)
  • address (Any) (defaults to: $nagios::client::host_address)
  • host_alias (Any) (defaults to: $nagios::client::host_alias)
  • check_period (Any) (defaults to: $nagios::client::host_check_period)
  • check_command (Any) (defaults to: $nagios::client::host_check_command)
  • contact_groups (Any) (defaults to: $nagios::client::host_contact_groups)
  • hostgroups (Any) (defaults to: $nagios::client::host_hostgroups)
  • notes (Any) (defaults to: $nagios::client::host_notes)
  • notes_url (Any) (defaults to: $nagios::client::host_notes_url)
  • notification_period (Any) (defaults to: $nagios::client::host_notification_period)
  • use (Any) (defaults to: $nagios::client::host_use)


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

define nagios::host (
    $server              = $nagios::client::server,
    $address             = $nagios::client::host_address,
    $host_alias          = $nagios::client::host_alias,
    $check_period        = $nagios::client::host_check_period,
    $check_command       = $nagios::client::host_check_command,
    $contact_groups      = $nagios::client::host_contact_groups,
    $hostgroups          = $nagios::client::host_hostgroups,
    $notes               = $nagios::client::host_notes,
    $notes_url           = $nagios::client::host_notes_url,
    $notification_period = $nagios::client::host_notification_period,
    $use                 = $nagios::client::host_use
) {

    # Fallback to defaults here, no problems passing empty values for the rest
    $final_address = $address ? {
        ''      => $::ipaddress,
        undef   => $::ipaddress,
        default => $address,
    }
    $swapsize = getvar('::swapsize') ? {
      undef   => 'n/a',
      default => $::swapsize,
    }
    $final_notes = $notes ? {
        ''      => "<table><tr><th>OS</th><td>${::operatingsystem} ${::operatingsystemrelease}</td></tr><tr><th>CPU</th><td>${::physicalprocessorcount} x ${::processor0}</td></tr><tr><th>Architecture</th><td>${::architecture}</td></tr><tr><th>Kernel</th><td>${::kernelrelease}</td></tr><tr><th>Memory</th><td>${::memorysize}</td></tr><tr><th>Swap</th><td>${swapsize}</td></tr></table>",
        undef   => "<table><tr><th>OS</th><td>${::operatingsystem} ${::operatingsystemrelease}</td></tr><tr><th>CPU</th><td>${::physicalprocessorcount} x ${::processor0}</td></tr><tr><th>Architecture</th><td>${::architecture}</td></tr><tr><th>Kernel</th><td>${::kernelrelease}</td></tr><tr><th>Memory</th><td>${::memorysize}</td></tr><tr><th>Swap</th><td>${swapsize}</td></tr></table>",
        default => $notes,
    }
    $final_notes_url = $notes_url ? {
        ''      => "/nagios/cgi-bin/status.cgi?host=${title}",
        undef   => "/nagios/cgi-bin/status.cgi?host=${title}",
        default => $notes_url,
    }
    $final_use = $use ? {
        ''      => 'linux-server',
        undef   => 'linux-server',
        default => $use,
    }

    @@nagios_host { $title:
        address             => $final_address,
        alias               => $host_alias,
        check_period        => $check_period,
        check_command       => $check_command,
        contact_groups      => $contact_groups,
        hostgroups          => $hostgroups,
        notes               => $final_notes,
        notes_url           => $final_notes_url,
        notification_period => $notification_period,
        use                 => $final_use,
        # Support an arrays of tags for multiple nagios servers
        tag                 => regsubst($server,'^(.+)$','nagios-\1'),
    }

}