Puppet Class: nagios::webinterface

Defined in:
manifests/webinterface.pp

Overview

Class: nagios::webinterface

This class takes care of all the bits needed to run the CGIs used to display nagios’s status in a web browser.

Example usage:

include nagios
include nagios::webinterface

Parameters:

  • authorized_for_system_information (Any) (defaults to: 'nagiosadmin')
  • authorized_for_configuration_information (Any) (defaults to: 'nagiosadmin')
  • authorized_for_system_commands (Any) (defaults to: 'nagiosadmin')
  • authorized_for_all_services (Any) (defaults to: 'nagiosadmin')
  • authorized_for_all_hosts (Any) (defaults to: 'nagiosadmin')
  • authorized_for_all_host_commands (Any) (defaults to: 'nagiosadmin')
  • authorized_for_all_service_commands (Any) (defaults to: 'nagiosadmin')
  • use_authentication (Any) (defaults to: '1')
  • default_user_name (Any) (defaults to: undef)
  • action_url_target (Any) (defaults to: '_blank')
  • default_statusmap_layout (Any) (defaults to: 5)
  • default_statuswrl_layout (Any) (defaults to: 4)
  • escape_html_tags (Any) (defaults to: 1)
  • lock_author_names (Any) (defaults to: 1)
  • notes_url_target (Any) (defaults to: '_blank')
  • ping_syntax (Any) (defaults to: '/bin/ping -n -U -c 5 $HOSTADDRESS$')
  • result_limit (Any) (defaults to: 100)
  • refresh_rate (Any) (defaults to: 90)
  • show_context_help (Any) (defaults to: 0)
  • use_pending_states (Any) (defaults to: 1)


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

class nagios::webinterface(
  $authorized_for_system_information        = 'nagiosadmin',
  $authorized_for_configuration_information = 'nagiosadmin',
  $authorized_for_system_commands           = 'nagiosadmin',
  $authorized_for_all_services              = 'nagiosadmin',
  $authorized_for_all_hosts                 = 'nagiosadmin',
  $authorized_for_all_host_commands         = 'nagiosadmin',
  $authorized_for_all_service_commands      = 'nagiosadmin',
  $use_authentication                       = '1',
  $default_user_name                        = undef,

  $action_url_target        = '_blank',
  $default_statusmap_layout = 5,
  $default_statuswrl_layout = 4,
  $escape_html_tags         = 1,
  $lock_author_names        = 1,
  $notes_url_target         = '_blank',
  $ping_syntax              = '/bin/ping -n -U -c 5 $HOSTADDRESS$',
  $result_limit             = 100,
  $refresh_rate             = 90,
  $show_context_help        = 0,
  $use_pending_states       = 1,
) {

  include ::nagios::params

  # variables used in erb template.
  $nagios_main_config_file     = $nagios::params::conffile
  $nagios_physical_html_path   = "/usr/share/${nagios::params::basename}"
  $nagios_url_html_path        = "/${nagios::params::basename}"
  $nagios_nagios_check_command = "${nagios::params::user1}/check_nagios /var/cache/${nagios::params::basename}/status.dat 5 '/usr/sbin/${nagios::params::basename}'"

  file {"${nagios::params::rootdir}/cgi.cfg":
    ensure  => file,
    owner   => root,
    group   => root,
    mode    => '0644',
    content => template('nagios/cgi.cfg.erb'),
    require => Class['nagios'],
    notify  => Exec['apache-graceful'],
  }

  case $::osfamily {

    'RedHat': {
      package {['nagios-www', 'nagios-plugins-nagios']:
        ensure => present,
      }

      #SELinux - see
      # http://grokbase.com/post/2008/12/06/centos-trying-to-setting-a-selinux-policy-to-nagios-3-0-6-on-centos-5-2/u-x2GXaK02ZlLVNVs_Mkq0G2hDg
      selinux::module {'nagios-httpd':
        content => "
module nagios-httpd 1.1;
require {
  type var_t;
  type httpd_t;
  type nagios_log_t;
  type httpd_nagios_script_t;
  class fifo_file { write getattr read create };
  class file { rename setattr read create write getattr unlink };
}
#============= httpd_nagios_script_t ==============
allow httpd_nagios_script_t var_t:fifo_file { write getattr };
allow httpd_nagios_script_t var_t:file { read getattr };
#============= httpd_t ==============
allow httpd_t nagios_log_t:file read;
",
      }
    }

    'Debian': {

      package {'nagios3-cgi':
        ensure => present,
      }

      file {'/etc/apache2/conf.d/nagios3.conf':
        ensure => absent,
        notify => Exec['apache-graceful'],
      }
    }

    default: {
      fail "Unknown osfamily: ${::osfamily}"
    }
  }

  include ::nagios::base::withwebinterface

}