From 1893960c1babb6a261cc6fc399231e9c0644a104 Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 29 Sep 2009 22:51:15 +0200 Subject: refactor everything into its own file --- manifests/client.pp | 171 ---------------------------- manifests/client/base.pp | 23 ++++ manifests/client/centos.pp | 3 + manifests/client/darwin.pp | 21 ++++ manifests/client/debian.pp | 15 +++ manifests/client/gentoo.pp | 9 ++ manifests/client/openbsd.pp | 43 +++++++ manifests/client/package.pp | 11 ++ manifests/host.pp | 36 +----- manifests/host/cgi.pp | 16 +++ manifests/init.pp | 7 -- manifests/plugin.pp | 236 --------------------------------------- manifests/plugins/apache.pp | 6 + manifests/plugins/base.pp | 49 ++++++++ manifests/plugins/debian.pp | 4 + manifests/plugins/deploy.pp | 37 ++++++ manifests/plugins/djbdns.pp | 3 + manifests/plugins/dom0.pp | 7 ++ manifests/plugins/gentoo.pp | 3 + manifests/plugins/interfaces.pp | 22 ++++ manifests/plugins/linux.pp | 10 ++ manifests/plugins/muninhost.pp | 4 + manifests/plugins/nagios.pp | 8 ++ manifests/plugins/openbsd.pp | 13 +++ manifests/plugins/physical.pp | 5 + manifests/plugins/scriptpaths.pp | 9 ++ manifests/plugins/selinux.pp | 4 + manifests/plugins/vserver.pp | 7 ++ manifests/register.pp | 17 +++ manifests/register_snmp.pp | 21 ++++ manifests/remoteplugin.pp | 18 +++ manifests/snmp_collector.pp | 14 +++ 32 files changed, 403 insertions(+), 449 deletions(-) create mode 100644 manifests/client/base.pp create mode 100644 manifests/client/centos.pp create mode 100644 manifests/client/darwin.pp create mode 100644 manifests/client/debian.pp create mode 100644 manifests/client/gentoo.pp create mode 100644 manifests/client/openbsd.pp create mode 100644 manifests/client/package.pp create mode 100644 manifests/host/cgi.pp create mode 100644 manifests/plugins/apache.pp create mode 100644 manifests/plugins/base.pp create mode 100644 manifests/plugins/debian.pp create mode 100644 manifests/plugins/deploy.pp create mode 100644 manifests/plugins/djbdns.pp create mode 100644 manifests/plugins/dom0.pp create mode 100644 manifests/plugins/gentoo.pp create mode 100644 manifests/plugins/interfaces.pp create mode 100644 manifests/plugins/linux.pp create mode 100644 manifests/plugins/muninhost.pp create mode 100644 manifests/plugins/nagios.pp create mode 100644 manifests/plugins/openbsd.pp create mode 100644 manifests/plugins/physical.pp create mode 100644 manifests/plugins/scriptpaths.pp create mode 100644 manifests/plugins/selinux.pp create mode 100644 manifests/plugins/vserver.pp create mode 100644 manifests/register.pp create mode 100644 manifests/register_snmp.pp create mode 100644 manifests/remoteplugin.pp create mode 100644 manifests/snmp_collector.pp diff --git a/manifests/client.pp b/manifests/client.pp index 7894e2f..bf49f44 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -16,7 +16,6 @@ class munin::client { openbsd: { include munin::client::openbsd } darwin: { include munin::client::darwin } debian,ubuntu: { include munin::client::debian } - centos: { include munin::client::centos } gentoo: { include munin::client::gentoo } default: { include munin::client::base } } @@ -24,173 +23,3 @@ class munin::client { include shorewall::rules::munin } } - -define munin::register() -{ - $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } - $munin_host_real = $munin_host ? { - '' => $fqdn, - 'fqdn' => $fqdn, - default => $munin_host - } - - @@file { "${NODESDIR}/${name}_${munin_port_real}": - ensure => present, - content => template("munin/defaultclient.erb"), - tag => 'munin', - } -} - -# snmp_testplugin: the plugin we use to test if it's set -define munin::register_snmp( - $snmpd_testplugin = 'load' -) -{ - $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } - $munin_host_real = $munin_host ? { - '' => '*', - 'fqdn' => '*', - default => $munin_host - } - exec{"register_snmp_munin_for_${name}": - command => "munin-node-configure-snmp ${name} | sh", - unless => "test -e /etc/munin/plugins/snmp_${name}_${snmpd_testplugin}", - } - @@file { "munin_snmp_${name}": path => "${NODESDIR}/${name}", - ensure => present, - content => template("munin/snmpclient.erb"), - tag => 'munin', - } -} - -class munin::client::base { - service { 'munin-node': - ensure => running, - enable => true, - hasstatus => true, - hasrestart => true, - } - file {'/etc/munin/': - ensure => directory, - mode => 0755, owner => root, group => 0; - } - $real_munin_allow = $munin_allow ? { - '' => '127.0.0.1', - default => $munin_allow - } - file {'/etc/munin/munin-node.conf': - content => template("munin/munin-node.conf.$operatingsystem"), - notify => Service['munin-node'], - mode => 0644, owner => root, group => 0, - } - munin::register { $fqdn: } - include munin::plugins::base -} - -# currently we install munin on openbsd by targz -# :( -class munin::client::openbsd inherits munin::client::base { - file{'/usr/src/munin_openbsd.tar.gz': - source => "puppet://$server/munin/openbsd/package/munin_openbsd.tar.gz", - owner => root, group => 0, mode => 0600; - } - package{ [ 'p5-Compress-Zlib', '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'], - } - 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'], - } - file{[ '/var/run/munin', '/var/log/munin' ]: - ensure => directory, - require => Exec['extract_openbsd'], - owner => root, group => 0, mode => 0755; - } - openbsd::add_to_rc_local{'munin-node': - binary => '/opt/munin/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 => '/opt/munin/sbin/munin-node', - hasstatus => false, - hasrestart => false, - require => [ File['/var/run/munin'], File['/var/log/munin'] ], - } - - cron{'clean_munin_logfile': - command => 'rm /var/log/munin/munin-node.log; kill -HUP `cat /var/run/munin/munin-node.pid`', - minute => 0, - hour => 2, - weekday => 0, - } -} - -class munin::client::darwin { - file { "/usr/share/snmp/snmpd.conf": - mode => 744, - content => template("munin/darwin_snmpd.conf.erb"), - group => 0, - owner => root, - } - delete_matching_line{"startsnmpdno": - file => "/etc/hostconfig", - pattern => "SNMPSERVER=-NO-", - } - 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: } -} - -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'], - } -} - -class munin::client::debian inherits munin::client::package { - # the plugin will need that - package { "iproute": ensure => installed } - - 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 } - include munin::plugins::debian -} - -class munin::client::gentoo inherits munin::client::package { - Package['munin-node'] { - name => 'munin', - category => 'net-analyzer', - } - - - include munin::plugins::gentoo -} - -class munin::client::centos inherits munin::client::package { - include munin::plugins::centos -} diff --git a/manifests/client/base.pp b/manifests/client/base.pp new file mode 100644 index 0000000..1f72e7e --- /dev/null +++ b/manifests/client/base.pp @@ -0,0 +1,23 @@ +class munin::client::base { + service { 'munin-node': + ensure => running, + enable => true, + hasstatus => true, + hasrestart => true, + } + file {'/etc/munin/': + ensure => directory, + mode => 0755, owner => root, group => 0; + } + $real_munin_allow = $munin_allow ? { + '' => '127.0.0.1', + default => $munin_allow + } + file {'/etc/munin/munin-node.conf': + content => template("munin/munin-node.conf.$operatingsystem"), + notify => Service['munin-node'], + mode => 0644, owner => root, group => 0, + } + munin::register { $fqdn: } + include munin::plugins::base +} diff --git a/manifests/client/centos.pp b/manifests/client/centos.pp new file mode 100644 index 0000000..46a7e3f --- /dev/null +++ b/manifests/client/centos.pp @@ -0,0 +1,3 @@ +class munin::client::centos inherits munin::client::package { + include munin::plugins::centos +} diff --git a/manifests/client/darwin.pp b/manifests/client/darwin.pp new file mode 100644 index 0000000..f6fc95f --- /dev/null +++ b/manifests/client/darwin.pp @@ -0,0 +1,21 @@ +class munin::client::darwin { + file { "/usr/share/snmp/snmpd.conf": + mode => 744, + content => template("munin/darwin_snmpd.conf.erb"), + group => 0, + owner => root, + } + delete_matching_line{"startsnmpdno": + file => "/etc/hostconfig", + pattern => "SNMPSERVER=-NO-", + } + 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 new file mode 100644 index 0000000..a6d677e --- /dev/null +++ b/manifests/client/debian.pp @@ -0,0 +1,15 @@ +class munin::client::debian inherits munin::client::package { + # the plugin will need that + package { "iproute": ensure => installed } + + 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 } + include munin::plugins::debian +} diff --git a/manifests/client/gentoo.pp b/manifests/client/gentoo.pp new file mode 100644 index 0000000..761742e --- /dev/null +++ b/manifests/client/gentoo.pp @@ -0,0 +1,9 @@ +class munin::client::gentoo inherits munin::client::package { + Package['munin-node'] { + name => 'munin', + category => 'net-analyzer', + } + + + include munin::plugins::gentoo +} diff --git a/manifests/client/openbsd.pp b/manifests/client/openbsd.pp new file mode 100644 index 0000000..303acd7 --- /dev/null +++ b/manifests/client/openbsd.pp @@ -0,0 +1,43 @@ +# currently we install munin on openbsd by targz +# :( +class munin::client::openbsd inherits munin::client::base { + file{'/usr/src/munin_openbsd.tar.gz': + source => "puppet://$server/munin/openbsd/package/munin_openbsd.tar.gz", + owner => root, group => 0, mode => 0600; + } + package{ [ 'p5-Compress-Zlib', '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'], + } + 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'], + } + file{[ '/var/run/munin', '/var/log/munin' ]: + ensure => directory, + require => Exec['extract_openbsd'], + owner => root, group => 0, mode => 0755; + } + openbsd::add_to_rc_local{'munin-node': + binary => '/opt/munin/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 => '/opt/munin/sbin/munin-node', + hasstatus => false, + hasrestart => false, + require => [ File['/var/run/munin'], File['/var/log/munin'] ], + } + + cron{'clean_munin_logfile': + command => 'rm /var/log/munin/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 new file mode 100644 index 0000000..84fcf5c --- /dev/null +++ b/manifests/client/package.pp @@ -0,0 +1,11 @@ +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/host.pp b/manifests/host.pp index 235e07c..9251516 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -19,7 +19,7 @@ class munin::host } concatenated_file { "/etc/munin/munin.conf": - dir => $NODESDIR, + dir => '/var/lib/puppet/modules/munin/nodes', header => "/etc/munin/munin.conf.header", } @@ -44,37 +44,3 @@ class munin::host include shorewall::rules::out::munin } } - -class munin::host::cgi { - exec{'set_modes_for_cgi': - command => 'chgrp apache /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/html/munin/* -maxdepth 1 -type d -exec chgrp -R apache {} \; && find /var/www/html/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', - refreshonly => true, - subscribe => File['/etc/munin/munin.conf.header'], - } - - file{'/etc/logrotate.d/munin': - source => [ "puppet://$server/files/munin/config/host/${fqdn}/logrotate", - "puppet://$server/files/munin/config/host/logrotate.$operatingsystem", - "puppet://$server/files/munin/config/host/logrotate", - "puppet://$server/munin/config/host/logrotate.$operatingsystem", - "puppet://$server/munin/config/host/logrotate" ], - owner => root, group => 0, mode => 0644; - } -} - -class munin::snmp_collector -{ - - file { - "/var/lib/puppet/modules/munin/create_snmp_links": - source => "puppet://$server/munin/create_snmp_links.sh", - mode => 755, owner => root, group => 0; - } - - exec { "create_snmp_links": - command => "/var/lib/puppet/modules/munin/create_snmp_links $NODESDIR", - require => File["snmp_links"], - timeout => "2048", - schedule => daily - } -} diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp new file mode 100644 index 0000000..7fdb281 --- /dev/null +++ b/manifests/host/cgi.pp @@ -0,0 +1,16 @@ +class munin::host::cgi { + exec{'set_modes_for_cgi': + command => 'chgrp apache /var/log/munin /var/log/munin/munin-graph.log && chmod g+w /var/log/munin /var/log/munin/munin-graph.log && find /var/www/html/munin/* -maxdepth 1 -type d -exec chgrp -R apache {} \; && find /var/www/html/munin/* -maxdepth 1 -type d -exec chmod -R g+w {} \;', + refreshonly => true, + subscribe => File['/etc/munin/munin.conf.header'], + } + + file{'/etc/logrotate.d/munin': + source => [ "puppet://$server/files/munin/config/host/${fqdn}/logrotate", + "puppet://$server/files/munin/config/host/logrotate.$operatingsystem", + "puppet://$server/files/munin/config/host/logrotate", + "puppet://$server/munin/config/host/logrotate.$operatingsystem", + "puppet://$server/munin/config/host/logrotate" ], + owner => root, group => 0, mode => 0644; + } +} diff --git a/manifests/init.pp b/manifests/init.pp index b0c2ba1..e5a92af 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -15,15 +15,8 @@ # the port is a parameter so vservers can share # IP addresses and still be happy -# Define where the individual nodes' configs are stored -$NODESDIR="/var/lib/puppet/modules/munin/nodes" - modules_dir { [ "munin", "munin/nodes", "munin/plugins" ]: } -import "host.pp" -import "client.pp" -import "plugin.pp" - case $operatingsystem { debian,ubuntu: { include assert_lsbdistcodename } } diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 8d739a8..0e83e04 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -3,19 +3,6 @@ # See LICENSE for the full license granted to you. # adapted and improved by admin(at)immerda.ch - -### 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" } - openbsd: { $script_path = "/opt/munin/lib/plugins/" } - default: { $script_path = "/usr/share/munin/plugins" } - } -} - ### defines define munin::plugin ( @@ -76,226 +63,3 @@ define munin::plugin ( } } } - -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", - } - } - } -} -define munin::plugin::deploy ($source = '', $ensure = 'present', $config = '') { - $plugin_src = $ensure ? { - 'present' => $name, - 'absent' => $name, - default => $ensure - } - $real_source = $source ? { - '' => "munin/plugins/$plugin_src", - default => $source - } - include munin::plugin::scriptpaths - file { "munin_plugin_${name}": - path => "$munin::plugin::scriptpaths::script_path/${name}", - source => "puppet://$server/$real_source", - 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 => [ $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 } - } -} - -### clases for plugins - -class munin::plugins::base { - file { - [ '/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'], - } - - 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 } - default: { - include munin::plugins::linux - } - } - } - } - case $virtual { - physical: { include munin::plugins::physical } - xen0: { include munin::plugins::dom0 } - xenu: { include munin::plugins::domU } - } -} - -# handle if_ and if_err_ plugins -class munin::plugins::interfaces inherits munin::plugins::base { - - $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; - } - - include munin::plugins::interfaces -} - -class munin::plugins::debian inherits munin::plugins::base { - 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; - } -} - -class munin::plugins::gentoo inherits munin::plugins::base { - munin::plugin::deploy { "gentoo_lastupdated": config => "user portage\nenv.logfile /var/log/emerge.log\nenv.tail /usr/bin/tail\nenv.grep /bin/grep"} -} - -class munin::plugins::centos inherits munin::plugins::base { -} - - - -class munin::plugins::dom0 inherits munin::plugins::physical { - munin::plugin::deploy { "xen": config => "user root"} - munin::plugin::deploy { "xen-cpu": config => "user root"} - munin::plugin::deploy { "xen_memory": config => "user root"} - munin::plugin::deploy { "xen_vbd": config => "user root"} - munin::plugin::deploy { "xen_traffic_all": config => "user root"} -} - -class munin::plugins::physical inherits munin::plugins::base { - case $kernel { - linux: { munin::plugin { iostat: } } - } -} - -class munin::plugins::muninhost inherits munin::plugins::base { - munin::plugin { munin_update: } - munin::plugin { munin_graph: } -} - -class munin::plugins::domU inherits munin::plugins::base { } - -class munin::plugins::djbdns inherits munin::plugins::base { - munin::plugin::deploy { "tinydns": } -} - -class munin::plugins::apache inherits munin::plugins::base { - munin::plugin{ "apache_accesses": } - munin::plugin{ "apache_processes": } - munin::plugin{ "apache_volume": } - munin::plugin::deploy { "apache_activity": } -} - -class munin::plugins::selinux inherits munin::plugins::base { - munin::plugin::deploy { "selinuxenforced": } - munin::plugin::deploy { "selinux_avcstats": } -} - -class munin::plugins::nagios inherits munin::plugins::base { - munin::plugin::deploy { - nagios_hosts: config => 'user root'; - nagios_svc: config => 'user root'; - nagios_perf_hosts: ensure => nagios_perf_, config => 'user root'; - nagios_perf_svc: ensure => nagios_perf_, config => 'user root'; - } -} diff --git a/manifests/plugins/apache.pp b/manifests/plugins/apache.pp new file mode 100644 index 0000000..ee90de8 --- /dev/null +++ b/manifests/plugins/apache.pp @@ -0,0 +1,6 @@ +class munin::plugins::apache inherits munin::plugins::base { + munin::plugin{ "apache_accesses": } + munin::plugin{ "apache_processes": } + munin::plugin{ "apache_volume": } + munin::plugin::deploy { "apache_activity": } +} diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp new file mode 100644 index 0000000..9f47f6b --- /dev/null +++ b/manifests/plugins/base.pp @@ -0,0 +1,49 @@ +class munin::plugins::base { + file { + [ '/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'], + } + + 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 } + default: { + include munin::plugins::linux + } + } + } + } + case $virtual { + physical: { include munin::plugins::physical } + xen0: { include munin::plugins::dom0 } + } diff --git a/manifests/plugins/debian.pp b/manifests/plugins/debian.pp new file mode 100644 index 0000000..f239989 --- /dev/null +++ b/manifests/plugins/debian.pp @@ -0,0 +1,4 @@ +class munin::plugins::debian inherits munin::plugins::base { + munin::plugin { apt_all: ensure => present; } +} + diff --git a/manifests/plugins/deploy.pp b/manifests/plugins/deploy.pp new file mode 100644 index 0000000..24ac3d3 --- /dev/null +++ b/manifests/plugins/deploy.pp @@ -0,0 +1,37 @@ +define munin::plugin::deploy ($source = '', $ensure = 'present', $config = '') { + $plugin_src = $ensure ? { + 'present' => $name, + 'absent' => $name, + default => $ensure + } + $real_source = $source ? { + '' => "munin/plugins/$plugin_src", + default => $source + } + include munin::plugin::scriptpaths + file { "munin_plugin_${name}": + path => "$munin::plugin::scriptpaths::script_path/${name}", + source => "puppet://$server/$real_source", + 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 => [ $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 } + } +} diff --git a/manifests/plugins/djbdns.pp b/manifests/plugins/djbdns.pp new file mode 100644 index 0000000..37d8ed6 --- /dev/null +++ b/manifests/plugins/djbdns.pp @@ -0,0 +1,3 @@ +class munin::plugins::djbdns inherits munin::plugins::base { + munin::plugin::deploy { "tinydns": } +} diff --git a/manifests/plugins/dom0.pp b/manifests/plugins/dom0.pp new file mode 100644 index 0000000..276dc9f --- /dev/null +++ b/manifests/plugins/dom0.pp @@ -0,0 +1,7 @@ +class munin::plugins::dom0 inherits munin::plugins::physical { + munin::plugin::deploy { "xen": config => "user root"} + munin::plugin::deploy { "xen-cpu": config => "user root"} + munin::plugin::deploy { "xen_memory": config => "user root"} + munin::plugin::deploy { "xen_vbd": config => "user root"} + munin::plugin::deploy { "xen_traffic_all": config => "user root"} +} diff --git a/manifests/plugins/gentoo.pp b/manifests/plugins/gentoo.pp new file mode 100644 index 0000000..81d0e6b --- /dev/null +++ b/manifests/plugins/gentoo.pp @@ -0,0 +1,3 @@ +class munin::plugins::gentoo inherits munin::plugins::base { + 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 new file mode 100644 index 0000000..99b85ba --- /dev/null +++ b/manifests/plugins/interfaces.pp @@ -0,0 +1,22 @@ +# handle if_ and if_err_ plugins +class munin::plugins::interfaces inherits munin::plugins::base { + + $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_"; + } + } + } +} diff --git a/manifests/plugins/linux.pp b/manifests/plugins/linux.pp new file mode 100644 index 0000000..c7beb59 --- /dev/null +++ b/manifests/plugins/linux.pp @@ -0,0 +1,10 @@ +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; + } + + include munin::plugins::interfaces +} diff --git a/manifests/plugins/muninhost.pp b/manifests/plugins/muninhost.pp new file mode 100644 index 0000000..2af4897 --- /dev/null +++ b/manifests/plugins/muninhost.pp @@ -0,0 +1,4 @@ +class munin::plugins::muninhost inherits munin::plugins::base { + munin::plugin { munin_update: } + munin::plugin { munin_graph: } +} diff --git a/manifests/plugins/nagios.pp b/manifests/plugins/nagios.pp new file mode 100644 index 0000000..93a261c --- /dev/null +++ b/manifests/plugins/nagios.pp @@ -0,0 +1,8 @@ +class munin::plugins::nagios inherits munin::plugins::base { + munin::plugin::deploy { + nagios_hosts: config => 'user root'; + nagios_svc: config => 'user root'; + nagios_perf_hosts: ensure => nagios_perf_, config => 'user root'; + nagios_perf_svc: ensure => nagios_perf_, config => 'user root'; + } +} diff --git a/manifests/plugins/openbsd.pp b/manifests/plugins/openbsd.pp new file mode 100644 index 0000000..67cf32d --- /dev/null +++ b/manifests/plugins/openbsd.pp @@ -0,0 +1,13 @@ +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, + } + +} diff --git a/manifests/plugins/physical.pp b/manifests/plugins/physical.pp new file mode 100644 index 0000000..6706711 --- /dev/null +++ b/manifests/plugins/physical.pp @@ -0,0 +1,5 @@ +class munin::plugins::physical inherits munin::plugins::base { + case $kernel { + linux: { munin::plugin { iostat: } } + } +} diff --git a/manifests/plugins/scriptpaths.pp b/manifests/plugins/scriptpaths.pp new file mode 100644 index 0000000..ebaa6fa --- /dev/null +++ b/manifests/plugins/scriptpaths.pp @@ -0,0 +1,9 @@ +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 = "/opt/munin/lib/plugins/" } + default: { $script_path = "/usr/share/munin/plugins" } + } +} diff --git a/manifests/plugins/selinux.pp b/manifests/plugins/selinux.pp new file mode 100644 index 0000000..6affc86 --- /dev/null +++ b/manifests/plugins/selinux.pp @@ -0,0 +1,4 @@ +class munin::plugins::selinux inherits munin::plugins::base { + munin::plugin::deploy { "selinuxenforced": } + munin::plugin::deploy { "selinux_avcstats": } +} diff --git a/manifests/plugins/vserver.pp b/manifests/plugins/vserver.pp new file mode 100644 index 0000000..bce28a1 --- /dev/null +++ b/manifests/plugins/vserver.pp @@ -0,0 +1,7 @@ +class munin::plugins::vserver inherits munin::plugins::base { + munin::plugin { + [ netstat, processes ]: + ensure => present; + } +} + diff --git a/manifests/register.pp b/manifests/register.pp new file mode 100644 index 0000000..e1271e1 --- /dev/null +++ b/manifests/register.pp @@ -0,0 +1,17 @@ +define munin::register() +{ + $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } + $munin_host_real = $munin_host ? { + '' => $fqdn, + 'fqdn' => $fqdn, + default => $munin_host + } + + @@file { "/var/lib/puppet/modules/munin/nodes/${name}_${munin_port_real}": + ensure => present, + content => template("munin/defaultclient.erb"), + tag => 'munin', + } +} + + diff --git a/manifests/register_snmp.pp b/manifests/register_snmp.pp new file mode 100644 index 0000000..e74ba44 --- /dev/null +++ b/manifests/register_snmp.pp @@ -0,0 +1,21 @@ +# snmp_testplugin: the plugin we use to test if it's set +define munin::register_snmp( + $snmpd_testplugin = 'load' +) +{ + $munin_port_real = $munin_port ? { '' => 4949, default => $munin_port } + $munin_host_real = $munin_host ? { + '' => '*', + 'fqdn' => '*', + default => $munin_host + } + exec{"register_snmp_munin_for_${name}": + command => "munin-node-configure-snmp ${name} | sh", + unless => "test -e /etc/munin/plugins/snmp_${name}_${snmpd_testplugin}", + } + @@file { "munin_snmp_${name}": path => "/var/lib/puppet/modules/munin/nodes/${name}", + ensure => present, + content => template("munin/snmpclient.erb"), + tag => 'munin', + } +} diff --git a/manifests/remoteplugin.pp b/manifests/remoteplugin.pp new file mode 100644 index 0000000..4bca235 --- /dev/null +++ b/manifests/remoteplugin.pp @@ -0,0 +1,18 @@ +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", + } + } + } +} + diff --git a/manifests/snmp_collector.pp b/manifests/snmp_collector.pp new file mode 100644 index 0000000..53a860f --- /dev/null +++ b/manifests/snmp_collector.pp @@ -0,0 +1,14 @@ +class munin::snmp_collector{ + file { + "/var/lib/puppet/modules/munin/create_snmp_links": + source => "puppet://$server/munin/create_snmp_links.sh", + mode => 755, 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 + } +} -- cgit v1.2.3