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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# client.pp - configure a munin node
# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
# See LICENSE for the full license granted to you.
class munin::client {
$munin_port_real = $munin_port ? { '' => 4949, default => $munin_port }
$munin_host_real = $munin_host ? {
'' => '*',
'fqdn' => '*',
default => $munin_host
}
case $operatingsystem {
darwin: { include munin::client::darwin }
debian: {
include munin::client::debian
include munin::plugins::debian
}
ubuntu: {
info ( "Trying to configure Ubuntu's munin with Debian class" )
include munin::client::debian
include munin::plugins::debian
}
default: { fail ("Don't know how to handle munin on $operatingsystem") }
}
case $kernel {
linux: {
case $vserver {
guest: { include munin::plugins::vserver }
default: {
include munin::plugins::linux
case $virtual {
xen0: { include munin::plugins::xen }
}
}
}
}
default: {
err( "Don't know which munin plugins to install for $kernel" )
}
}
}
define munin::register()
{
$munin_port_real = $munin_port ? { '' => 4949, default => $munin_port }
$munin_host_real = $munin_host ? {
'' => $fqdn,
'fqdn' => $fqdn,
default => $munin_host
}
@@file { "${NODESDIR}/${name}_${munin_port_real}":
ensure => present,
content => template("munin/defaultclient.erb"),
tag => 'munin',
}
}
define munin::register_snmp()
{
@@file { "munin_snmp_${name}": path => "${NODESDIR}/${name}",
ensure => present,
content => template("munin/snmpclient.erb"),
tag => 'munin',
}
}
class munin::client::darwin
{
file { "/usr/share/snmp/snmpd.conf":
mode => 744,
content => template("munin/darwin_snmpd.conf.erb"),
group => staff,
owner => root,
}
delete_matching_line{"startsnmpdno":
file => "/etc/hostconfig",
pattern => "SNMPSERVER=-NO-",
}
line { "startsnmpdyes":
file => "/etc/hostconfig",
line => "SNMPSERVER=-YES-",
notify => Exec["/sbin/SystemStarter start SNMP"],
}
exec{"/sbin/SystemStarter start SNMP":
noop => false,
}
munin::register_snmp { $fqdn: }
}
class munin::client::debian
{
package { "munin-node": ensure => installed }
file {
"/etc/munin/":
ensure => directory,
mode => 0755, owner => root, group => root;
"/etc/munin/munin-node.conf":
content => template("munin/munin-node.conf.${operatingsystem}.${lsbdistcodename}"),
mode => 0644, owner => root, group => root,
# this has to be installed before the package, so the postinst can
# boot the munin-node without failure!
before => Package["munin-node"],
notify => Service["munin-node"],
}
service { "munin-node":
ensure => running,
# sarge's munin-node init script has no status
hasstatus => $lsbdistcodename ? { sarge => false, default => true }
}
munin::register { $fqdn: }
# workaround bug in munin_node_configure
plugin { "postfix_mailvolume": ensure => absent }
}
|