From dab730ed6b0667d4356c0e8e21e37719ea977a93 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 15 Jul 2010 20:41:39 +0200 Subject: fixing weird class setup we had some weird class setup which caused some problems on 2.6 (see puppet bug #4242 for more info). This commit cleans that weird setup up and decouples a lot of things. --- manifests/plugin.pp | 2 ++ manifests/plugins/apache.pp | 8 ++---- manifests/plugins/base.pp | 63 +++++++++++++---------------------------- manifests/plugins/debian.pp | 3 +- manifests/plugins/djbdns.pp | 2 +- manifests/plugins/dom0.pp | 14 ++++----- manifests/plugins/gentoo.pp | 6 ++-- manifests/plugins/interfaces.pp | 32 ++++++++++----------- manifests/plugins/linux.pp | 16 +++++------ manifests/plugins/muninhost.pp | 5 ++-- manifests/plugins/openbsd.pp | 17 ++++------- manifests/plugins/physical.pp | 8 +++--- manifests/plugins/selinux.pp | 5 ++-- manifests/plugins/setup.pp | 27 ++++++++++++++++++ manifests/plugins/vserver.pp | 10 +++---- 15 files changed, 104 insertions(+), 114 deletions(-) create mode 100644 manifests/plugins/setup.pp diff --git a/manifests/plugin.pp b/manifests/plugin.pp index cdaa17d..52c77c2 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -16,6 +16,8 @@ define munin::plugin ( $plugin_src = $ensure ? { "present" => $name, default => $ensure } $plugin = "/etc/munin/plugins/$name" $plugin_conf = "/etc/munin/plugin-conf.d/$name.conf" + + include munin::plugins::setup case $ensure { "absent": { file { $plugin: ensure => absent, } diff --git a/manifests/plugins/apache.pp b/manifests/plugins/apache.pp index ee90de8..b3e7634 100644 --- a/manifests/plugins/apache.pp +++ b/manifests/plugins/apache.pp @@ -1,6 +1,4 @@ -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::apache { + munin::plugin{ [ 'apache_accesses', 'apache_processes',' apache_volume' ]: } + munin::plugin::deploy { "apache_activity": } } diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp index 4658acc..bfccae5 100644 --- a/manifests/plugins/base.pp +++ b/manifests/plugins/base.pp @@ -1,50 +1,25 @@ class munin::plugins::base { - file { - [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: - source => "puppet://$server/modules/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 - ]: + # setup basic plugins + munin::plugin { + [ df, cpu, interrupts, load, memory, netstat, open_files, + processes, swap, uptime, users, vmstat ]: ensure => present, - } - include munin::plugins::interfaces + } + 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 } + case $kernel { + openbsd: { include munin::plugins::openbsd } + 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 index 6d2faef..f756150 100644 --- a/manifests/plugins/debian.pp +++ b/manifests/plugins/debian.pp @@ -1,2 +1 @@ -class munin::plugins::debian inherits munin::plugins::base { -} +class munin::plugins::debian { } diff --git a/manifests/plugins/djbdns.pp b/manifests/plugins/djbdns.pp index 37d8ed6..c0a5163 100644 --- a/manifests/plugins/djbdns.pp +++ b/manifests/plugins/djbdns.pp @@ -1,3 +1,3 @@ -class munin::plugins::djbdns inherits munin::plugins::base { +class munin::plugins::djbdns { munin::plugin::deploy { "tinydns": } } diff --git a/manifests/plugins/dom0.pp b/manifests/plugins/dom0.pp index 8d919c3..3be3e3f 100644 --- a/manifests/plugins/dom0.pp +++ b/manifests/plugins/dom0.pp @@ -1,9 +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_mem": config => "user root"} - munin::plugin::deploy { "xen_vm": config => "user root"} - munin::plugin::deploy { "xen_vbd": config => "user root"} - munin::plugin::deploy { "xen_traffic_all": config => "user root"} +class munin::plugins::dom0 { + munin::plugin::deploy { + [ 'xen', 'xen-cpu', 'xen_memory', 'xen_mem', + 'xen_vm', 'xen_vbd' 'xen_traffic_all' ]: + config => 'user root'; + } } diff --git a/manifests/plugins/gentoo.pp b/manifests/plugins/gentoo.pp index 81d0e6b..25c1626 100644 --- a/manifests/plugins/gentoo.pp +++ b/manifests/plugins/gentoo.pp @@ -1,3 +1,5 @@ -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::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 df0828c..e0744a0 100644 --- a/manifests/plugins/interfaces.pp +++ b/manifests/plugins/interfaces.pp @@ -1,22 +1,22 @@ # handle if_ and if_err_ plugins -class munin::plugins::interfaces inherits munin::plugins::base { +class munin::plugins::interfaces { - $ifs = gsub(split($interfaces, " |,"), "(.+)", "if_\\1") - munin::plugin { + $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_"; + } } - 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_"; - } - } + 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 index 86696cc..30e0af6 100644 --- a/manifests/plugins/linux.pp +++ b/manifests/plugins/linux.pp @@ -1,10 +1,8 @@ -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::linux { + munin::plugin { + [ df_abs, forks, df_inode, irqstats, entropy, open_inodes ]: + ensure => present; + acpi: + ensure => $acpi_available; + } } diff --git a/manifests/plugins/muninhost.pp b/manifests/plugins/muninhost.pp index 2af4897..e4fb87d 100644 --- a/manifests/plugins/muninhost.pp +++ b/manifests/plugins/muninhost.pp @@ -1,4 +1,3 @@ -class munin::plugins::muninhost inherits munin::plugins::base { - munin::plugin { munin_update: } - munin::plugin { munin_graph: } +class munin::plugins::muninhost { + munin::plugin { ['munin_update', 'munin_graph']: } } diff --git a/manifests/plugins/openbsd.pp b/manifests/plugins/openbsd.pp index 67cf32d..b549994 100644 --- a/manifests/plugins/openbsd.pp +++ b/manifests/plugins/openbsd.pp @@ -1,13 +1,6 @@ -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::openbsd { + munin::plugin { + [ memory_pools, memory_types ]: + ensure => present, + } } diff --git a/manifests/plugins/physical.pp b/manifests/plugins/physical.pp index 6706711..ac050a5 100644 --- a/manifests/plugins/physical.pp +++ b/manifests/plugins/physical.pp @@ -1,5 +1,5 @@ -class munin::plugins::physical inherits munin::plugins::base { - case $kernel { - linux: { munin::plugin { iostat: } } - } +class munin::plugins::physical { + case $kernel { + linux: { munin::plugin { iostat: } } + } } diff --git a/manifests/plugins/selinux.pp b/manifests/plugins/selinux.pp index 6affc86..faf610a 100644 --- a/manifests/plugins/selinux.pp +++ b/manifests/plugins/selinux.pp @@ -1,4 +1,3 @@ -class munin::plugins::selinux inherits munin::plugins::base { - munin::plugin::deploy { "selinuxenforced": } - munin::plugin::deploy { "selinux_avcstats": } +class munin::plugins::selinux { + munin::plugin::deploy { [ 'selinuxenforced', 'selinux_avcstats' ]: } } diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp new file mode 100644 index 0000000..f645f12 --- /dev/null +++ b/manifests/plugins/setup.pp @@ -0,0 +1,27 @@ +class munin::plugins::setup { + file { + [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: + source => "puppet://$server/modules/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'], + } + 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 f24af07..e3eec05 100644 --- a/manifests/plugins/vserver.pp +++ b/manifests/plugins/vserver.pp @@ -1,7 +1,7 @@ -class munin::plugins::vserver inherits munin::plugins::base { - munin::plugin { - [ netstat, processes ]: - ensure => present; - } +class munin::plugins::vserver { + munin::plugin { + [ netstat, processes ]: + ensure => present; + } } -- cgit v1.2.3 From 271fb020c2f0265cf4eeb82e79c8beab9eee14ff Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 19 Jul 2010 21:34:29 +0200 Subject: fixing a possible include problem --- manifests/plugins/base.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp index bfccae5..2924599 100644 --- a/manifests/plugins/base.pp +++ b/manifests/plugins/base.pp @@ -20,6 +20,6 @@ class munin::plugins::base { case $virtual { physical: { include munin::plugins::physical } - xen0: { include munin::plugins::dom0 } + xen0: { include "munin::plugins::dom0" } } } -- cgit v1.2.3 From 002e6fb8f374de98a9532102248e0776ecfdb3c8 Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 19 Jul 2010 21:41:05 +0200 Subject: another fix for inclusion --- manifests/plugins/base.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp index 2924599..ff36a19 100644 --- a/manifests/plugins/base.pp +++ b/manifests/plugins/base.pp @@ -20,6 +20,6 @@ class munin::plugins::base { case $virtual { physical: { include munin::plugins::physical } - xen0: { include "munin::plugins::dom0" } + xen0: { include ::munin::plugins::dom0 } } } -- cgit v1.2.3 From 892232f7c419fed071b7b1bdb0e3a2b9482c7449 Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 19 Jul 2010 21:41:55 +0200 Subject: fixing the actual problem --- manifests/plugins/base.pp | 2 +- manifests/plugins/dom0.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/plugins/base.pp b/manifests/plugins/base.pp index ff36a19..bfccae5 100644 --- a/manifests/plugins/base.pp +++ b/manifests/plugins/base.pp @@ -20,6 +20,6 @@ class munin::plugins::base { case $virtual { physical: { include munin::plugins::physical } - xen0: { include ::munin::plugins::dom0 } + xen0: { include munin::plugins::dom0 } } } diff --git a/manifests/plugins/dom0.pp b/manifests/plugins/dom0.pp index 3be3e3f..ed4f62c 100644 --- a/manifests/plugins/dom0.pp +++ b/manifests/plugins/dom0.pp @@ -1,7 +1,7 @@ class munin::plugins::dom0 { munin::plugin::deploy { [ 'xen', 'xen-cpu', 'xen_memory', 'xen_mem', - 'xen_vm', 'xen_vbd' 'xen_traffic_all' ]: + 'xen_vm', 'xen_vbd', 'xen_traffic_all' ]: config => 'user root'; } } -- cgit v1.2.3 From b491a012b6c2af328a782d27d8109aa282611f0c Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 20 Jul 2010 00:32:09 +0200 Subject: remove escaping --- manifests/plugins/setup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp index f645f12..e0d445c 100644 --- a/manifests/plugins/setup.pp +++ b/manifests/plugins/setup.pp @@ -2,7 +2,7 @@ class munin::plugins::setup { file { [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: source => "puppet://$server/modules/common/empty", - ignore => [ '\.ignore', 'snmp_*' ], + ignore => [ '.ignore', 'snmp_*' ], ensure => directory, checksum => mtime, recurse => true, purge => true, force => true, mode => 0755, owner => root, group => 0, -- cgit v1.2.3 From fc9a763859a4817a6f7ae06b3b3298e8325ff351 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 21 Jul 2010 07:53:05 +0200 Subject: Revert "remove escaping" This reverts commit b491a012b6c2af328a782d27d8109aa282611f0c. --- manifests/plugins/setup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp index e0d445c..f645f12 100644 --- a/manifests/plugins/setup.pp +++ b/manifests/plugins/setup.pp @@ -2,7 +2,7 @@ class munin::plugins::setup { file { [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: source => "puppet://$server/modules/common/empty", - ignore => [ '.ignore', 'snmp_*' ], + ignore => [ '\.ignore', 'snmp_*' ], ensure => directory, checksum => mtime, recurse => true, purge => true, force => true, mode => 0755, owner => root, group => 0, -- cgit v1.2.3 From dbcbf2607d52e922c20d0491400ab3099d0dba2a Mon Sep 17 00:00:00 2001 From: mh Date: Mon, 2 Aug 2010 01:54:15 +0200 Subject: escaping --- manifests/plugins/setup.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp index f645f12..e0d445c 100644 --- a/manifests/plugins/setup.pp +++ b/manifests/plugins/setup.pp @@ -2,7 +2,7 @@ class munin::plugins::setup { file { [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: source => "puppet://$server/modules/common/empty", - ignore => [ '\.ignore', 'snmp_*' ], + ignore => [ '.ignore', 'snmp_*' ], ensure => directory, checksum => mtime, recurse => true, purge => true, force => true, mode => 0755, owner => root, group => 0, -- cgit v1.2.3 From 3ccc8e2495a66ae9681bef64a4034a0e7828bf14 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 7 Aug 2010 02:12:20 +0200 Subject: remove unnecessary fileserver variable (#2460) --- manifests/client/openbsd.pp | 2 +- manifests/host.pp | 10 +++++----- manifests/host/cgi.pp | 10 +++++----- manifests/plugin/deploy.pp | 2 +- manifests/plugins/setup.pp | 2 +- manifests/snmp_collector.pp | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifests/client/openbsd.pp b/manifests/client/openbsd.pp index 8de025e..7012c00 100644 --- a/manifests/client/openbsd.pp +++ b/manifests/client/openbsd.pp @@ -3,7 +3,7 @@ class munin::client::openbsd inherits munin::client::base { if $operatingsystemrelease == '4.3' { file{'/usr/src/munin_openbsd.tar.gz': - source => "puppet://$server/modules/munin/openbsd/package/munin_openbsd.tar.gz", + source => "puppet:///modules/munin/openbsd/package/munin_openbsd.tar.gz", owner => root, group => 0, mode => 0600; } exec{'extract_openbsd': diff --git a/manifests/host.pp b/manifests/host.pp index 87d3255..e038fd7 100644 --- a/manifests/host.pp +++ b/manifests/host.pp @@ -9,11 +9,11 @@ class munin::host inherits munin File <<| tag == 'munin' |>> file{'/etc/munin/munin.conf.header': - source => [ "puppet://$server/modules/site-munin/config/host/${fqdn}/munin.conf.header", - "puppet://$server/modules/site-munin/config/host/munin.conf.header.$operatingsystem", - "puppet://$server/modules/site-munin/config/host/munin.conf.header", - "puppet://$server/modules/munin/config/host/munin.conf.header.$operatingsystem", - "puppet://$server/modules/munin/config/host/munin.conf.header" ], + source => [ "puppet:///modules/site-munin/config/host/${fqdn}/munin.conf.header", + "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", + "puppet:///modules/munin/config/host/munin.conf.header" ], notify => Exec['concat_/etc/munin/munin.conf'], owner => root, group => 0, mode => 0644; } diff --git a/manifests/host/cgi.pp b/manifests/host/cgi.pp index aeb0cdf..6fd50df 100644 --- a/manifests/host/cgi.pp +++ b/manifests/host/cgi.pp @@ -6,11 +6,11 @@ class munin::host::cgi { } file{'/etc/logrotate.d/munin': - source => [ "puppet://$server/modules/site-munin/config/host/${fqdn}/logrotate", - "puppet://$server/modules/site-munin/config/host/logrotate.$operatingsystem", - "puppet://$server/modules/site-munin/config/host/logrotate", - "puppet://$server/modules/munin/config/host/logrotate.$operatingsystem", - "puppet://$server/modules/munin/config/host/logrotate" ], + 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; } } diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 846a873..67cbfb8 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -11,7 +11,7 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { include munin::plugin::scriptpaths file { "munin_plugin_${name}": path => "$munin::plugin::scriptpaths::script_path/${name}", - source => "puppet://$server/modules/$real_source", + source => "puppet:///modules/$real_source", mode => 0755, owner => root, group => 0; } diff --git a/manifests/plugins/setup.pp b/manifests/plugins/setup.pp index e0d445c..c2c5ed3 100644 --- a/manifests/plugins/setup.pp +++ b/manifests/plugins/setup.pp @@ -1,7 +1,7 @@ class munin::plugins::setup { file { [ '/etc/munin/plugins', '/etc/munin/plugin-conf.d' ]: - source => "puppet://$server/modules/common/empty", + source => "puppet:///modules/common/empty", ignore => [ '.ignore', 'snmp_*' ], ensure => directory, checksum => mtime, recurse => true, purge => true, force => true, diff --git a/manifests/snmp_collector.pp b/manifests/snmp_collector.pp index 6f3fe34..7bd8bba 100644 --- a/manifests/snmp_collector.pp +++ b/manifests/snmp_collector.pp @@ -1,7 +1,7 @@ class munin::snmp_collector{ file { "/var/lib/puppet/modules/munin/create_snmp_links": - source => "puppet://$server/modules/munin/create_snmp_links.sh", + source => "puppet:///modules/munin/create_snmp_links.sh", mode => 755, owner => root, group => 0; } -- cgit v1.2.3 From 0d5407168827cb293abd9f0b5ecd406b16783f01 Mon Sep 17 00:00:00 2001 From: mh Date: Wed, 11 Aug 2010 09:59:09 +0200 Subject: introduce caching for xen plugins calls to the xen binaries such as xm are quite heavy and we therefore cache now a lot of the data that is generated for these plugins and use them as well for the other ones. --- files/plugins/xen | 11 +++++---- files/plugins/xen-cpu | 20 +++++++--------- files/plugins/xen_mem | 9 ++++--- files/plugins/xen_traffic_all | 55 ++++++++++++++++++++++++++----------------- files/plugins/xen_vbd | 34 +++++++++++++++++--------- files/plugins/xen_vm | 7 +++++- 6 files changed, 84 insertions(+), 52 deletions(-) diff --git a/files/plugins/xen b/files/plugins/xen index 575cd3b..a9f1a1e 100755 --- a/files/plugins/xen +++ b/files/plugins/xen @@ -8,8 +8,6 @@ # autoconf (optinal - used by munin-config) # -MAXDOMAINS=16 - if [ "$1" = "autoconf" ]; then if which xm > /dev/null ; then echo yes @@ -19,6 +17,11 @@ if [ "$1" = "autoconf" ]; then exit 1 fi +# we cache xm list for 5 min for perfomance reasons +((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE '^\/var\/lib\/munin\/plugin-state\/xm_list\.state$') && \ + [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || \ + /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state + if [ "$1" = "config" ]; then echo 'graph_title Xen Domain Utilerisation' @@ -27,7 +30,7 @@ if [ "$1" = "config" ]; then echo 'graph_vlabel mS' echo 'graph_category xen' echo 'graph_info This graph shows of many mS wall time where used by a domain' - /usr/sbin/xm list | grep -v "^Name .* Console$" | \ + cat /var/lib/munin/plugin-state/xm_list.state | \ while read name domid mem cpu state time console; do name=`echo $name | sed -e"s/-/_/"` echo "$name.label $name" @@ -43,7 +46,7 @@ if [ "$1" = "config" ]; then exit 0 fi -/usr/sbin/xm list | grep -v "^Name" | grep -v "^Name .* Console$" | \ +cat /var/lib/munin/plugin-state/xm_list.state | \ while read name domid mem cpu state time console; do name=`echo $name | sed -e"s/-/_/"` time=`echo $time | sed -e "s/\.//"` diff --git a/files/plugins/xen-cpu b/files/plugins/xen-cpu index 0ef301e..b456a14 100755 --- a/files/plugins/xen-cpu +++ b/files/plugins/xen-cpu @@ -28,6 +28,10 @@ use strict; $ENV{PATH} = '/bin:/usr/bin:/usr/sbin'; +# we cache xm list for 5 min for perfomance reasons +system('((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_list\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state'); +system('((find /var/lib/munin/plugin-state/xm_top.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_top\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_top.state | wc -l` -gt 1 ]) || /usr/sbin/xentop -b -i1 > /var/lib/munin/plugin-state/xm_top.state'); + my $arg; undef($arg); if (defined($ARGV[0])) { $arg = 'config' if ($ARGV[0] eq 'config'); @@ -53,8 +57,9 @@ if (defined($ARGV[0])) { 'graph_info' => 'Display the % of CPU Usage for each domain', ); - my @domains = `$XM list`; - shift(@domains); # we dont need the header line + my @domains = `cat /var/lib/munin/plugin-state/xm_list.state`; + # the header line is not in the cached file + #shift(@domains); # we dont need the header line my $cnt = "0"; foreach my $domain ( @domains ) { my ($dom,undef) = split(/\s/, $domain, 2); @@ -81,16 +86,7 @@ if (defined($ARGV[0])) { # Nothing was passed as an argument, so let's just return the proper values -my @chunks; undef(@chunks); - -{ - # run the xentop command a few times because the first reading is not always accurate - local $/ = undef; - @chunks = split(/^xentop - .*$/m, `$XMTOP -b -i2 -d2`); -} - -# Take only the last run of xentop -my @stats = split (/\n/,pop(@chunks)); +my @stats = `cat /var/lib/munin/plugin-state/xm_top.state`; # remove the first 4 items that are junk that we don't need. shift(@stats); diff --git a/files/plugins/xen_mem b/files/plugins/xen_mem index 5e985a5..16d91cf 100644 --- a/files/plugins/xen_mem +++ b/files/plugins/xen_mem @@ -43,7 +43,10 @@ #%# family=auto #%# capabilities=autoconf -XM="/usr/sbin/xm" +# we cache xm list for 5 min for perfomance reasons +((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE '^\/var\/lib\/munin\/plugin-state\/xm_list\.state$') && \ + [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || \ + /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state if [ "$1" = "autoconf" ]; then echo yes @@ -60,7 +63,7 @@ if [ "$1" = "config" ]; then echo 'graph_info This graph shows affected memory for each domain.' echo 'Domain_0.label Domain-0' echo 'Domain_0.draw AREA' -$XM list | grep -v 'Mem' | grep -v 'Domain-0' | while read i; do +cat /var/lib/munin/plugin-state/xm_list.state | grep -v 'Mem' | grep -v 'Domain-0' | while read i; do name=`echo $i | awk '{ print $1 }' | sed 's/[\/.-]/_/g'` echo -n "$name.label " echo $i | awk '{ print $1 }' @@ -70,7 +73,7 @@ done exit 0 fi -$XM list | grep -v 'Mem' | while read i; do +cat /var/lib/munin/plugin-state/xm_list.state | grep -v 'Mem' | while read i; do name=`echo $i | awk '{ print $1 }' | sed 's/[\/.-]/_/g'` echo -n "$name.value " echo $i | awk '{ print $3 * 1024 * 1024 }' diff --git a/files/plugins/xen_traffic_all b/files/plugins/xen_traffic_all index 76d4ded..c5bbfbb 100644 --- a/files/plugins/xen_traffic_all +++ b/files/plugins/xen_traffic_all @@ -11,6 +11,11 @@ #%# family=auto #%# capabilities=autoconf +# we cache xm list for 5 min for perfomance reasons +((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE '^\/var\/lib\/munin\/plugin-state\/xm_list\.state$') && \ + [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || \ + /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state + if [ "$1" = "autoconf" ]; then if which xm > /dev/null ; then echo yes @@ -32,34 +37,42 @@ if [ "$1" = "config" ]; then echo 'graph_vlabel bits received (-) / sent (+) per ${graph_period}' echo 'graph_args --base 1024 -l 0' echo 'graph_category xen' - DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)") + DOMAINS=$(cat /var/lib/munin/plugin-state/xm_list.state | awk '{print $1}' | egrep -v "^(Name|Domain-0)") for dom in $DOMAINS; do - devs=$( xm network-list $dom |\ - egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@') - real_name=$( echo $dom | sed -e's/-/_/g' ) - name=$real_name - for dev in $devs; do - if [ ${#devs} -gt 1 ]; then - name=$real_name"_"`echo $dev | sed 's/\./\_/'` - fi + # we update network devices only twice an hour + ((find /var/lib/munin/plugin-state/xm_net_$dom.state -mmin -30 > /dev/null 2>&1) && \ + [ `cat /var/lib/munin/plugin-state/xm_net_$dom.state | wc -l` -gt 0 ]) || \ + (/usr/sbin/xm network-list $dom |\ + egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@' > /var/lib/munin/plugin-state/xm_net_$dom.state) + devs=$(cat /var/lib/munin/plugin-state/xm_net_$dom.state) + real_name=$( echo $dom | sed -e's/-/_/g' ) + name=$real_name + for dev in $devs; do + if [ ${#devs} -gt 1 ]; then + name=$real_name"_"`echo $dev | sed 's/\./\_/'` + fi - echo $name'Down.label received' - echo $name'Down.type COUNTER' - echo $name'Down.graph no' - echo "${name}Down.cdef ${name}Down,8,*" - echo "${name}Up.label ${name}" - echo $name'Up.type COUNTER' - echo "${name}Up.negative ${name}Down" - echo "${name}Up.cdef ${name}Up,8,*" - done + echo $name'Down.label received' + echo $name'Down.type COUNTER' + echo $name'Down.graph no' + echo "${name}Down.cdef ${name}Down,8,*" + echo "${name}Up.label ${name}" + echo $name'Up.type COUNTER' + echo "${name}Up.negative ${name}Down" + echo "${name}Up.cdef ${name}Up,8,*" + done done exit 0 fi -DOMAINS=$(xm list | awk '{print $1}' | egrep -v "^(Name|Domain-0)") +DOMAINS=$(cat /var/lib/munin/plugin-state/xm_list.state | awk '{print $1}' | egrep -v "^(Name|Domain-0)") for dom in $DOMAINS; do - devs=$( xm network-list $dom |\ - egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@') + # we update network devices only twice an hour + ((find /var/lib/munin/plugin-state/xm_net_$dom.state -mmin -30 > /dev/null 2>&1) && \ + [ `cat /var/lib/munin/plugin-state/xm_net_$dom.state | wc -l` -gt 0 ]) || \ + (/usr/sbin/xm network-list $dom |\ + egrep "^[0-9]+" | sed 's@^.*vif/\([0-9]*\)/\([0-9]*\).*$@vif\1.\2@' > /var/lib/munin/plugin-state/xm_net_$dom.state) + devs=$(cat /var/lib/munin/plugin-state/xm_net_$dom.state) real_name=$( echo $dom | sed -e's/-/_/g' ) name=$real_name for dev in $devs; do diff --git a/files/plugins/xen_vbd b/files/plugins/xen_vbd index 238bf08..4eca5a6 100755 --- a/files/plugins/xen_vbd +++ b/files/plugins/xen_vbd @@ -16,6 +16,10 @@ $XM = '/usr/sbin/xm'; $XMTOP = '/usr/sbin/xentop'; +# we cache xm list for 5 min for perfomance reasons +system('((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_list\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state'); +system('((find /var/lib/munin/plugin-state/xm_top.state -mmin -5 2>&1 | grep -qE \'^\/var\/lib\/munin\/plugin-state\/xm_top\.state$\') && [ `cat /var/lib/munin/plugin-state/xm_top.state | wc -l` -gt 1 ]) || /usr/sbin/xentop -b -i1 > /var/lib/munin/plugin-state/xm_top.state'); + # ah, parameters coming in if ( defined($ARGV[0])) { @@ -46,7 +50,7 @@ if ( defined($ARGV[0])) 'graph_info' => 'Display the I/O operations for each domain', ); - @domains = `$XM list`; + @domains = `cat /var/lib/munin/plugin-state/xm_list.state`; shift(@domains); # we don't need the header line foreach $domain ( @domains ) @@ -82,16 +86,24 @@ if ( defined($ARGV[0])) # No args, get rolling -# NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%) VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR SSID -$tmpfile = "/tmp/munin_xen_vbd_tmp"; - -system("$XMTOP -b -i1 > $tmpfile"); -open(I,"$tmpfile"); -while(){ - chomp; - s/^\s*//g; - @tmp=split(/\s+/, $_); - next if $tmp[0] eq "NAME"; +my @stats = `cat /var/lib/munin/plugin-state/xm_top.state`; + +# remove the first 4 items that are junk that we don't need. +shift(@stats); +shift(@stats); +shift(@stats); +shift(@stats); + +my %vals; undef(%vals); + +foreach my $domain (@stats) { + # trim the leading whitespace + $domain =~ s/^\s+//; + my @tmp = split(/\s+/, $domain); + + # we need to change - and . to _ or things get weird with the graphs + # some decent quoting would probably fix this, but this works for now + $tmp[0] =~ s/[-.]/_/g; $domname = $tmp[0]; $domname =~ s/[-.]/_/g; diff --git a/files/plugins/xen_vm b/files/plugins/xen_vm index a0dc0b7..a69b5fe 100644 --- a/files/plugins/xen_vm +++ b/files/plugins/xen_vm @@ -45,6 +45,11 @@ XM="/usr/sbin/xm" +# we cache xm list for 5 min for perfomance reasons +((find /var/lib/munin/plugin-state/xm_list.state -mmin -5 2>&1 | grep -qE '^\/var\/lib\/munin\/plugin-state\/xm_list\.state$') && \ + [ `cat /var/lib/munin/plugin-state/xm_list.state | wc -l` -gt 1 ]) || \ + /usr/sbin/xm list | grep -v "^Name .* Console$" > /var/lib/munin/plugin-state/xm_list.state + if [ "$1" = "autoconf" ]; then echo yes exit 0 @@ -61,7 +66,7 @@ if [ "$1" = "config" ]; then exit 0 fi -domains=`$XM list | wc -l` +domains=`cat /var/lib/munin/plugin-state/xm_list.state | wc -l` echo -n "domains.value " echo $(($domains-2)) -- cgit v1.2.3 From 022eb852e772afb07541866291ad20ff978ac912 Mon Sep 17 00:00:00 2001 From: Marcel Haerry Date: Mon, 27 Sep 2010 12:29:31 +0200 Subject: use shell so we can actually pipe that command --- manifests/register/snmp.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/register/snmp.pp b/manifests/register/snmp.pp index c0d9279..0c3ac5c 100644 --- a/manifests/register/snmp.pp +++ b/manifests/register/snmp.pp @@ -9,7 +9,7 @@ define munin::register::snmp ( $config = [ 'use_node_name no' ] exec { "munin_register_snmp_${fhost}": - command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} | sh", + command => "munin-node-configure --snmp ${fhost} --snmpcommunity ${community} --shell | sh", unless => "ls /etc/munin/plugins/snmp_${fhost}_* &> /dev/null", } -- cgit v1.2.3 From 0e23402c1146edcbf1d6fcce6fdfc654d661db33 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 30 Sep 2010 12:39:42 +0200 Subject: restore munin port in template --- templates/client.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/client.erb b/templates/client.erb index e7c6730..15e05c6 100644 --- a/templates/client.erb +++ b/templates/client.erb @@ -12,7 +12,8 @@ # Description: <%= description.gsub!(/\n/, ' ') %> <% end -%> [<%= fhost.downcase %>] - address <%= munin_host_real -%> + address <%= munin_host_real %> + port <%= munin_port_real %> <% if config -%><% config.each do |val| -%> <%= val -%> <% end -%><% end -%> -- cgit v1.2.3 From 17df63f17e1aab4c15584b41fbe7fe925503e054 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 9 Dec 2010 23:32:53 +0100 Subject: replace gsub with builtin regsubst --- manifests/plugins/interfaces.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/plugins/interfaces.pp b/manifests/plugins/interfaces.pp index e0744a0..18a713b 100644 --- a/manifests/plugins/interfaces.pp +++ b/manifests/plugins/interfaces.pp @@ -1,19 +1,19 @@ # handle if_ and if_err_ plugins class munin::plugins::interfaces { - $ifs = gsub(split($interfaces, " |,"), "(.+)", "if_\\1") + $ifs = regsubst(split($interfaces, " |,"), "(.+)", "if_\\1") munin::plugin { $ifs: ensure => "if_"; } case $operatingsystem { openbsd: { - $if_errs = gsub(split($interfaces, " |,"), "(.+)", "if_errcoll_\\1") + $if_errs = regsubst(split($interfaces, " |,"), "(.+)", "if_errcoll_\\1") munin::plugin{ $if_errs: ensure => "if_errcoll_"; } } default: { - $if_errs = gsub(split($interfaces, " |,"), "(.+)", "if_err_\\1") + $if_errs = regsubst(split($interfaces, " |,"), "(.+)", "if_err_\\1") munin::plugin{ $if_errs: ensure => "if_err_"; } -- cgit v1.2.3