munin: Rewrote munin::plugin

This commit is contained in:
Ossi Salmi 2013-07-18 18:24:21 +03:00
parent 1c42703762
commit 05ac584cbf

View file

@ -143,76 +143,61 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") {
# Plugin name to install. # Plugin name to install.
# $enable: # $enable:
# Set to false to disable plugin. # Set to false to disable plugin.
# $source:
# Source path for the plugin.
# $config: # $config:
# Configuration file name associated with plugin. Defaults to none. # Source path of plugin configuration file. Defaults to none.
# #
# === Sample usage # === Sample usage
# #
# munin::plugin { "vmware_vms": # munin::plugin { "nagios_multi_":
# config => "vmware", # source => "puppet:///files/munin/plugins/nagios_multi_",
# config => "puppet:///files/munin/plugins/nagios_multi_.conf",
# } # }
# #
define munin::plugin($enable=true, $config="") { define munin::plugin($enable=true, $source=undef, $config=undef) {
if $enable == true { if $enable == true {
if ! $source {
fail("Must define source parameter for Munin::Plugin[${name}]")
}
case $::operatingsystem { case $::operatingsystem {
"openbsd": { "openbsd": {
file { "/usr/local/libexec/munin/plugins/${name}": $plugindir = "/usr/local/libexec/munin/plugins"
ensure => present,
mode => "0755",
owner => "root",
group => "wheel",
source => [ "puppet:///files/munin/plugins/${name}",
"puppet:///modules/munin/plugins/${name}", ],
require => Package["munin-node"],
}
exec { "munin-enable-${name}":
command => "ln -s /usr/local/libexec/munin/plugins/${name} /etc/munin/plugins/${name}",
path => "/bin:/usr/bin:/sbin:/usr/sbin",
user => "root",
onlyif => [ "test ! -h /etc/munin/plugins/${name}",
"/usr/local/libexec/munin/plugins/${name} autoconf", ],
notify => Service["munin-node"],
require => File["/usr/local/libexec/munin/plugins/${name}"],
}
} }
default: { default: {
file { "/usr/share/munin/plugins/${name}": $plugindir = "/usr/share/munin/plugins"
ensure => present,
mode => "0755",
owner => "root",
group => "root",
source => [ "puppet:///files/munin/plugins/${name}",
"puppet:///modules/munin/plugins/${name}", ],
require => Package["munin-node"],
}
exec { "munin-enable-${name}":
command => "ln -s /usr/share/munin/plugins/${name} /etc/munin/plugins/${name}",
path => "/bin:/usr/bin:/sbin:/usr/sbin",
user => "root",
onlyif => [ "test ! -h /etc/munin/plugins/${name}",
"/usr/share/munin/plugins/${name} autoconf", ],
notify => Service["munin-node"],
require => File["/usr/share/munin/plugins/${name}"],
}
} }
} }
if $config { file { "${plugindir}/${name}":
file { "/etc/munin/plugin-conf.d/${config}": ensure => present,
ensure => present, mode => "0755",
mode => "0644", owner => "root",
owner => "root", group => $::operatingsystem ? {
group => $::operatingsystem ? { "openbsd" => "wheel",
"openbsd" => "wheel", default => "root",
default => "root", },
}, source => $source,
source => [ "puppet:///files/munin/plugin-conf/${config}.${::homename}", notify => Exec["munin-node-configure"],
"puppet:///files/munin/plugin-conf/${config}", require => Package["munin-node"],
"puppet:///modules/munin/plugin-conf/${config}", ], }
notify => Service["munin-node"],
before => Exec["munin-enable-name"], file { "/etc/munin/plugin-conf.d/${name}":
} ensure => $config ? {
undef => absent,
default => present,
},
mode => "0644",
owner => "root",
group => $::operatingsystem ? {
"openbsd" => "wheel",
default => "root",
},
source => $config,
notify => Exec["munin-node-configure"],
require => Package["munin-node"],
} }
} else { } else {
file { "/etc/munin/plugin-conf.d/${name}": file { "/etc/munin/plugin-conf.d/${name}":