summaryrefslogtreecommitdiff
path: root/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'manifests')
-rw-r--r--manifests/client.pp25
-rw-r--r--manifests/client/base.pp48
-rw-r--r--manifests/client/centos.pp3
-rw-r--r--manifests/client/darwin.pp22
-rw-r--r--manifests/client/debian.pp14
-rw-r--r--manifests/client/gentoo.pp6
-rw-r--r--manifests/client/openbsd.pp46
-rw-r--r--manifests/client/package.pp12
-rw-r--r--manifests/client/params.pp19
-rw-r--r--manifests/host.pp44
-rw-r--r--manifests/host/cgi.pp30
-rw-r--r--manifests/init.pp41
-rw-r--r--manifests/plugin.pp74
-rw-r--r--manifests/plugin/deploy.pp16
-rw-r--r--manifests/plugin/scriptpaths.pp14
-rw-r--r--manifests/plugins/base.pp16
-rw-r--r--manifests/plugins/centos.pp3
-rw-r--r--manifests/plugins/debian.pp1
-rw-r--r--manifests/plugins/djbdns.pp5
-rw-r--r--manifests/plugins/dom0.pp1
-rw-r--r--manifests/plugins/gentoo.pp3
-rw-r--r--manifests/plugins/interfaces.pp32
-rw-r--r--manifests/plugins/kvm.pp1
-rw-r--r--manifests/plugins/linux.pp8
-rw-r--r--manifests/plugins/muninhost.pp3
-rw-r--r--manifests/plugins/openbsd.pp5
-rw-r--r--manifests/plugins/physical.pp6
-rw-r--r--manifests/plugins/selinux.pp1
-rw-r--r--manifests/plugins/setup.pp21
-rw-r--r--manifests/plugins/vserver.pp4
-rw-r--r--manifests/register.pp16
-rw-r--r--manifests/register/snmp.pp19
-rw-r--r--manifests/remoteplugin.pp19
-rw-r--r--manifests/snmp_collector.pp23
34 files changed, 301 insertions, 300 deletions
diff --git a/manifests/client.pp b/manifests/client.pp
index 2316bc9..afab5f1 100644
--- a/manifests/client.pp
+++ b/manifests/client.pp
@@ -1,30 +1,23 @@
-# client.pp - configure a munin node
# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
# See LICENSE for the full license granted to you.
# Adapted and improved by admin(at)immerda.ch
-class munin::client(
- $allow = [ '127.0.0.1' ],
- $host = '*',
- $port = '4949',
- $use_ssh = false,
- $manage_shorewall = false,
- $shorewall_collector_source = 'net',
- $export_tag = 'munin'
-) {
+# configure a munin node
+# WARNING: this class should not be included directly. See the 'munin' class.
+class munin::client {
+
case $::operatingsystem {
openbsd: { include munin::client::openbsd }
- darwin: { include munin::client::darwin }
debian,ubuntu: { include munin::client::debian }
gentoo: { include munin::client::gentoo }
- centos: { include munin::client::package }
+ centos: { include munin::client::base }
default: { include munin::client::base }
}
- if $munin::client::manage_shorewall {
+ if $munin::manage_shorewall {
class{'shorewall::rules::munin':
- munin_port => $port,
- munin_collector => delete($allow,'127.0.0.1'),
- collector_source => $shorewall_collector_source,
+ munin_port => $munin::port,
+ munin_collector => delete($munin::allow,'127.0.0.1'),
+ collector_source => $munin::shorewall_collector_source,
}
}
}
diff --git a/manifests/client/base.pp b/manifests/client/base.pp
index 78398a9..8ee8b95 100644
--- a/manifests/client/base.pp
+++ b/manifests/client/base.pp
@@ -1,28 +1,44 @@
-class munin::client::base {
+# Install a basic munin client
+class munin::client::base inherits munin::client::params {
+ package { 'munin-node':
+ ensure => installed
+ }
service { 'munin-node':
- ensure => running,
- enable => true,
- hasstatus => true,
+ ensure => running,
+ enable => true,
+ hasstatus => true,
hasrestart => true,
+ require => Package[munin-node],
}
file {'/etc/munin':
ensure => directory,
- mode => 0755, owner => root, group => 0;
+ mode => '0755',
+ owner => root,
+ group => 0,
}
file {'/etc/munin/munin-node.conf':
- content => template("munin/munin-node.conf.${::operatingsystem}"),
- notify => Service['munin-node'],
- mode => 0644, owner => root, group => 0,
+ content => template("${module_name}/munin-node.conf.erb"),
+ # this has to be installed before the package, so the postinst can
+ # boot the munin-node without failure!
+ before => Package['munin-node'],
+ notify => Service['munin-node'],
+ mode => '0644',
+ owner => root,
+ group => 0,
+ }
+ $host = $munin::host ? {
+ '*' => $::fqdn,
+ default => $munin::host
}
munin::register { $::fqdn:
- host => $munin::client::host ? {
- '*' => $::fqdn,
- default => $munin::client::host
- },
- port => $munin::client::port,
- use_ssh => $munin::client::use_ssh,
- config => [ 'use_node_name yes', 'load.load.warning 5', 'load.load.critical 10'],
- export_tag => $munin::client::export_tag,
+ host => $host,
+ port => $munin::port,
+ use_ssh => $munin::use_ssh,
+ description => $munin::description,
+ group => $munin::munin_group,
+ config => [ 'use_node_name yes', 'load.load.warning 5',
+ 'load.load.critical 10'],
+ export_tag => $munin::export_tag,
}
include munin::plugins::base
}
diff --git a/manifests/client/centos.pp b/manifests/client/centos.pp
deleted file mode 100644
index 3a7151b..0000000
--- a/manifests/client/centos.pp
+++ /dev/null
@@ -1,3 +0,0 @@
-class munin::client::centos inherits munin::client::package {
- include munin::plugins::centos
-}
diff --git a/manifests/client/darwin.pp b/manifests/client/darwin.pp
deleted file mode 100644
index 264263d..0000000
--- a/manifests/client/darwin.pp
+++ /dev/null
@@ -1,22 +0,0 @@
-class munin::client::darwin {
- file { "/usr/share/snmp/snmpd.conf":
- mode => 744,
- content => template("munin/darwin_snmpd.conf.erb"),
- group => 0,
- owner => root,
- }
- line{"startsnmpdno":
- file => "/etc/hostconfig",
- line => "SNMPSERVER=-NO-",
- ensure => 'absent',
- }
- line { "startsnmpdyes":
- file => "/etc/hostconfig",
- line => "SNMPSERVER=-YES-",
- notify => Exec["/sbin/SystemStarter start SNMP"],
- }
- exec{"/sbin/SystemStarter start SNMP":
- noop => false,
- }
- munin::register::snmp { $::fqdn: }
-}
diff --git a/manifests/client/debian.pp b/manifests/client/debian.pp
index e67ac26..49ee567 100644
--- a/manifests/client/debian.pp
+++ b/manifests/client/debian.pp
@@ -1,15 +1,9 @@
-class munin::client::debian inherits munin::client::package {
+# Install the munin client on debian
+class munin::client::debian inherits munin::client::base {
# the plugin will need that
- package { "iproute": ensure => installed }
+ ensure_packages(['iproute'])
- Service["munin-node"]{
- # sarge's munin-node init script has no status
- hasstatus => $::lsbdistcodename ? { sarge => false, default => true }
- }
- File["/etc/munin/munin-node.conf"]{
- content => template("munin/munin-node.conf.${::operatingsystem}.${::lsbdistcodename}"),
- }
# workaround bug in munin_node_configure
- plugin { "postfix_mailvolume": ensure => absent }
+ plugin { 'postfix_mailvolume': ensure => absent }
include munin::plugins::debian
}
diff --git a/manifests/client/gentoo.pp b/manifests/client/gentoo.pp
index e79f6b0..263fecd 100644
--- a/manifests/client/gentoo.pp
+++ b/manifests/client/gentoo.pp
@@ -1,8 +1,8 @@
-class munin::client::gentoo inherits munin::client::package {
+# install a munin client on gentoo
+class munin::client::gentoo inherits munin::client::base {
Package['munin-node'] {
- name => 'munin',
- category => 'net-analyzer',
+ name => 'net-analyzer/munin',
}
include munin::plugins::gentoo
diff --git a/manifests/client/openbsd.pp b/manifests/client/openbsd.pp
index cd21abf..09fb24f 100644
--- a/manifests/client/openbsd.pp
+++ b/manifests/client/openbsd.pp
@@ -1,60 +1,26 @@
-# currently we install munin on openbsd by targz
-# :(
-
+# generate a few missing things on openbsd
class munin::client::openbsd inherits munin::client::base {
- if $::operatingsystemrelease == '4.3' {
- file{'/usr/src/munin_openbsd.tar.gz':
- source => "puppet:///modules/munin/openbsd/package/munin_openbsd.tar.gz",
- owner => root,
- group => 0,
- mode => '0600';
- }
- exec{'extract_openbsd':
- command => 'cd /;tar xzf /usr/src/munin_openbsd.tar.gz',
- unless => 'test -d /opt/munin',
- require => File['/usr/src/munin_openbsd.tar.gz'],
- before => File['/var/run/munin'],
- }
- package{'p5-Compress-Zlib':
- ensure => installed,
- before => File['/var/run/munin'],
- }
- } else {
- package{'munin-node':
- ensure => installed,
- }
- }
- package{ [ 'p5-Crypt-SSLeay', 'p5-HTML-Parser', 'p5-HTML-Tagset', 'p5-HTTP-GHTTP',
- 'p5-LWP-UserAgent-Determined', 'p5-Net-SSLeay', 'p5-Net-Server',
- 'p5-URI', 'p5-libwww', 'pcre', 'curl' ]:
- ensure => installed,
- before => File['/var/run/munin'],
- }
- file{[ '/var/run/munin', '/var/log/munin' ]:
+ file{[ '/var/run/munin', '/var/log/munin-node' ]:
ensure => directory,
owner => root,
group => 0,
mode => '0755';
}
- $bin_loc = $::operatingsystemrelease ? {
- '4.3' => '/opt/munin/sbin/munin-node',
- default => '/usr/local/sbin/munin-node'
- }
openbsd::rc_local{'munin-node':
- binary => $bin_loc,
+ binary => '/usr/local/sbin/munin-node',
require => File['/var/run/munin'],
}
Service['munin-node']{
restart => '/bin/kill -HUP `/bin/cat /var/run/munin/munin-node.pid`',
stop => '/bin/kill `/bin/cat /var/run/munin/munin-node.pid`',
- start => $bin_loc,
+ start => '/usr/local/sbin/munin-node',
status => 'test -e /var/run/munin/munin-node.pid && (ps ax | egrep -q "^ *$(cat /var/run/munin/munin-node.pid).*munin-node")',
hasstatus => true,
hasrestart => true,
- require => [ File['/var/run/munin'], File['/var/log/munin'] ],
+ require => [ File['/var/run/munin'], File['/var/log/munin-node'] ],
}
cron{'clean_munin_logfile':
- command => 'rm /var/log/munin/munin-node.log; kill -HUP `cat /var/run/munin/munin-node.pid`',
+ command => 'rm /var/log/munin-node/munin-node.log; kill -HUP `cat /var/run/munin/munin-node.pid`',
minute => 0,
hour => 2,
weekday => 0,
diff --git a/manifests/client/package.pp b/manifests/client/package.pp
deleted file mode 100644
index 206ccc8..0000000
--- a/manifests/client/package.pp
+++ /dev/null
@@ -1,12 +0,0 @@
-class munin::client::package inherits munin::client::base {
- package { 'munin-node': ensure => installed }
- Service['munin-node']{
- require => Package[munin-node],
- }
- File['/etc/munin/munin-node.conf']{
- # this has to be installed before the package, so the postinst can
- # boot the munin-node without failure!
- before => Package['munin-node'],
- }
-}
-
diff --git a/manifests/client/params.pp b/manifests/client/params.pp
new file mode 100644
index 0000000..4473912
--- /dev/null
+++ b/manifests/client/params.pp
@@ -0,0 +1,19 @@
+# Set the parameters for the munin client
+class munin::client::params {
+ $user = 'root'
+
+ case $::osfamily {
+ 'OpenBSD': {
+ $group = '0'
+ $log_file = '/var/log/munin-node/munin-node.log'
+ }
+ 'Debian': {
+ $group = 'root'
+ $log_file = '/var/log/munin/munin-node.log'
+ }
+ default: {
+ $group = 'root'
+ $log_file = '/var/log/munin-node/munin-node.log'
+ }
+ }
+}
diff --git a/manifests/host.pp b/manifests/host.pp
index 05dcb5e..dd5720c 100644
--- a/manifests/host.pp
+++ b/manifests/host.pp
@@ -2,43 +2,47 @@
# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
# See LICENSE for the full license granted to you.
-class munin::host(
- $cgi_graphing = false,
- $export_tag = 'munin'
-) {
- package {"munin": ensure => installed, }
- include concat::setup
+# WARNING: this class should not be included directly. See the 'munin' class.
+class munin::host {
- Concat::Fragment <<| tag == $export_tag |>>
+ package {'munin': ensure => installed, }
+
+ Concat::Fragment <<| tag == $munin::export_tag |>>
concat::fragment{'munin.conf.header':
target => '/etc/munin/munin.conf',
source => [ "puppet:///modules/site_munin/config/host/${::fqdn}/munin.conf.header",
- "puppet:///modules/site_munin/config/host/munin.conf.header.${::operatingsystem}.${::lsbdistcodename}",
+ "puppet:///modules/site_munin/config/host/munin.conf.header.${::operatingsystem}.${::operatingsystemmajrelease}",
"puppet:///modules/site_munin/config/host/munin.conf.header.${::operatingsystem}",
- "puppet:///modules/site_munin/config/host/munin.conf.header",
- "puppet:///modules/munin/config/host/munin.conf.header.${::operatingsystem}.${::lsbdistcodename}",
+ 'puppet:///modules/site_munin/config/host/munin.conf.header',
+ "puppet:///modules/munin/config/host/munin.conf.header.${::operatingsystem}.${::operatingsystemmajrelease}",
"puppet:///modules/munin/config/host/munin.conf.header.${::operatingsystem}",
- "puppet:///modules/munin/config/host/munin.conf.header" ],
- order => 05,
+ 'puppet:///modules/munin/config/host/munin.conf.header' ],
+ order => 05,
}
- concat{ "/etc/munin/munin.conf":
- owner => root, group => 0, mode => 0644;
+ concat{ '/etc/munin/munin.conf':
+ owner => root,
+ group => 0,
+ mode => '0644',
}
include munin::plugins::muninhost
- if $munin::host::cgi_graphing {
- include munin::host::cgi
+ if $munin::cgi_graphing {
+ class {'munin::host::cgi':
+ owner => $munin::cgi_owner,
+ }
}
# from time to time we cleanup hanging munin-runs
- file{'/etc/cron.d/munin_kill':
- content => "4,34 * * * * root if $(ps ax | grep -v grep | grep -q munin-run); then killall munin-run; fi\n",
- owner => root, group => 0, mode => 0644;
+ cron { 'munin_kill':
+ command => 'if $(ps ax | grep -v grep | grep -q munin-run); then killall munin-run; fi',
+ minute => ['4', '34'],
+ user => 'root',
}
- if $munin::host::manage_shorewall {
+
+ if $munin::manage_shorewall {
include shorewall::rules::out::munin
}
}
diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp
index 0c11d32..9951a48 100644
--- a/manifests/host/cgi.pp
+++ b/manifests/host/cgi.pp
@@ -1,15 +1,27 @@
-class munin::host::cgi {
-
+# Set up a munin host using CGI rendering
+class munin::host::cgi(
+ $owner = 'os_default'
+) {
case $::operatingsystem {
debian,ubuntu: {
- $apache_user = 'www-data'
$document_root = '/var/www/munin'
}
default: {
- $apache_user = 'apache'
$document_root = '/var/www/html/munin'
}
}
+ if $owner == 'os_default' {
+ case $::operatingsystem {
+ debian,ubuntu: {
+ $apache_user = 'www-data'
+ }
+ default: {
+ $apache_user = 'apache'
+ }
+ }
+ } else {
+ $apache_user = $owner
+ }
exec{'set_modes_for_cgi':
command => "chgrp ${apache_user} /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find ${document_root}/* -maxdepth 1 -type d -exec chgrp -R ${apache_user} {} \; && find ${document_root}/* -maxdepth 1 -type d -exec chmod -R g+w {} \;",
@@ -18,11 +30,9 @@ class munin::host::cgi {
}
file{'/etc/logrotate.d/munin':
- source => [ "puppet:///modules/site_munin/config/host/${::fqdn}/logrotate",
- "puppet:///modules/site_munin/config/host/logrotate.${::operatingsystem}",
- "puppet:///modules/site_munin/config/host/logrotate",
- "puppet:///modules/munin/config/host/logrotate.${::operatingsystem}",
- "puppet:///modules/munin/config/host/logrotate" ],
- owner => root, group => 0, mode => 0644;
+ content => template("${module_name}/logrotate.conf.erb"),
+ owner => root,
+ group => 0,
+ mode => '0644',
}
}
diff --git a/manifests/init.pp b/manifests/init.pp
index b015521..367ba8f 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -4,7 +4,7 @@
# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
#
# Copyright 2008, Puzzle ITC GmbH
-# Marcel Härry haerry+puppet(at)puzzle.ch
+# Marcel Haerry haerry+puppet(at)puzzle.ch
# Simon Josi josi+puppet(at)puzzle.ch
#
# This program is free software; you can redistribute
@@ -12,5 +12,40 @@
# General Public License version 3 as published by
# the Free Software Foundation.
#
-# the port is a parameter so vservers can share
-# IP addresses and still be happy
+# Parameters:
+# $is_server - determines whether or not to install munin server. munin-node is
+# required for the server so it is always installed.
+# $export_tag - tag exported resources so that only the server targeted by that
+# tag will collect them. This can let you install multiple munin
+# servers.
+#
+# Client-specific parameters:
+# $allow, $host, $host_name, $port, $use_ssh, $manage_shorewall,
+# $shorewall_collector_source, $description, $munin_group
+#
+# Server-specific parameters:
+# $cgi_graphing, cgi_owner
+
+class munin (
+ $is_server = false,
+ $export_tag = 'munin',
+ $allow = [ '127.0.0.1' ],
+ $host = '*',
+ $host_name = $::fqdn,
+ $port = '4949',
+ $use_ssh = false,
+ $manage_shorewall = false,
+ $shorewall_collector_source = 'net',
+ $description = 'absent',
+ $munin_group = 'absent',
+ $cgi_graphing = false,
+ $cgi_owner = 'os_default',
+ $if_filter = 'eth\d+_\d+|sit0|virbr\d+_nic|vif\d+_\d+|veth\d+|vnet\d+|__tmp\d+',
+) {
+
+ include munin::client
+
+ if $is_server {
+ include munin::host
+ }
+}
diff --git a/manifests/plugin.pp b/manifests/plugin.pp
index ffe5452..50b861b 100644
--- a/manifests/plugin.pp
+++ b/manifests/plugin.pp
@@ -1,55 +1,43 @@
# configure a specific munin plugin
+#
+# We only manage the plugin if it is not set to absent.
+# A plugin (or its config) that should be removed should
+# be purged by the recursively managed plugins- or
+# config-directory. So we can safe a few resources being
+# managed.
define munin::plugin (
$ensure = 'present',
$script_path_in = '',
- $config = ''
+ $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 }
- $plugin = "/etc/munin/plugins/${name}"
- $plugin_conf = "/etc/munin/plugin-conf.d/${name}.conf"
+ if $ensure != 'absent' {
+ include munin::plugin::scriptpaths
+ include munin::plugins::setup
+ $real_script_path = $script_path_in ? {
+ '' => $munin::plugin::scriptpaths::script_path,
+ default => $script_path_in
+ }
+ $plugin_src = $ensure ? {
+ 'present' => $name,
+ default => $ensure
+ }
- include munin::plugins::setup
- case $ensure {
- 'absent': {
- file { $plugin: ensure => absent, }
+ file { "/etc/munin/plugins/${name}":
+ ensure => link,
+ target =>"${real_script_path}/${plugin_src}",
+ notify => Service['munin-node'];
}
- default: {
- $dep = $::kernel ? {
- OpenBSD => File['/var/run/munin'],
- default => Package['munin-node']
- }
- file { $plugin:
- ensure => "${real_script_path}/${plugin_src}",
- require => $dep,
- notify => Service['munin-node'];
+ if (str2bool($::selinux) == true) and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::operatingsystemmajrelease != '5')){
+ File["/etc/munin/plugins/${name}"]{
+ seltype => 'munin_etc_t',
}
- if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){
- File[$plugin]{
- seltype => 'munin_etc_t',
- }
- }
- }
- }
- 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",
- owner => root,
- group => 0,
- mode => '0640',
- }
- }
+ if !empty($config) {
+ file { "/etc/munin/plugin-conf.d/${name}.conf":
+ content => inline_template("[<%= @name %>]\n<%= Array(@config).join(\"\n\") %>\n"),
+ owner => root,
+ group => 0,
+ mode => '0640',
}
}
}
diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp
index cbf64fb..2ffd92e 100644
--- a/manifests/plugin/deploy.pp
+++ b/manifests/plugin/deploy.pp
@@ -3,7 +3,8 @@ define munin::plugin::deploy(
$ensure = 'present',
$source = '',
$config = '',
- $seltype = 'munin_exec_t'
+ $seltype = 'munin_unconfined_plugin_exec_t',
+ $register = true,
) {
$plugin_src = $ensure ? {
'present' => $name,
@@ -23,7 +24,7 @@ define munin::plugin::deploy(
mode => '0755';
}
- if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){
+ if (str2bool($::selinux) == true) and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::operatingsystemmajrelease > '5')){
File["munin_plugin_${name}"]{
seltype => $seltype,
}
@@ -36,9 +37,12 @@ define munin::plugin::deploy(
File["munin_plugin_${name}"]{
require => $basic_require,
}
- # register the plugin
- munin::plugin{$name:
- ensure => $ensure,
- config => $config
+
+ # register the plugin if required
+ if ($register) {
+ munin::plugin{$name:
+ ensure => $ensure,
+ config => $config
+ }
}
}
diff --git a/manifests/plugin/scriptpaths.pp b/manifests/plugin/scriptpaths.pp
index 2cad97b..62dd77b 100644
--- a/manifests/plugin/scriptpaths.pp
+++ b/manifests/plugin/scriptpaths.pp
@@ -1,12 +1,10 @@
+# Determine the script path for each OS
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" }
- openbsd: { $script_path = $::operatingsystemrelease ? {
- '4.3' => '/opt/munin/lib/plugins/',
- default => '/usr/local/libexec/munin/plugins/'
- } }
- default: { $script_path = "/usr/share/munin/plugins" }
+ gentoo: { $script_path = '/usr/libexec/munin/plugins' }
+ debian: { $script_path = '/usr/share/munin/plugins' }
+ centos: { $script_path = '/usr/share/munin/plugins' }
+ openbsd: { $script_path = '/usr/local/libexec/munin/plugins/' }
+ default: { $script_path = '/usr/share/munin/plugins' }
}
}
diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp
index c6b88ed..33cd84d 100644
--- a/manifests/plugins/base.pp
+++ b/manifests/plugins/base.pp
@@ -1,29 +1,33 @@
+# A basic set of plugins
class munin::plugins::base {
# setup basic plugins
munin::plugin {
- [ df, cpu, interrupts, load, memory, netstat, open_files,
- processes, swap, uptime, users, vmstat ]:
+ [ 'df', 'cpu', 'interrupts', 'load', 'memory', 'netstat', 'open_files',
+ 'processes', 'swap', 'uptime', 'users', 'vmstat' ]:
ensure => present,
}
file{'/etc/munin/plugin-conf.d/df':
content => "[df*]\nenv.exclude none unknown iso9660 squashfs udf romfs ramfs debugfs binfmt_misc rpc_pipefs fuse.gvfs-fuse-daemon\n",
- require => Munin::Plugin[df],
- owner => root, group => 0, mode => 0644;
+ require => Munin::Plugin['df'],
+ owner => 'root',
+ group => 0,
+ mode => '0644',
}
include munin::plugins::interfaces
case $::kernel {
openbsd: { include munin::plugins::openbsd }
linux: {
- case $vserver {
+ case $::vserver {
guest: { include munin::plugins::vserver }
default: { include munin::plugins::linux }
}
}
}
-
+
case $::virtual {
physical: { include munin::plugins::physical }
xen0: { include munin::plugins::dom0 }
+ default: { }
}
}
diff --git a/manifests/plugins/centos.pp b/manifests/plugins/centos.pp
deleted file mode 100644
index 60c706c..0000000
--- a/manifests/plugins/centos.pp
+++ /dev/null
@@ -1,3 +0,0 @@
-class munin::plugins::centos inherits munin::plugins::base {
- munin::plugin { users: ensure => present; }
-}
diff --git a/manifests/plugins/debian.pp b/manifests/plugins/debian.pp
index f756150..efa922b 100644
--- a/manifests/plugins/debian.pp
+++ b/manifests/plugins/debian.pp
@@ -1 +1,2 @@
+# Debian specific plugins
class munin::plugins::debian { }
diff --git a/manifests/plugins/djbdns.pp b/manifests/plugins/djbdns.pp
index c0a5163..de3936b 100644
--- a/manifests/plugins/djbdns.pp
+++ b/manifests/plugins/djbdns.pp
@@ -1,3 +1,4 @@
-class munin::plugins::djbdns {
- munin::plugin::deploy { "tinydns": }
+# Set up the djbdns plugin
+class munin::plugins::djbdns {
+ munin::plugin::deploy { 'tinydns': }
}
diff --git a/manifests/plugins/dom0.pp b/manifests/plugins/dom0.pp
index 44995fc..98aee1d 100644
--- a/manifests/plugins/dom0.pp
+++ b/manifests/plugins/dom0.pp
@@ -1,3 +1,4 @@
+# Set up plugins for a Xen dom0 host
class munin::plugins::dom0 {
munin::plugin::deploy {
[ 'xen', 'xen_cpu', 'xen_memory', 'xen_mem',
diff --git a/manifests/plugins/gentoo.pp b/manifests/plugins/gentoo.pp
index 27d4689..36f2370 100644
--- a/manifests/plugins/gentoo.pp
+++ b/manifests/plugins/gentoo.pp
@@ -1,4 +1,5 @@
-class munin::plugins::gentoo {
+# Set up the plugins for a gentoo host
+class munin::plugins::gentoo {
munin::plugin::deploy { 'gentoo_lastupdated':
config => "user portage\nenv.logfile /var/log/emerge.log\nenv.tail /usr/bin/tail\nenv.grep /bin/grep"
}
diff --git a/manifests/plugins/interfaces.pp b/manifests/plugins/interfaces.pp
index da89ed0..2bbc1c6 100644
--- a/manifests/plugins/interfaces.pp
+++ b/manifests/plugins/interfaces.pp
@@ -1,25 +1,21 @@
# handle if_ and if_err_ plugins
-class munin::plugins::interfaces {
+class munin::plugins::interfaces {
# filter out many of the useless interfaces that show up
- $real_ifs = reject(split($::interfaces, ' |,'), 'eth\d+_\d+|sit0|virbr\d+_nic|vif\d+_\d+|veth\d+|__tmp\d+')
- $ifs = regsubst($real_ifs, '(.+)', "if_\\1")
+ $real_ifs = reject(split($::interfaces, ' |,'), $munin::if_filter)
+ $ifs = prefix($real_ifs, 'if_')
- munin::plugin {
- $ifs: ensure => 'if_';
+ $if_err_plugin = $::operatingsystem ? {
+ 'openbsd' => 'if_errcoll_',
+ default => 'if_err_',
}
- case $::operatingsystem {
- openbsd: {
- $if_errs = regsubst($real_ifs, '(.+)', "if_errcoll_\\1")
- munin::plugin{
- $if_errs: ensure => 'if_errcoll_';
- }
- }
- default: {
- $if_errs = regsubst($real_ifs, '(.+)', "if_err_\\1")
- munin::plugin{
- $if_errs: ensure => 'if_err_';
- }
- }
+ $if_errs = prefix($real_ifs, $if_err_plugin)
+
+ munin::plugin { $ifs:
+ ensure => 'if_',
+ }
+
+ munin::plugin { $if_errs:
+ ensure => $if_err_plugin,
}
}
diff --git a/manifests/plugins/kvm.pp b/manifests/plugins/kvm.pp
index 7a1430f..650e5ef 100644
--- a/manifests/plugins/kvm.pp
+++ b/manifests/plugins/kvm.pp
@@ -1,3 +1,4 @@
+# Set up munin plugins for a KVM host
class munin::plugins::kvm {
munin::plugin::deploy {
[ 'kvm_cpu', 'kvm_mem', 'kvm_net' ]:;
diff --git a/manifests/plugins/linux.pp b/manifests/plugins/linux.pp
index a73de63..354d23c 100644
--- a/manifests/plugins/linux.pp
+++ b/manifests/plugins/linux.pp
@@ -1,8 +1,10 @@
-class munin::plugins::linux {
+# Set up plugins for a linux host
+class munin::plugins::linux {
munin::plugin {
- [ df_abs, forks, df_inode, irqstats, entropy, open_inodes ]:
+ [ 'df_abs', 'forks', 'df_inode', 'irqstats', 'entropy', 'open_inodes',
+ 'diskstats', 'proc_pri', 'threads', ]:
ensure => present;
- acpi:
+ 'acpi':
ensure => $::acpi_available;
}
}
diff --git a/manifests/plugins/muninhost.pp b/manifests/plugins/muninhost.pp
index e4fb87d..644adb6 100644
--- a/manifests/plugins/muninhost.pp
+++ b/manifests/plugins/muninhost.pp
@@ -1,3 +1,4 @@
-class munin::plugins::muninhost {
+# Set up the plugins for a munin host
+class munin::plugins::muninhost {
munin::plugin { ['munin_update', 'munin_graph']: }
}
diff --git a/manifests/plugins/openbsd.pp b/manifests/plugins/openbsd.pp
index b549994..c195a1d 100644
--- a/manifests/plugins/openbsd.pp
+++ b/manifests/plugins/openbsd.pp
@@ -1,6 +1,7 @@
-class munin::plugins::openbsd {
+# Set up the plugins for an openbsd host
+class munin::plugins::openbsd {
munin::plugin {
- [ memory_pools, memory_types ]:
+ [ 'memory_pools', 'memory_types' ]:
ensure => present,
}
}
diff --git a/manifests/plugins/physical.pp b/manifests/plugins/physical.pp
index a1c27a7..b04845c 100644
--- a/manifests/plugins/physical.pp
+++ b/manifests/plugins/physical.pp
@@ -1,5 +1,7 @@
-class munin::plugins::physical {
+# Set up the plugins for a physical machine
+class munin::plugins::physical {
case $::kernel {
- linux: { munin::plugin { iostat: } }
+ linux: { munin::plugin { 'iostat': } }
+ default: {}
}
}
diff --git a/manifests/plugins/selinux.pp b/manifests/plugins/selinux.pp
index d094f35..9e03f0a 100644
--- a/manifests/plugins/selinux.pp
+++ b/manifests/plugins/selinux.pp
@@ -1,3 +1,4 @@
+# SELinux specific plugins
class munin::plugins::selinux {
munin::plugin{ [ 'selinux_avcstat' ]: }
}
diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp
index 197b657..a3f3b22 100644
--- a/manifests/plugins/setup.pp
+++ b/manifests/plugins/setup.pp
@@ -1,14 +1,13 @@
+# Set up the munin plugins for a node
class munin::plugins::setup {
- # This is required for the munin-node service and package requirements below.
- include munin::client
-
file {
[ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]:
- ignore => 'snmp_*',
ensure => directory,
+ require => Package['munin-node'],
+ ignore => 'snmp_*',
checksum => mtime,
- recurse => true,
+ recurse => true,
purge => true,
force => true,
notify => Service['munin-node'],
@@ -22,16 +21,4 @@ class munin::plugins::setup {
group => 0,
mode => '0640';
}
- 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'],
- }
- }
- }
}
diff --git a/manifests/plugins/vserver.pp b/manifests/plugins/vserver.pp
index e3eec05..5dc6431 100644
--- a/manifests/plugins/vserver.pp
+++ b/manifests/plugins/vserver.pp
@@ -1,7 +1,7 @@
+# vserver specific plugins
class munin::plugins::vserver {
munin::plugin {
- [ netstat, processes ]:
+ [ 'netstat', 'processes' ]:
ensure => present;
}
}
-
diff --git a/manifests/register.pp b/manifests/register.pp
index 309c322..8c1ec61 100644
--- a/manifests/register.pp
+++ b/manifests/register.pp
@@ -1,10 +1,12 @@
+# Register a munin client
define munin::register (
- $host = $::fqdn,
- $port = '4949',
- $use_ssh = false,
- $description = 'absent',
- $config = [],
- $export_tag = 'munin'
+ $host = $::fqdn,
+ $port = '4949',
+ $use_ssh = false,
+ $description = 'absent',
+ $config = [],
+ $export_tag = 'munin',
+ $group = 'absent',
)
{
$fhost = $name
@@ -12,7 +14,7 @@ define munin::register (
@@concat::fragment{ "munin_client_${fhost}_${port}":
target => '/etc/munin/munin.conf',
- content => template("munin/client.erb"),
+ content => template('munin/client.erb'),
tag => $export_tag,
}
}
diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp
index 78c3e91..8d7ea56 100644
--- a/manifests/register/snmp.pp
+++ b/manifests/register/snmp.pp
@@ -1,21 +1,24 @@
+# Register a munin node with snmp enabled
define munin::register::snmp (
- $community = 'public',
+ $community = 'public',
$description = 'absent',
- $port = '4949',
- $host = $::fqdn
+ $port = '4949',
+ $host = $::fqdn,
+ $group = 'absent',
+ $version = '2',
) {
$fhost = $name
$client_type = 'snmp'
$config = [ 'use_node_name no' ]
exec { "munin_register_snmp_${fhost}":
- command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} --shell | sh",
- unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null",
+ command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} --snmpversion ${version} --shell | sh",
+ unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null",
}
@@concat::fragment{ "munin_snmp_${fhost}":
- target => '/etc/munin/munin.conf',
- content => template("munin/client.erb"),
- tag => 'munin',
+ target => '/etc/munin/munin.conf',
+ content => template('munin/client.erb'),
+ tag => 'munin',
}
}
diff --git a/manifests/remoteplugin.pp b/manifests/remoteplugin.pp
index 603cb66..dc03c76 100644
--- a/manifests/remoteplugin.pp
+++ b/manifests/remoteplugin.pp
@@ -1,16 +1,23 @@
-define munin::remoteplugin($ensure = "present", $source, $config = '') {
+# Configure a munin remote plugin
+define munin::remoteplugin(
+ $source,
+ $ensure = 'present',
+ $config = ''
+) {
case $ensure {
- "absent": { munin::plugin{ $name: ensure => absent } }
+ 'absent': { munin::plugin{ $name: ensure => absent } }
default: {
file {
"/var/lib/puppet/modules/munin/plugins/${name}":
source => $source,
- mode => 0755, owner => root, group => 0;
+ mode => '0755',
+ owner => root,
+ group => 0,
}
munin::plugin { $name:
- ensure => $ensure,
- config => $config,
- script_path_in => "/var/lib/puppet/modules/munin/plugins",
+ ensure => $ensure,
+ config => $config,
+ script_path_in => '/var/lib/puppet/modules/munin/plugins',
}
}
}
diff --git a/manifests/snmp_collector.pp b/manifests/snmp_collector.pp
index 0f8318a..4ff3bf9 100644
--- a/manifests/snmp_collector.pp
+++ b/manifests/snmp_collector.pp
@@ -1,14 +1,17 @@
+# Set up munin as an SNMP collector
class munin::snmp_collector{
- file {
- "/var/lib/puppet/modules/munin/create_snmp_links":
- source => "puppet:///modules/munin/create_snmp_links.sh",
- mode => 755, owner => root, group => 0;
- }
+ file {
+ '/var/lib/puppet/modules/munin/create_snmp_links':
+ source => 'puppet:///modules/munin/create_snmp_links.sh',
+ mode => '0755',
+ owner => root,
+ group => 0,
+ }
- exec { "create_snmp_links":
- command => "/var/lib/puppet/modules/munin/create_snmp_links /var/lib/puppet/modules/munin/nodes",
- require => File["snmp_links"],
- timeout => "2048",
- schedule => daily
+ exec { 'create_snmp_links':
+ command => '/var/lib/puppet/modules/munin/create_snmp_links /var/lib/puppet/modules/munin/nodes',
+ require => File['snmp_links'],
+ timeout => '2048',
+ schedule => daily,
}
}