uebersehener error
[puppet_munin.git] / manifests / plugin.pp
1 # plugin.pp - configure a specific munin plugin
2 # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
3 # See LICENSE for the full license granted to you.
4
5 define munin::plugin (
6         $ensure = "present",
7         $script_path = "/usr/share/munin/plugins",
8         $config = '')
9 {
10         case $operatingsystem {
11                 debian: {       $munin_node_service = "munin-node" }
12                 gentoo: {       $munin_node_service = "munin" }
13         }
14         $plugin_src = $ensure ? { "present" => $name, default => $ensure }
15         debug ( "munin_plugin: name=$name, ensure=$ensure, script_path=$script_path" )
16         $plugin = "/etc/munin/plugins/$name"
17         $plugin_conf = "/etc/munin/plugin-conf.d/$name.conf"
18         case $ensure {
19                 "absent": {
20                         debug ( "munin_plugin: suppressing $plugin" )
21                         file { $plugin: ensure => absent, } 
22                 }
23                 default: {
24                         #$plugin_src = $ensure ? { "present" => $name, default => $ensure }
25                         debug ( "munin_plugin: making $plugin using src: $plugin_src" )
26                         file { $plugin:
27                                 ensure => "$script_path/${plugin_src}",
28                                 require => Package[$munin_node_service],
29                                 notify => Service[$munin_node_service],
30                         }
31                 }
32         }
33         case $config {
34                 '': {
35                         debug("no config for $name")
36                         file { $plugin_conf: ensure => absent }
37                 }
38                 default: {
39                         case $ensure {
40                                 absent: {
41                                         debug("removing config for $name")
42                                         file { $plugin_conf: ensure => absent }
43                                 }
44                                 default: {
45                                         debug("creating $plugin_conf")
46                                         file { $plugin_conf:
47                                                 content => "[${name}]\n$config\n",
48                                                 mode => 0644, owner => root, group => root,
49                                         }
50                                 }
51                         }
52                 }
53         }
54 }
55
56 define munin::remoteplugin($ensure = "present", $source, $config = '') {
57         case $ensure {
58                 "absent": { munin::plugin{ $name: ensure => absent } }
59                 default: {
60                         file {
61                                 "/var/lib/puppet/modules/munin/plugins/${name}":
62                                         source => $source,
63                                         mode => 0755, owner => root, group => root;
64                         }
65                         munin::plugin { $name:
66                                 ensure => $ensure,
67                                 config => $config,
68                                 script_path => "/var/lib/puppet/modules/munin/plugins",
69                         }
70                 }
71         }
72 }
73
74 class munin::plugins::base {
75
76         case $operatingsystem {
77                 gentoo: {       $munin_node_service = "munin" }
78                 debian: {       $munin_node_service = "munin-node" }
79         }
80                 file {
81                         [ "/etc/munin/plugins", "/etc/munin/plugin-conf.d" ]:
82                                 source => "puppet://$servername/munin/empty",
83                                 ensure => directory, checksum => mtime,
84                                 recurse => true, purge => true, force => true, 
85                                 mode => 0755, owner => root, group => root,
86                                 notify => Service["$munin_node_service-$operatingsystem"];
87                         "/etc/munin/plugin-conf.d/munin-node":
88                                 ensure => present, 
89                                 mode => 0644, owner => root, group => root,
90                                 notify => Service[$munin_node_service];
91                 }
92 }
93
94 # handle if_ and if_err_ plugins
95 class munin::plugins::interfaces inherits munin::plugins::base {
96
97         $ifs = gsub(split($interfaces, " "), "(.+)", "if_\\1")
98         $if_errs = gsub(split($interfaces, " "), "(.+)", "if_err_\\1")
99         plugin {
100                 $ifs: ensure => "if_";
101                 $if_errs: ensure => "if_err_";
102         }
103 }
104
105 class munin::plugins::linux inherits munin::plugins::base {
106
107         plugin {
108                 [ df_abs, forks, iostat, memory, processes, cpu, df_inode, irqstats,
109                   netstat, open_files, swap, df, entropy, interrupts, load, open_inodes,
110                   vmstat
111                 ]:
112                         ensure => present;
113                 acpi: 
114                         ensure => $acpi_available;
115         }
116
117         include munin::plugins::interfaces
118 }
119
120 class munin::plugins::debian inherits munin::plugins::base {
121
122         plugin { apt_all: ensure => present; }
123
124 }
125
126 class munin::plugins::vserver inherits munin::plugins::base {
127
128         plugin {
129                 [ netstat, processes ]:
130                         ensure => present;
131         }
132
133 }
134
135 class munin::plugins::gentoo inherits munin::plugins::base {
136
137 }