summaryrefslogtreecommitdiff
path: root/manifests/irc_bot/base.pp
blob: 6fab2ac20e1edd9ba561f5a50af6af39ccf873c9 (plain)
1
2
3
4
5
6
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
69
class nagios::irc_bot::base {

    # Default values for the two first variables are defined in nagios::irc_bot
    $nsa_socket = $nsa_socket ? {
        '' => $nsa_default_socket,
        default => $nsa_socket,
    }
    $nsa_pidfile = $nsa_pidfile ? {
        '' => $nsa_default_pidfile,
        default => $nsa_pidfile,
    }
    $nsa_port = $nsa_port ? {
        '' => '6667',
        default => $nsa_port,
    }
    $nsa_realname = $nsa_realname ? {
        '' => 'Nagios',
        default => $nsa_realname,
    }

    if (! $nsa_password) {
        $nsa_password = ''
    }

    if (! $nsa_usenotices) {
      $nsa_usenotices = ''
    }
    
    file { "/usr/local/bin/riseup-nagios-client.pl":
        owner => root, group => 0, mode => 0755,
        source => "puppet:///modules/nagios/irc_bot/riseup-nagios-client.pl",
    }
    file { "/usr/local/bin/riseup-nagios-server.pl":
        owner => root, group => 0, mode => 0755,
        source => "puppet:///modules/nagios/irc_bot/riseup-nagios-server.pl",
    }
    file { "/etc/init.d/nagios-nsa":
        owner => root, group => 0, mode => 0755,
        content => template("nagios/irc_bot/${operatingsystem}/nagios-nsa.sh.erb"),
        require => File["/usr/local/bin/riseup-nagios-server.pl"],
    }
    file { "/etc/nagios_nsa.cfg":
        ensure => present,
        owner => nagios, group => 0, mode => 0400,
        content => template('nagios/irc_bot/nsa.cfg.erb'),
        notify => Service["nagios-nsa"],
    }

    package { "libnet-irc-perl":
        ensure => present,
    }

    service { "nagios-nsa":
        ensure => "running",
        hasstatus => true,
        enable => true,
        require => [File["/etc/nagios_nsa.cfg"],
                    File["/etc/init.d/nagios-nsa"],
                    Package["libnet-irc-perl"],
                    Service['nagios'] ],
    }

    nagios_command {
        "notify-by-irc":
            command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($SERVICEDESC$) $NOTIFICATIONTYPE$ $SERVICEATTEMPT$/$MAXSERVICEATTEMPTS$ $SERVICESTATETYPE$ $SERVICEEXECUTIONTIME$s $SERVICELATENCY$s $SERVICEOUTPUT$ $SERVICEPERFDATA$"';
        "host-notify-by-irc":
            command_line => '/usr/local/bin/riseup-nagios-client.pl "$HOSTNAME$ ($HOSTALIAS$) $NOTIFICATIONTYPE$ $HOSTATTEMPT$/$MAXHOSTATTEMPTS$ $HOSTSTATETYPE$ took $HOSTEXECUTIONTIME$s $HOSTOUTPUT$ $HOSTPERFDATA$ $HOSTLATENCY$s"';
    }
}