aboutsummaryrefslogtreecommitdiff
path: root/manifests/subsystem/monitor/master.pp
blob: c93ec0eeff297aea476c105f8794572e83043510 (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
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
102
class nodo::subsystem::monitor::master {
  file { '/etc/nagios-plugins/check_rbl.ini':
    ensure  => present,
    owner   => root,
    group   => root,
    source  => 'puppet:///modules/nodo/etc/nagios-plugins/check_rbl.ini',
    require => Package['nagios'],
  }

  $main   = hiera('nodo::role::master::main', false)
  $ensure = $main ? {
    true    => 'present',
    default => 'absent',
  }

  # See http://www.jethrocarr.com/2012/05/26/munin-performance/
  file { "munin_graph_performance":
    ensure  => $ensure,
    path    => "/var/lib/puppet/modules/munin/nodes/00-performance",
    content => "max_graph_jobs 1\nmax_cgi_graph_jobs 1\n",
    require => $main ? {
      true    => Concatenated_file['/etc/munin/munin.conf'],
      default => undef,
    },
  }

  # See https://raymii.org/s/tutorials/Munin_optimalization_on_Debian.html
  file { '/usr/local/bin/munin-graph':
    ensure  => $ensure,
    owner   => root,
    group   => root,
    mode    => 0755,
    source  => 'puppet:///modules/nodo/bin/munin-graph',
  }

  file { '/etc/cron.d/munin-graph':
    ensure  => $ensure,
    owner   => root,
    group   => root,
    mode    => 0644,
    content => "10 * * * *      munin if [ -x /usr/local/bin/munin-graph ]; then /usr/local/bin/munin-graph; fi\n",
    require => File['/usr/local/bin/munin-graph'],
  }

  # We won't mess with the package, so we distribute our own munin-cron
  file { '/usr/local/bin/munin-cron':
    ensure  => $ensure,
    owner   => root,
    group   => root,
    mode    => 0755,
    source  => 'puppet:///modules/nodo/bin/munin-cron',
  }

  file { '/etc/cron.d/munin':
    ensure  => $ensure,
    owner   => root,
    group   => root,
    mode    => 0644,
    source  => 'puppet:///modules/nodo/etc/cron.d/munin',
    require => File['/usr/local/bin/munin-cron'],
  }

  #
  # See https://raymii.org/s/tutorials/Munin_optimalization_on_Debian.html
  #     https://munin.readthedocs.org/en/latest/master/rrdcached.html
  #     http://kuszelas.eu/~eyck/log/Howto/Munin.Rrdcached.html
  #     http://munin-monitoring.org/wiki/rrdcached
  #
  package { 'rrdcached':
    ensure => $ensure,
  }

  file { '/etc/default/rrdcached':
    ensure  => $ensure,
    owner   => root,
    group   => root,
    source  => 'puppet:///modules/nodo/etc/default/rrdcached',
    require => Package['rrdcached'],
    notify  => $main ? {
      true    => Service['rrdcached'],
      default => undef,
    },
  }

  # Munin configuration for rrdcache
  file { "munin_rrdcache":
    ensure  => $ensure,
    path    => "/var/lib/puppet/modules/munin/nodes/00-rrdcache",
    content => "rrdcached_socket /var/run/rrdcached.sock\n",
    require => $main ? {
      true    => Concatenated_file['/etc/munin/munin.conf'],
      default => undef,
    },
  }

  if $main == true {
    service { 'rrdcached':
      ensure  => running,
      require => Package['rrdcached'],
    }
  }
}