From c55a6660083899b4c01be4d9d9510d81580c8acb Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 2 Sep 2010 22:20:11 -0400 Subject: switch to new lsb method --- manifests/vserver.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/vserver.pp b/manifests/vserver.pp index 11068b6..4a49268 100644 --- a/manifests/vserver.pp +++ b/manifests/vserver.pp @@ -7,7 +7,7 @@ module_dir{ "virtual/contexts": } class vserver::host { # make sure we have the ability to query for lsbdistcodename - include assert_lsbdistcodename + include lsb $utilvserver_version = $lsbdistcodename ? { etch => "0.30.216~r2772-6~bpo40+1", -- cgit v1.2.3 From 620f972db89ec6891693e1b01de128c81d1764b9 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 15 Dec 2010 13:13:20 -0500 Subject: enable site-virtual source distribution of xend-config.sxp --- manifests/xen.pp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/manifests/xen.pp b/manifests/xen.pp index 301b316..de07f19 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -41,13 +41,11 @@ class xen::domain::base { } file{'/etc/xen/xend-config.sxp': - source => [ "puppet://$server/files/virtual/xen/${fqdn}/config/xend-config.sxp", - "puppet://$server/files/virtual/xen/config/${domain}/xend-config.sxp", - "puppet://$server/files/virtual/xen/config/${operatingsystem}/xend-config.sxp", - "puppet://$server/files/virtual/xen/config/${operatingsystem}/$lsbdistcodename/xend-config.sxp", - "puppet://$server/files/virtual/xen/config/xend-config.sxp", + source => [ "puppet://$server/modules/site-virtual/xen/${fqdn}/config/xend-config.sxp", + "puppet://$server/modules/site-virtual/xen/config/${domain}/xend-config.sxp", + "puppet://$server/modules/site-virtual/xen/config/${operatingsystem}/xend-config.sxp", + "puppet://$server/modules/site-virtual/xen/config/xend-config.sxp", "puppet://$server/modules/virtual/xen/config/${operatingsystem}/xend-config.sxp", - "puppet://$server/modules/virtual/xen/config/${operatingsystem}/$lsbdistcodename/xend-config.sxp", "puppet://$server/modules/virtual/xen/config/xend-config.sxp" ], notify => Service['xend'], owner => root, group => 0, mode => 0644; -- cgit v1.2.3 From 3edbcf33cf7860db84f6fb9d3126f8cb22b5c9f4 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 15 Dec 2010 13:15:49 -0500 Subject: remove unnecessary fileserver variable --- manifests/openvpn.pp | 4 ++-- manifests/vserver.pp | 10 +++++----- manifests/xen.pp | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/manifests/openvpn.pp b/manifests/openvpn.pp index 7745d38..5aa8d92 100644 --- a/manifests/openvpn.pp +++ b/manifests/openvpn.pp @@ -14,10 +14,10 @@ class virtual::openvpn::base { class virtual::openvpn::host_base inherits virtual::openvpn::base { file { "/var/lib/puppet/modules/virtual/openvpn/create_interface": - source => "puppet://$server/modules/virtual/create_openvpn_interface", + source => "puppet:///modules/virtual/create_openvpn_interface", mode => 0755, owner => root, group => 0; "/var/lib/puppet/modules/virtual/openvpn/destroy_interface": - source => "puppet://$server/modules/virtual/destroy_openvpn_interface", + source => "puppet:///modules/virtual/destroy_openvpn_interface", mode => 0755, owner => root, group => 0; } } diff --git a/manifests/vserver.pp b/manifests/vserver.pp index 4a49268..9e1566d 100644 --- a/manifests/vserver.pp +++ b/manifests/vserver.pp @@ -34,14 +34,14 @@ class vserver::host { require => File["/etc/vservers"]; "/usr/local/bin/build_vserver": - source => "puppet://$server/modules/virtual/vserver/build_vserver", + source => "puppet:///modules/virtual/vserver/build_vserver", mode => 0755, owner => root, group => root, require => [ Package['util-vserver'], Package[debootstrap]]; # perhaps we should use hashify. # but i'm commenting this out until we learn how to properly use in case we want to use it. #"/etc/cron.daily/vserver-hashify": - # source => "puppet://$server/virtual/hashify.cron.daily", + # source => "puppet:///virtual/hashify.cron.daily", # mode => 0755, owner => root, group => root; } @@ -58,15 +58,15 @@ class vserver::host { mode => 0644, owner => root, group => root; "/usr/local/share/munin-plugins/vserver_resources": - source => "puppet://$server/modules/virtual/munin/vserver_resources", + source => "puppet:///modules/virtual/munin/vserver_resources", mode => 0755, owner => root, group => root; "/usr/local/share/munin-plugins/vserver_cpu_": - source => "puppet://$server/modules/virtual/munin/vserver_cpu_", + source => "puppet:///modules/virtual/munin/vserver_cpu_", mode => 0755, owner => root, group => root; "/usr/local/share/munin-plugins/vserver_loadavg": - source => "puppet://$server/modules/virtual/munin/vserver_loadavg", + source => "puppet:///modules/virtual/munin/vserver_loadavg", mode => 0755, owner => root, group => root; } diff --git a/manifests/xen.pp b/manifests/xen.pp index de07f19..7c06147 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -5,10 +5,10 @@ class munin::plugins::xen { munin::remoteplugin { xen_mem: - source => "puppet://$server/modules/virtual/munin/xen_mem", + source => "puppet:///modules/virtual/munin/xen_mem", config => "user root"; xen_vm: - source => "puppet://$server/modules/virtual/munin/xen_vm", + source => "puppet:///modules/virtual/munin/xen_vm", config => "user root"; } } @@ -41,12 +41,12 @@ class xen::domain::base { } file{'/etc/xen/xend-config.sxp': - source => [ "puppet://$server/modules/site-virtual/xen/${fqdn}/config/xend-config.sxp", - "puppet://$server/modules/site-virtual/xen/config/${domain}/xend-config.sxp", - "puppet://$server/modules/site-virtual/xen/config/${operatingsystem}/xend-config.sxp", - "puppet://$server/modules/site-virtual/xen/config/xend-config.sxp", - "puppet://$server/modules/virtual/xen/config/${operatingsystem}/xend-config.sxp", - "puppet://$server/modules/virtual/xen/config/xend-config.sxp" ], + source => [ "puppet:///modules/site-virtual/xen/${fqdn}/config/xend-config.sxp", + "puppet:///modules/site-virtual/xen/config/${domain}/xend-config.sxp", + "puppet:///modules/site-virtual/xen/config/${operatingsystem}/xend-config.sxp", + "puppet:///modules/site-virtual/xen/config/xend-config.sxp", + "puppet:///modules/virtual/xen/config/${operatingsystem}/xend-config.sxp", + "puppet:///modules/virtual/xen/config/xend-config.sxp" ], notify => Service['xend'], owner => root, group => 0, mode => 0644; } @@ -62,13 +62,13 @@ class xen::domain::centos inherits xen::domain::base { } file{'/etc/sysconfig/xend': - source => "puppet://$server/modules/virtual/xen/${operatingsystem}/sysconfig/xend", + source => "puppet:///modules/virtual/xen/${operatingsystem}/sysconfig/xend", notify => Service['xend'], owner => root, group => 0, mode => 0644; } file{'/etc/sysconfig/xendomains': - source => "puppet://$server/modules/virtual/xen/${operatingsystem}/sysconfig/xendomains", + source => "puppet:///modules/virtual/xen/${operatingsystem}/sysconfig/xendomains", owner => root, group => 0, mode => 0644; } -- cgit v1.2.3 From 0d5214bfd0c7d10f0f181a8fe95966de3d348a38 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 15 Dec 2010 13:16:40 -0500 Subject: fix lookup path --- manifests/xen.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/xen.pp b/manifests/xen.pp index 7c06147..93fdc40 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -41,7 +41,7 @@ class xen::domain::base { } file{'/etc/xen/xend-config.sxp': - source => [ "puppet:///modules/site-virtual/xen/${fqdn}/config/xend-config.sxp", + source => [ "puppet:///modules/site-virtual/xen/config/${fqdn}/config/xend-config.sxp", "puppet:///modules/site-virtual/xen/config/${domain}/xend-config.sxp", "puppet:///modules/site-virtual/xen/config/${operatingsystem}/xend-config.sxp", "puppet:///modules/site-virtual/xen/config/xend-config.sxp", -- cgit v1.2.3 From aea276aa7416d7bf1277f97e9ca7449967e68140 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 15 Dec 2010 13:22:29 -0500 Subject: add $lsbdistcodename subdirectory for search path --- manifests/xen.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/xen.pp b/manifests/xen.pp index 93fdc40..27504bb 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -44,6 +44,7 @@ class xen::domain::base { source => [ "puppet:///modules/site-virtual/xen/config/${fqdn}/config/xend-config.sxp", "puppet:///modules/site-virtual/xen/config/${domain}/xend-config.sxp", "puppet:///modules/site-virtual/xen/config/${operatingsystem}/xend-config.sxp", + "puppet:///modules/site-virtual/xen/config/${operatingsystem}/${lsbdistcodeename}/xend-config.sxp", "puppet:///modules/site-virtual/xen/config/xend-config.sxp", "puppet:///modules/virtual/xen/config/${operatingsystem}/xend-config.sxp", "puppet:///modules/virtual/xen/config/xend-config.sxp" ], -- cgit v1.2.3 From 6c130e10055d76c611d0fba44223c0b0ede93012 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 15 Dec 2010 13:32:09 -0500 Subject: add a $lsbdistcodename case for the xen-linux-system packages add a squeeze version update the xen-linux-system packages for lenny to be the -2 version --- manifests/xen.pp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/manifests/xen.pp b/manifests/xen.pp index 27504bb..6fc3ba5 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -87,10 +87,21 @@ class xen::domain::centos inherits xen::domain::base { } class xen::domain::debian inherits xen::domain::base { - $xen_linux_system = $architecture ? { - amd64 => "xen-linux-system-2.6.26-1-xen-amd64", - i386 => "xen-linux-system-2.6.26-1-xen-686" + case $lsbdistcodename { + "lenny": { + $xen_linux_system = $architecture ? { + amd64 => "xen-linux-system-2.6.26-2-xen-amd64", + i386 => "xen-linux-system-2.6.26-2-xen-686" + } + } + "squeeze": { + $xen_linux_system = $architecture ? { + amd64 => "xen-linux-system-2.6.32-5-xen-amd64", + i386 => "xen-linux-system-2.6.32-5-xen-686" + } + } } +} package { "$xen_linux_system": -- cgit v1.2.3 From 22b37d7e165fe5cd2ff688cb59b559167ce8dbf0 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 15 Dec 2010 13:33:54 -0500 Subject: add a squeeze case for the xen-tools package installation --- manifests/xen.pp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/manifests/xen.pp b/manifests/xen.pp index 6fc3ba5..6aff1b8 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -139,6 +139,12 @@ class xen::dom0::debian inherits xen::dom0::base { ensure => "4.1-1~bpo50+1", } } + squeeze: { + package { + "xen-tools": + ensure => installed; + } + } } file { -- cgit v1.2.3 From 078f717b98a8f6822ae01a05e3cedb5c32bf24a5 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 15 Dec 2010 13:38:28 -0500 Subject: change template location for xen-tools.conf.erb to be in the site-virtual module, with a $operatingsystem/$lsbdistcodename variation --- manifests/xen.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/xen.pp b/manifests/xen.pp index 6aff1b8..afcc13d 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -150,7 +150,7 @@ class xen::dom0::debian inherits xen::dom0::base { file { "/etc/xen-tools/xen-tools.conf": owner => root, group => 0, mode => 0644, - content => template("virtual/xen-tools.conf.erb"), + content => template("site-virtual/${operatingsystem}/${lsbdistcodename}/xen-tools.conf.erb"), require => Package['xen-tools']; } } -- cgit v1.2.3 From 52046b5dd07703d82c2b77452144dd928cf30347 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 15 Dec 2010 13:51:32 -0500 Subject: fix closing curly brace syntax error --- manifests/xen.pp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/manifests/xen.pp b/manifests/xen.pp index afcc13d..95e9937 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -101,8 +101,7 @@ class xen::domain::debian inherits xen::domain::base { } } } -} - + package { "$xen_linux_system": ensure => present, -- cgit v1.2.3 From 45f951dac124333c30acdd7b18b4f8a0d224c480 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 15 Dec 2010 13:54:01 -0500 Subject: add xen-specific path to the xen-tools site-virtual template path --- manifests/xen.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/xen.pp b/manifests/xen.pp index 95e9937..c5caa6c 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -149,7 +149,7 @@ class xen::dom0::debian inherits xen::dom0::base { file { "/etc/xen-tools/xen-tools.conf": owner => root, group => 0, mode => 0644, - content => template("site-virtual/${operatingsystem}/${lsbdistcodename}/xen-tools.conf.erb"), + content => template("site-virtual/xen/${operatingsystem}/${lsbdistcodename}/xen-tools.conf.erb"), require => Package['xen-tools']; } } -- cgit v1.2.3 From 59f7ba6d75060a13c5dfba9fba92b595419099d2 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 2 Feb 2012 12:12:43 -0500 Subject: workaround for http://projects.puppetlabs.com/issues/11511 --- manifests/xen.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/xen.pp b/manifests/xen.pp index c5caa6c..96200ac 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -96,8 +96,8 @@ class xen::domain::debian inherits xen::domain::base { } "squeeze": { $xen_linux_system = $architecture ? { - amd64 => "xen-linux-system-2.6.32-5-xen-amd64", - i386 => "xen-linux-system-2.6.32-5-xen-686" + 'amd64','x86_64' => "xen-linux-system-2.6.32-5-xen-amd64", + 'i386' => "xen-linux-system-2.6.32-5-xen-686" } } } -- cgit v1.2.3 From d23068ecb593e7287fc70af809c3068fdeccb511 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Thu, 2 Feb 2012 12:15:26 -0500 Subject: fix syntax error --- manifests/xen.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/xen.pp b/manifests/xen.pp index 96200ac..0ca5dc3 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -96,8 +96,8 @@ class xen::domain::debian inherits xen::domain::base { } "squeeze": { $xen_linux_system = $architecture ? { - 'amd64','x86_64' => "xen-linux-system-2.6.32-5-xen-amd64", - 'i386' => "xen-linux-system-2.6.32-5-xen-686" + /(amd64|x86_64)/ => "xen-linux-system-2.6.32-5-xen-amd64", + i386 => "xen-linux-system-2.6.32-5-xen-686" } } } -- cgit v1.2.3 From e02f8638bcdf08d59b1a13b8a5be5efe1f344f27 Mon Sep 17 00:00:00 2001 From: Matt Taggart Date: Mon, 13 Feb 2012 16:19:58 -0800 Subject: these have bashisms which don't work with dash as /bin/sh, so switch the scripts to bash and add a comment --- files/munin/vserver_cpu_ | 3 ++- files/munin/vserver_loadavg | 3 ++- files/munin/vserver_resources | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/files/munin/vserver_cpu_ b/files/munin/vserver_cpu_ index 981f262..8ce3a95 100755 --- a/files/munin/vserver_cpu_ +++ b/files/munin/vserver_cpu_ @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (C) 2006-2008 Holger Levsen and Micah Anderson # @@ -63,6 +63,7 @@ VSERVERS="$vservers" +# FIXME: using arrays is a bashism INFO=(`sed 's/.*:\t//' /proc/virtual/info 2>/dev/null || echo ''`) KCIN="$[ 16#${INFO[2]} ]"; diff --git a/files/munin/vserver_loadavg b/files/munin/vserver_loadavg index 43ce5e1..147eff9 100644 --- a/files/munin/vserver_loadavg +++ b/files/munin/vserver_loadavg @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (C) 2007 Andrei Morgan # Copyright (C) 2008 Micah Anderson @@ -56,6 +56,7 @@ fi # if vservers are specified, use them; the default is to use all. VSERVERS="$vservers" +# FIXME: using arrays is a bashism INFO=(`sed 's/.*:\t//' /proc/virtual/info 2>/dev/null || echo ''`) KCIN="$[ 16#${INFO[2]} ]"; diff --git a/files/munin/vserver_resources b/files/munin/vserver_resources index 495614f..05dfecb 100755 --- a/files/munin/vserver_resources +++ b/files/munin/vserver_resources @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (C) 2006-2008 Holger Levsen and Micah Anderson # @@ -127,6 +127,7 @@ VSERVERS="$vservers" LIMITS="$limits" RESOURCE="$resource" +# FIXME: using arrays is a bashism INFO=(`sed 's/.*:\t//' /proc/virtual/info 2>/dev/null || echo ''`) KCIN="$[ 16#${INFO[2]} ]"; -- cgit v1.2.3 From d20265e48c06316d9b8120aed913796231a4ad7d Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 27 Jun 2012 23:56:56 -0400 Subject: 2.7 underscore rename --- manifests/xen.pp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/xen.pp b/manifests/xen.pp index 0ca5dc3..3dbb12c 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -41,11 +41,11 @@ class xen::domain::base { } file{'/etc/xen/xend-config.sxp': - source => [ "puppet:///modules/site-virtual/xen/config/${fqdn}/config/xend-config.sxp", - "puppet:///modules/site-virtual/xen/config/${domain}/xend-config.sxp", - "puppet:///modules/site-virtual/xen/config/${operatingsystem}/xend-config.sxp", - "puppet:///modules/site-virtual/xen/config/${operatingsystem}/${lsbdistcodeename}/xend-config.sxp", - "puppet:///modules/site-virtual/xen/config/xend-config.sxp", + source => [ "puppet:///modules/site_virtual/xen/config/${fqdn}/config/xend-config.sxp", + "puppet:///modules/site_virtual/xen/config/${domain}/xend-config.sxp", + "puppet:///modules/site_virtual/xen/config/${operatingsystem}/xend-config.sxp", + "puppet:///modules/site_virtual/xen/config/${operatingsystem}/${lsbdistcodeename}/xend-config.sxp", + "puppet:///modules/site_virtual/xen/config/xend-config.sxp", "puppet:///modules/virtual/xen/config/${operatingsystem}/xend-config.sxp", "puppet:///modules/virtual/xen/config/xend-config.sxp" ], notify => Service['xend'], @@ -149,7 +149,7 @@ class xen::dom0::debian inherits xen::dom0::base { file { "/etc/xen-tools/xen-tools.conf": owner => root, group => 0, mode => 0644, - content => template("site-virtual/xen/${operatingsystem}/${lsbdistcodename}/xen-tools.conf.erb"), + content => template("site_virtual/xen/${operatingsystem}/${lsbdistcodename}/xen-tools.conf.erb"), require => Package['xen-tools']; } } -- cgit v1.2.3 From 711a471ae8c77f0fce3f05dd57ebd308d0144f57 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 9 Jan 2013 15:56:57 -0500 Subject: switch to xen-multi munin plugin. This removes the buggy and slow xen_mem and xen_vm and replaces it with a plugin that does those and more --- files/munin/xen-multi | 243 ++++++++++++++++++++++++++++++++++++++++++++++++++ manifests/xen.pp | 11 ++- 2 files changed, 251 insertions(+), 3 deletions(-) create mode 100644 files/munin/xen-multi diff --git a/files/munin/xen-multi b/files/munin/xen-multi new file mode 100644 index 0000000..c57a2b8 --- /dev/null +++ b/files/munin/xen-multi @@ -0,0 +1,243 @@ +#! /usr/bin/perl + +# -*- perl -*- + +=head1 NAME + +xen_multi - Munin multigraph plugin to monitor Xen domains activity + +=head1 APPLICABLE SYSTEMS + +This plugin should work on any system running a Xen hypervisor and where xentop +is installed. It also needs Munin 1.4.0 or higher, since it uses AREASTACK +(available from 1.3.3) and multigraph (available from 1.4.0). + +=head1 CONFIGURATION + +xentop requires superuser privileges, so you need to include in your +configuration: + + [xen-multi] + user root + +Then restart munin-node and you're done. + +=head1 INTERPRETATION + +This plugin produces four different graphs: CPU usage, memory usage, disk IOs +and network traffic. + +In each graph, all Xen domains (including dom0) have their data stacked, giving +an overall amount of ressources used. + +NOTE: xentop always reports 0 for dom0's disk IOs and network traffic, but +both graphs show its entry all the same, so each domain can keep its own color +along the different graphs. + +=head2 CPU usage + +This graph shows a percentage of the CPU time used by each domain. + +=head2 Memory usage + +This graph shows the amount of memory (in bytes) used by each domain. + +=head2 Disk IOs + +This graph shows the number of disk read and write operations for each domain. + +=head2 Network traffic + +This graph shows the amount of bits received and transmitted for each domain. + +=head1 ACKNOWLEDGEMENTS + +Michael Renner for the C plugin which I borrowed some code from. + +=head1 VERSION + +0.90 + +=head1 MAGIC MARKERS + + #%# family=auto + #%# capabilities=autoconf + +=head1 AUTHOR + +Raphael HALIMI + +=head1 LICENSE + +GPLv2 + +=cut + +use strict; +use Munin::Plugin; + +# autoconf - quite simple +if ($ARGV[0] eq "autoconf") { + if (`which xentop`) { + print "yes\n"; + } else { + print "no (xentop not found)\n"; + } + exit 0; +} + + +# +# Common steps for both "config" and a normal run +# + +# +# trim_label +# +# Trims a given label to it's non-wrapping size +# $type = 'pos' for normal graphs and 'neg' for mirror graphs +# pos: nnn.nnU_ times 4 +# neg: nnn.nnU/nnn.nnU_ times 4 + +sub trim_label { + my ($type, $label) = @_; my $data_characters; + my ($graph_width, $graph_border_width, $padding_characters, $pixels_per_character) = (400,97,10,6); + if ($type eq 'pos') {$data_characters = 32;} elsif ($type eq 'neg') {$data_characters = 64;} else {return $label;} + + my $available_characters = abs(($graph_width+$graph_border_width)/$pixels_per_character)-$padding_characters-$data_characters; + + # If the label is longer than the available space, we write as many + # characters as we can on both left and right, and two dots in the middle + if ( $available_characters < length $label ) { + my $center = ($available_characters-2)/2; + $label = substr($label,0,($center)) . '..' . substr($label,-$center); + } + + return $label; +} + +# Global variables +my (%domains,$domain,$munindomain,$cpusecs,$memk,$nettxk,$netrxk,$vbdrd,$vbdwr); + +open (XENTOP,"xentop -b -f -i1 |") or die "Could not execute xentop, $!"; + +# Now we build a hash of hashes to store information +while () { + # Some cleaning first + s/^\s+//; chomp; + # Skip the headers + next if /^NAME/; + + # We define only what we need + ($domain,undef,$cpusecs,undef,$memk,undef,undef,undef,undef,undef,$nettxk,$netrxk,undef,undef,$vbdrd,$vbdwr,undef,undef,undef) = split(/\s+/); + + # We have to store the sanitised domain name in a separate variable + $domains{$domain}{'munindomain'} = clean_fieldname($domain); + + # We need the remaining data only for a normal run + if ($ARGV[0] eq "") { + $domains{$domain}{'cpusecs'} = $cpusecs; + $domains{$domain}{'mem'} = $memk; + $domains{$domain}{'nettx'} = $nettxk; + $domains{$domain}{'netrx'} = $netrxk; + $domains{$domain}{'vbdrd'} = $vbdrd; + $domains{$domain}{'vbdwr'} = $vbdwr; + } +} + + +# +# config - quite simple, too +# + +if ($ARGV[0] eq "config") { + print "multigraph xen_cpu_time\n"; + print "graph_title Xen domains CPU time\n"; + print "graph_args --base 1000 -l 0\n"; + print "graph_vlabel %\n"; + print "graph_scale no\n"; + print "graph_category xen\n"; + print "graph_info This graph shows CPU time for each Xen domain.\n"; + for $domain (sort(keys(%domains))) { + print "$domains{$domain}{'munindomain'}_cpu_time.label ".trim_label('pos',$domain)."\n"; + print "$domains{$domain}{'munindomain'}_cpu_time.type DERIVE\n"; + print "$domains{$domain}{'munindomain'}_cpu_time.cdef $domains{$domain}{'munindomain'}_cpu_time,100,*\n"; + print "$domains{$domain}{'munindomain'}_cpu_time.min 0\n"; + print "$domains{$domain}{'munindomain'}_cpu_time.draw AREASTACK\n"; + } + + print "\nmultigraph xen_mem\n"; + print "graph_title Xen domains memory usage\n"; + print "graph_args --base 1024 -l 0\n"; + print "graph_vlabel bytes\n"; + print "graph_category xen\n"; + print "graph_info This graph shows memory usage for each Xen domain.\n"; + for $domain (sort(keys(%domains))) { + print "$domains{$domain}{'munindomain'}_mem.label ".trim_label('pos',$domain)."\n"; + print "$domains{$domain}{'munindomain'}_mem.cdef $domains{$domain}{'munindomain'}_mem,1024,*\n"; + print "$domains{$domain}{'munindomain'}_mem.draw AREASTACK\n"; + } + + print "\nmultigraph xen_net\n"; + print "graph_title Xen domains network traffic\n"; + print "graph_args --base 1000\n"; + print "graph_vlabel bits per \${graph_period} in (-) / out (+)\n"; + print "graph_category xen\n"; + print "graph_info This graph shows network traffic for each Xen domain.\n"; + for $domain (sort(keys(%domains))) { + print "$domains{$domain}{'munindomain'}_netrx.label none\n"; + print "$domains{$domain}{'munindomain'}_netrx.cdef $domains{$domain}{'munindomain'}_netrx,8192,*\n"; + print "$domains{$domain}{'munindomain'}_netrx.type COUNTER\n"; + print "$domains{$domain}{'munindomain'}_netrx.graph no\n"; + print "$domains{$domain}{'munindomain'}_nettx.label ".trim_label('neg',$domain)."\n"; + print "$domains{$domain}{'munindomain'}_nettx.cdef $domains{$domain}{'munindomain'}_nettx,8192,*\n"; + print "$domains{$domain}{'munindomain'}_nettx.type COUNTER\n"; + print "$domains{$domain}{'munindomain'}_nettx.draw AREASTACK\n"; + print "$domains{$domain}{'munindomain'}_nettx.negative $domains{$domain}{'munindomain'}_netrx\n"; + } + + print "\nmultigraph xen_disk\n"; + print "graph_title Xen domains disk IOs\n"; + print "graph_args --base 1000\n"; + print "graph_vlabel IOs per \${graph_period} read (-) / write (+)\n"; + print "graph_category xen\n"; + print "graph_info This graph shows disk IOs for each Xen domain.\n"; + for $domain (sort(keys(%domains))) { + print "$domains{$domain}{'munindomain'}_vbdrd.label none\n"; + print "$domains{$domain}{'munindomain'}_vbdrd.type COUNTER\n"; + print "$domains{$domain}{'munindomain'}_vbdrd.graph no\n"; + print "$domains{$domain}{'munindomain'}_vbdwr.label ".trim_label('neg',$domain)."\n"; + print "$domains{$domain}{'munindomain'}_vbdwr.type COUNTER\n"; + print "$domains{$domain}{'munindomain'}_vbdwr.draw AREASTACK\n"; + print "$domains{$domain}{'munindomain'}_vbdwr.negative $domains{$domain}{'munindomain'}_vbdrd\n"; + } + + exit 0; +} + + +# +# Normal run +# + +print "multigraph xen_cpu_time\n"; +for $domain (sort(keys(%domains))) { + print "$domains{$domain}{'munindomain'}_cpu_time.value $domains{$domain}{'cpusecs'}\n"; +} + +print "\nmultigraph xen_mem\n"; +for $domain (sort(keys(%domains))) { + print "$domains{$domain}{'munindomain'}_mem.value $domains{$domain}{'mem'}\n"; +} + +print "\nmultigraph xen_net\n"; +for $domain (sort(keys(%domains))) { + print "$domains{$domain}{'munindomain'}_nettx.value $domains{$domain}{'nettx'}\n"; + print "$domains{$domain}{'munindomain'}_netrx.value $domains{$domain}{'netrx'}\n"; +} + +print "\nmultigraph xen_disk\n"; +for $domain (sort(keys(%domains))) { + print "$domains{$domain}{'munindomain'}_vbdrd.value $domains{$domain}{'vbdrd'}\n"; + print "$domains{$domain}{'munindomain'}_vbdwr.value $domains{$domain}{'vbdwr'}\n"; +} diff --git a/manifests/xen.pp b/manifests/xen.pp index 3dbb12c..516a59c 100644 --- a/manifests/xen.pp +++ b/manifests/xen.pp @@ -4,12 +4,17 @@ class munin::plugins::xen { munin::remoteplugin { - xen_mem: + xen-multi: source => "puppet:///modules/virtual/munin/xen_mem", - config => "user root"; + config => "user root", + ensure => absent; xen_vm: source => "puppet:///modules/virtual/munin/xen_vm", - config => "user root"; + config => "user root", + ensure => absent; + 'xen-multi': + source => 'puppet:///modules/virtual/munin/xen-multi', + config => 'user root'; } } -- cgit v1.2.3