summaryrefslogtreecommitdiff
path: root/manifests/plugin.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/plugin.pp')
-rw-r--r--manifests/plugin.pp129
1 files changed, 129 insertions, 0 deletions
diff --git a/manifests/plugin.pp b/manifests/plugin.pp
new file mode 100644
index 0000000..8b85e63
--- /dev/null
+++ b/manifests/plugin.pp
@@ -0,0 +1,129 @@
+# plugin.pp - configure a specific munin plugin
+# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
+# See LICENSE for the full license granted to you.
+
+define munin::plugin (
+ $ensure = "present",
+ $script_path = "/usr/share/munin/plugins",
+ $config = '')
+{
+ debug ( "munin_plugin: name=$name, ensure=$ensure, script_path=$script_path" )
+ $plugin = "/etc/munin/plugins/$name"
+ $plugin_conf = "/etc/munin/plugin-conf.d/$name.conf"
+ case $ensure {
+ "absent": {
+ debug ( "munin_plugin: suppressing $plugin" )
+ file { $plugin: ensure => absent, }
+ }
+ default: {
+ $plugin_src = $ensure ? { "present" => $name, default => $ensure }
+ debug ( "munin_plugin: making $plugin using src: $plugin_src" )
+ file { $plugin:
+ ensure => "$script_path/${plugin_src}",
+ require => Package["munin-node"],
+ notify => Service["munin-node"],
+ }
+ }
+ }
+ case $config {
+ '': {
+ debug("no config for $name")
+ file { $plugin_conf: ensure => absent }
+ }
+ default: {
+ case $ensure {
+ absent: {
+ debug("removing config for $name")
+ file { $plugin_conf: ensure => absent }
+ }
+ default: {
+ debug("creating $plugin_conf")
+ file { $plugin_conf:
+ content => "[${name}]\n$config\n",
+ mode => 0644, owner => root, group => root,
+ }
+ }
+ }
+ }
+ }
+}
+
+define munin::remoteplugin($ensure = "present", $source, $config = '') {
+ case $ensure {
+ "absent": { munin::plugin{ $name: ensure => absent } }
+ default: {
+ file {
+ "/var/lib/puppet/modules/munin/plugins/${name}":
+ source => $source,
+ mode => 0755, owner => root, group => root;
+ }
+ munin::plugin { $name:
+ ensure => $ensure,
+ config => $config,
+ script_path => "/var/lib/puppet/modules/munin/plugins",
+ }
+ }
+ }
+}
+
+class munin::plugins::base {
+
+ file {
+ [ "/etc/munin/plugins", "/etc/munin/plugin-conf.d" ]:
+ source => "puppet://$servername/munin/empty",
+ ensure => directory, checksum => mtime,
+ recurse => true, purge => true, force => true,
+ mode => 0755, owner => root, group => root,
+ notify => Service[munin-node];
+ "/etc/munin/plugin-conf.d/munin-node":
+ ensure => present,
+ mode => 0644, owner => root, group => root,
+ notify => Service[munin-node];
+ }
+
+ puppet::fact{ interfaces:
+ source => "puppet://$servername/munin/facter/interfaces.rb",
+ require => Package[iproute],
+ }
+}
+
+# handle if_ and if_err_ plugins
+class munin::plugins::interfaces inherits munin::plugins::base {
+
+ $ifs = gsub(split($interfaces, " "), "(.+)", "if_\\1")
+ $if_errs = gsub(split($interfaces, " "), "(.+)", "if_err_\\1")
+ plugin {
+ $ifs: ensure => "if_";
+ $if_errs: ensure => "if_err_";
+ }
+
+
+}
+
+class munin::plugins::linux inherits munin::plugins::base {
+
+ plugin {
+ [ df_abs, forks, iostat, memory, processes, cpu, df_inode, irqstats,
+ netstat, open_files, swap, df, entropy, interrupts, load, open_inodes,
+ vmstat
+ ]:
+ ensure => present;
+ }
+
+ include munin::plugins::interfaces
+}
+
+class munin::plugins::debian inherits munin::plugins::base {
+
+ plugin { apt_all: ensure => present; }
+
+}
+
+class munin::plugins::vserver inherits munin::plugins::base {
+
+ plugin {
+ [ netstat, processes, vmstat ]:
+ ensure => present;
+ }
+
+}