summaryrefslogtreecommitdiff
path: root/manifests/client.pp
blob: f52af9fd18b54145312cfb9d39cdcb86e1d8fa42 (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
103
104
105
106
107
108
109
110
111
# 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, 
		'fqdn' => $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()
{
	@@file { "munin_node_${name}": path => "${NODESDIR}/$name",
		ensure => present,
		content => template("munin/defaultclient.erb"),
	}
}

define munin::register_snmp()
{
	@@file { "munin_snmp_${name}": path => "${NODESDIR}/$name",
		ensure => present,
		content => template("munin/snmpclient.erb"),
	}
}

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-",
	}
	append_if_no_such_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 
{
	err("munin port: $munin_port_real" )
	err("munin host: $munin_host_real" )

	package { "munin-node": ensure => installed }

	file {
		"/etc/munin/munin-node.conf":
			content => template("munin/munin-node.conf.${operatingsystem}.${lsbdistcodename}"),
			mode => 0644, owner => root, group => root,
			require => Package["munin-node"],
			notify => Service["munin-node"],
	}

	service { "munin-node":
		ensure => running, 
		hasstatus => true,
	}

	munin::register { $munin_host_real: }

	# workaround bug in munin_node_configure
	plugin { "postfix_mailvolume": ensure => absent }
}