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