summaryrefslogtreecommitdiff
path: root/manifests/plugin.pp
diff options
context:
space:
mode:
authorMarcel Haerry <haerry@puzzle.ch>2009-06-02 12:04:21 +0200
committerMarcel Haerry <haerry@puzzle.ch>2009-06-02 12:04:21 +0200
commit2ec7065337abc02835be322151c78da4a2410baf (patch)
treeade64070a5e30312323c3d55bd6ecb2278d2e266 /manifests/plugin.pp
parent8442cf9262887764cfd8d66323d79953d3176cdc (diff)
parente6b9c153680f94acb0201394325d9c2a2bdd4b0a (diff)
merged with immerda
Diffstat (limited to 'manifests/plugin.pp')
-rw-r--r--manifests/plugin.pp282
1 files changed, 162 insertions, 120 deletions
diff --git a/manifests/plugin.pp b/manifests/plugin.pp
index bb02e46..8d739a8 100644
--- a/manifests/plugin.pp
+++ b/manifests/plugin.pp
@@ -7,124 +7,125 @@
### configpaths
class munin::plugin::scriptpaths {
- case $operatingsystem {
- gentoo: {
- $script_path = "/usr/libexec/munin/plugins"
- }
- debian: {
- $script_path = "/usr/share/munin/plugins"
- }
- centos: {
- $script_path = "/usr/share/munin/plugins"
- }
- default: {
- $script_path = "/usr/share/munin/plugins"
- }
- }
+ case $operatingsystem {
+ gentoo: { $script_path = "/usr/libexec/munin/plugins" }
+ debian: { $script_path = "/usr/share/munin/plugins" }
+ centos: { $script_path = "/usr/share/munin/plugins" }
+ openbsd: { $script_path = "/opt/munin/lib/plugins/" }
+ default: { $script_path = "/usr/share/munin/plugins" }
+ }
}
### defines
define munin::plugin (
- $ensure = "present",
- $script_path_in = '',
- $config = '')
+ $ensure = "present",
+ $script_path_in = '',
+ $config = '')
{
include munin::plugin::scriptpaths
- $real_script_path = $script_path_in ? { '' => $munin::plugin::scriptpaths::script_path, default => $script_path_in }
-
- $plugin_src = $ensure ? { "present" => $name, default => $ensure }
- debug ( "munin_plugin: name=$name, ensure=$ensure, script_path=$munin::plugin::scriptpaths::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: {
- debug ( "munin_plugin: making $plugin using src: $plugin_src" )
+ $real_script_path = $script_path_in ? { '' => $munin::plugin::scriptpaths::script_path, default => $script_path_in }
+
+ $plugin_src = $ensure ? { "present" => $name, default => $ensure }
+ $plugin = "/etc/munin/plugins/$name"
+ $plugin_conf = "/etc/munin/plugin-conf.d/$name.conf"
+ case $ensure {
+ "absent": {
+ file { $plugin: ensure => absent, }
+ }
+ default: {
+ case $kernel {
+ openbsd: { $basic_require = File['/var/run/munin'] }
+ default: { $basic_require = Package['munin-node'] }
+ }
if $require {
- $real_require = [ $require, Package['munin-node'] ]
+ $real_require = [ $require, $basic_require ]
} else {
- $real_require = Package['munin-node']
+ $real_require = $basic_require
}
- file { $plugin:
- ensure => "${real_script_path}/${plugin_src}",
- require => $real_require,
- 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 => 0,
- }
+ file { $plugin:
+ ensure => "${real_script_path}/${plugin_src}",
+ require => $real_require,
+ notify => Service['munin-node'];
+ }
+
+ }
+ }
+ case $config {
+ '': {
+ file { $plugin_conf: ensure => absent }
+ }
+ default: {
+ case $ensure {
+ absent: {
+ file { $plugin_conf: ensure => absent }
+ }
+ default: {
+ file { $plugin_conf:
+ content => "[${name}]\n$config\n",
+ mode => 0644, owner => root, group => 0,
+ }
if $require {
File[$plugin_conf]{
require +> $require,
}
}
- }
- }
- }
- }
+ }
+ }
+ }
+ }
}
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 => 0;
- }
- munin::plugin { $name:
- ensure => $ensure,
- config => $config,
- script_path_in => "/var/lib/puppet/modules/munin/plugins",
- }
- }
- }
+ case $ensure {
+ "absent": { munin::plugin{ $name: ensure => absent } }
+ default: {
+ file {
+ "/var/lib/puppet/modules/munin/plugins/${name}":
+ source => $source,
+ mode => 0755, owner => root, group => 0;
+ }
+ munin::plugin { $name:
+ ensure => $ensure,
+ config => $config,
+ script_path_in => "/var/lib/puppet/modules/munin/plugins",
+ }
+ }
+ }
}
define munin::plugin::deploy ($source = '', $ensure = 'present', $config = '') {
- $plugin_src = $ensure ? {
- 'present' => $name,
- 'absent' => $name,
- default => $ensure
+ $plugin_src = $ensure ? {
+ 'present' => $name,
+ 'absent' => $name,
+ default => $ensure
}
$real_source = $source ? {
'' => "munin/plugins/$plugin_src",
default => $source
}
include munin::plugin::scriptpaths
- debug ( "munin_plugin_${name}: name=$name, source=$source, script_path=$munin::plugin::scriptpaths::script_path" )
file { "munin_plugin_${name}":
path => "$munin::plugin::scriptpaths::script_path/${name}",
source => "puppet://$server/$real_source",
- require => Package['munin-node'],
mode => 0755, owner => root, group => 0;
}
+
+ case $kernel {
+ openbsd: { $basic_require = File['/var/run/munin'] }
+ default: { $basic_require = Package['munin-node'] }
+ }
if $require {
File["munin_plugin_${name}"]{
- require +> $require,
+ require => [ $basic_require, $require ],
}
+ } else {
+ File["munin_plugin_${name}"]{
+ require => $basic_require,
+ }
+ }
+ # register the plugin
+ if $require {
munin::plugin{$name: ensure => $ensure, config => $config, require => $require }
} else {
munin::plugin{$name: ensure => $ensure, config => $config }
@@ -135,23 +136,40 @@ define munin::plugin::deploy ($source = '', $ensure = 'present', $config = '') {
class munin::plugins::base {
file {
- [ "/etc/munin/plugins", "/etc/munin/plugin-conf.d" ]:
- source => "puppet://$server/common/empty",
+ [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]:
+ source => "puppet://$server/common/empty",
ignore => [ '\.ignore', 'snmp_*' ],
- ensure => directory, checksum => mtime,
- recurse => true, purge => true, force => true,
- mode => 0755, owner => root, group => 0,
- notify => Service['munin-node'];
- "/etc/munin/plugin-conf.d/munin-node":
- ensure => present,
- mode => 0644, owner => root, group => 0,
- notify => Service['munin-node'],
- before => Package['munin-node'];
- }
-
- munin::plugin {'uptime': ensure => present, }
+ ensure => directory, checksum => mtime,
+ recurse => true, purge => true, force => true,
+ mode => 0755, owner => root, group => 0,
+ notify => Service['munin-node'];
+ '/etc/munin/plugin-conf.d/munin-node':
+ ensure => present,
+ mode => 0644, owner => root, group => 0,
+ notify => Service['munin-node'],
+ }
+
+ munin::plugin {
+ [ df, cpu, interrupts, load, memory, netstat, open_files,
+ processes, swap, uptime, users, vmstat
+ ]:
+ ensure => present,
+ }
+ include munin::plugins::interfaces
case $kernel {
+ openbsd: {
+ File['/etc/munin/plugin-conf.d/munin-node']{
+ before => File['/var/run/munin'],
+ }
+ }
+ default: {
+ File['/etc/munin/plugin-conf.d/munin-node']{
+ before => Package['munin-node'],
+ }
+ }
+ }
+ case $kernel {
linux: {
case $vserver {
guest: { include munin::plugins::vserver }
@@ -171,38 +189,60 @@ class munin::plugins::base {
# 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")
- munin::plugin {
- $ifs: ensure => "if_";
- $if_errs: ensure => "if_err_";
- }
+ $ifs = gsub(split($interfaces, " |,"), "(.+)", "if_\\1")
+ munin::plugin {
+ $ifs: ensure => "if_";
+ }
+ case $operatingsystem {
+ openbsd: {
+ $if_errs = gsub(split($interfaces, " |,"), "(.+)", "if_errcoll_\\1")
+ munin::plugin{
+ $if_errs: ensure => "if_errcoll_";
+ }
+ }
+ default: {
+ $if_errs = gsub(split($interfaces, " |,"), "(.+)", "if_err_\\1")
+ munin::plugin{
+ $if_errs: ensure => "if_err_";
+ }
+ }
+ }
}
class munin::plugins::linux inherits munin::plugins::base {
+ munin::plugin {
+ [ df_abs, forks, df_inode, irqstats, entropy, open_inodes ]:
+ ensure => present;
+ acpi:
+ ensure => $acpi_available;
+ }
- munin::plugin {
- [ df_abs, forks, memory, processes, cpu, df_inode, irqstats,
- netstat, open_files, swap, df, entropy, interrupts, load, open_inodes,
- vmstat
- ]:
- ensure => present;
- acpi:
- ensure => $acpi_available;
- }
-
- include munin::plugins::interfaces
+ include munin::plugins::interfaces
}
class munin::plugins::debian inherits munin::plugins::base {
- munin::plugin { apt_all: ensure => present; }
+ munin::plugin { apt_all: ensure => present; }
+}
+
+class munin::plugins::openbsd inherits munin::plugins::base {
+ munin::plugin {
+ [ df, cpu, interrupts, load, memory, netstat, open_files,
+ processes, swap, users, vmstat
+ ]:
+ ensure => present,
+ }
+ munin::plugin {
+ [ memory_pools, memory_types ]:
+ ensure => present,
+ }
+
}
class munin::plugins::vserver inherits munin::plugins::base {
- munin::plugin {
- [ netstat, processes ]:
- ensure => present;
- }
+ munin::plugin {
+ [ netstat, processes ]:
+ ensure => present;
+ }
}
class munin::plugins::gentoo inherits munin::plugins::base {
@@ -223,7 +263,9 @@ class munin::plugins::dom0 inherits munin::plugins::physical {
}
class munin::plugins::physical inherits munin::plugins::base {
- munin::plugin { iostat: }
+ case $kernel {
+ linux: { munin::plugin { iostat: } }
+ }
}
class munin::plugins::muninhost inherits munin::plugins::base {