munin: Rewrote munin::plugin
This commit is contained in:
parent
1c42703762
commit
05ac584cbf
1 changed files with 40 additions and 55 deletions
|
@ -143,76 +143,61 @@ define munin::snmpnode($snmp_community="public", $snmp_version="2") {
|
|||
# Plugin name to install.
|
||||
# $enable:
|
||||
# Set to false to disable plugin.
|
||||
# $source:
|
||||
# Source path for the plugin.
|
||||
# $config:
|
||||
# Configuration file name associated with plugin. Defaults to none.
|
||||
# Source path of plugin configuration file. Defaults to none.
|
||||
#
|
||||
# === Sample usage
|
||||
#
|
||||
# munin::plugin { "vmware_vms":
|
||||
# config => "vmware",
|
||||
# munin::plugin { "nagios_multi_":
|
||||
# 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 ! $source {
|
||||
fail("Must define source parameter for Munin::Plugin[${name}]")
|
||||
}
|
||||
|
||||
case $::operatingsystem {
|
||||
"openbsd": {
|
||||
file { "/usr/local/libexec/munin/plugins/${name}":
|
||||
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}"],
|
||||
}
|
||||
$plugindir = "/usr/local/libexec/munin/plugins"
|
||||
}
|
||||
default: {
|
||||
file { "/usr/share/munin/plugins/${name}":
|
||||
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}"],
|
||||
}
|
||||
$plugindir = "/usr/share/munin/plugins"
|
||||
}
|
||||
}
|
||||
|
||||
if $config {
|
||||
file { "/etc/munin/plugin-conf.d/${config}":
|
||||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
source => [ "puppet:///files/munin/plugin-conf/${config}.${::homename}",
|
||||
"puppet:///files/munin/plugin-conf/${config}",
|
||||
"puppet:///modules/munin/plugin-conf/${config}", ],
|
||||
notify => Service["munin-node"],
|
||||
before => Exec["munin-enable-name"],
|
||||
}
|
||||
file { "${plugindir}/${name}":
|
||||
ensure => present,
|
||||
mode => "0755",
|
||||
owner => "root",
|
||||
group => $::operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
source => $source,
|
||||
notify => Exec["munin-node-configure"],
|
||||
require => Package["munin-node"],
|
||||
}
|
||||
|
||||
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 {
|
||||
file { "/etc/munin/plugin-conf.d/${name}":
|
||||
|
|
Loading…
Add table
Reference in a new issue