summaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorMarcel Haerry <haerry@puzzle.ch>2011-08-04 10:22:48 +0200
committerMarcel Haerry <haerry@puzzle.ch>2011-08-04 10:22:48 +0200
commit447041b01494690975d078776a85f4a3fd4e64fa (patch)
tree0d09932e8466de8208144aa034de401398151ca6 /files
parent553fbe3e1d3c6865172c1db8cf93d69fb936dc18 (diff)
parenteb953716cd545f86972e85d983b5862c194f5aed (diff)
merge with immerda/master
Diffstat (limited to 'files')
-rw-r--r--files/config/host/munin.conf.header.CentOS46
-rw-r--r--files/config/host/munin.conf.header.Debian75
-rwxr-xr-xfiles/plugins/nagios_hosts28
-rwxr-xr-xfiles/plugins/nagios_perf_35
-rwxr-xr-xfiles/plugins/nagios_svc33
-rwxr-xr-xfiles/plugins/xen11
-rwxr-xr-xfiles/plugins/xen-cpu20
-rw-r--r--files/plugins/xen_mem9
-rw-r--r--files/plugins/xen_traffic_all55
-rwxr-xr-xfiles/plugins/xen_vbd34
-rw-r--r--files/plugins/xen_vm7
11 files changed, 197 insertions, 156 deletions
diff --git a/files/config/host/munin.conf.header.CentOS b/files/config/host/munin.conf.header.CentOS
index dcadd6b..413cd84 100644
--- a/files/config/host/munin.conf.header.CentOS
+++ b/files/config/host/munin.conf.header.CentOS
@@ -1,21 +1,51 @@
# Example configuration file for Munin, generated by 'make build'
# The next three variables specifies where the location of the RRD
-# databases, the HTML output, and the logs, severally. They all
-# must be writable by the user running munin-cron.
-dbdir /var/lib/munin
-htmldir /var/www/html/munin/
-logdir /var/log/munin
-rundir /var/run/munin
+# databases, the HTML output, logs and the lock/pid files. They all
+# must be writable by the user running munin-cron. They are all
+# defaulted to the values you see here.
+#
+# dbdir /var/lib/munin
+# htmldir /var/www/html/munin
+# logdir /var/log/munin
+# rundir /var/run/munin
+#
+# tmpldir /etc/munin/templates
-# Where to look for the HTML templates
-tmpldir /etc/munin/templates
+# (Exactly one) directory to include all files from.
+#
+# includedir /etc/munin/munin-conf.d
# Make graphs show values per minute instead of per second
#graph_period minute
+# Graphics files are normaly generated by munin-graph, no matter if
+# the graphs are used or not. You can change this to
+# on-demand-graphing by following the instructions in
+# http://munin.projects.linpro.no/wiki/CgiHowto
+#
graph_strategy cgi
+# munin-cgi-graph is invoked by the web server up to very many times at the
+# same time. This is not optimal since it results in high CPU and memory
+# consumption to the degree that the system can thrash. Again the default is
+# 6. Most likely the optimal number for max_cgi_graph_jobs is the same as
+# max_graph_jobs.
+#
+#munin_cgi_graph_jobs 6
+
+# If the automatic CGI url is wrong for your system override it here:
+#
+#cgiurl_graph /cgi-bin/munin-cgi-graph
+
+# munin-graph runs in parallel, the number of concurrent processes is
+# 6. If you want munin-graph to not be parallel set to 0. If set too
+# high it will slow down munin-graph. Some experiments are needed to
+# determine how many are optimal on your system. On a multi-core
+# system with good SCSI disks the number can probably be quite high.
+#
+#max_graph_jobs 6
+
# Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime
# something changes (OK -> WARNING, CRITICAL -> OK, etc)
#contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm
diff --git a/files/config/host/munin.conf.header.Debian b/files/config/host/munin.conf.header.Debian
new file mode 100644
index 0000000..082f01f
--- /dev/null
+++ b/files/config/host/munin.conf.header.Debian
@@ -0,0 +1,75 @@
+# Example configuration file for Munin, generated by 'make build'
+
+# The next three variables specifies where the location of the RRD
+# databases, the HTML output, and the logs, severally. They all
+# must be writable by the user running munin-cron.
+dbdir /var/lib/munin
+htmldir /var/www/munin
+logdir /var/log/munin
+rundir /var/run/munin
+
+# Where to look for the HTML templates
+tmpldir /etc/munin/templates
+
+# Make graphs show values per minute instead of per second
+#graph_period minute
+
+# Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime
+# something changes (OK -> WARNING, CRITICAL -> OK, etc)
+#contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm
+#contact.anotheruser.command mail -s "Munin notification" anotheruser@blibb.comm
+#
+# For those with Nagios, the following might come in handy. In addition,
+# the services must be defined in the Nagios server as well.
+#contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg
+
+#contacts me
+#contact.me.command mail -s "Munin notification ${var:group} :: ${var:host} :: ${var:graph_title}" root
+#contact.me.always_send warning critical
+
+# a simple host tree
+#[localhost]
+# address 127.0.0.1
+# use_node_name yes
+
+#
+# A more complex example of a host tree
+#
+## First our "normal" host.
+# [fii.foo.com]
+# address foo
+#
+## Then our other host...
+# [fay.foo.com]
+# address fay
+#
+## Then we want totals...
+# [foo.com;Totals] #Force it into the "foo.com"-domain...
+# update no # Turn off data-fetching for this "host".
+#
+# # The graph "load1". We want to see the loads of both machines...
+# # "fii=fii.foo.com:load.load" means "label=machine:graph.field"
+# load1.graph_title Loads side by side
+# load1.graph_order fii=fii.foo.com:load.load fay=fay.foo.com:load.load
+#
+# # The graph "load2". Now we want them stacked on top of each other.
+# load2.graph_title Loads on top of each other
+# load2.dummy_field.stack fii=fii.foo.com:load.load fay=fay.foo.com:load.load
+# load2.dummy_field.draw AREA # We want area instead the default LINE2.
+# load2.dummy_field.label dummy # This is needed. Silly, really.
+#
+# # The graph "load3". Now we want them summarised into one field
+# load3.graph_title Loads summarised
+# load3.combined_loads.sum fii.foo.com:load.load fay.foo.com:load.load
+# load3.combined_loads.label Combined loads # Must be set, as this is
+# # not a dummy field!
+#
+## ...and on a side note, I want them listen in another order (default is
+## alphabetically)
+#
+# # Since [foo.com] would be interpreted as a host in the domain "com", we
+# # specify that this is a domain by adding a semicolon.
+# [foo.com;]
+# node_order Totals fii.foo.com fay.foo.com
+#
+
diff --git a/files/plugins/nagios_hosts b/files/plugins/nagios_hosts
deleted file mode 100755
index 04fe8ed..0000000
--- a/files/plugins/nagios_hosts
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-
-if [ "$1" = "config" ]; then
- echo 'graph_title Nagios host stats'
- echo 'graph_args --base 1000 -l 0'
- echo 'graph_vlabel hosts'
- echo 'graph_category nagios'
- echo 'graph_info The number of hosts checked by nagios'
- echo 'up.label up'
- echo 'up.draw AREA'
- echo 'up.info number of hosts UP'
- echo 'down.label down'
- echo 'down.draw STACK'
- echo 'down.info number of hosts DOWN'
- echo 'unr.label unr'
- echo 'unr.draw STACK'
- echo 'unr.info number of hosts UNREACHABLE'
-
- exit 0
-fi
-
-echo -n 'up.value '
-nagios2stats --mrtg --data NUMHSTUP
-echo -n 'down.value '
-nagios2stats --mrtg --data NUMHSTDOWN
-echo -n 'unr.value '
-nagios2stats --mrtg --data NUMHSTUNR
-
diff --git a/files/plugins/nagios_perf_ b/files/plugins/nagios_perf_
deleted file mode 100755
index f819def..0000000
--- a/files/plugins/nagios_perf_
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-
-NAME=$(basename $0)
-
-TYPE=${NAME##nagios_perf_}
-
-[ "x$TYPE" = 'xhosts' ] && TYPE_ABBR=HST
-[ "x$TYPE" = 'xsvc' ] && TYPE_ABBR=SVC
-[ -z "$TYPE_ABBR" ] && echo "unknown type $TYPE" >&2 && exit 1
-
-if [ "$1" = "config" ]; then
- echo "graph_title Nagios $TYPE performance stats"
- echo "graph_args --base 1000"
- echo "graph_vlabel seconds"
- echo "graph_category nagios"
- echo "graph_info Check performance statistics"
-
- echo "act_lat_$TYPE_ABBR.label act lat"
- echo "act_lat_$TYPE_ABBR.type GAUGE"
- echo "act_lat_$TYPE_ABBR.draw AREA"
- echo "act_lat_$TYPE_ABBR.cdef act_lat_$TYPE_ABBR,1000,/"
- echo "act_lat_$TYPE_ABBR.info average latency of active checks over the last 5 minutes"
-
- echo "act_ext_$TYPE_ABBR.label act ext"
- echo "act_ext_$TYPE_ABBR.type GAUGE"
- echo "act_ext_$TYPE_ABBR.draw LINE1"
- echo "act_ext_$TYPE_ABBR.cdef act_ext_$TYPE_ABBR,1000,/"
- echo "act_ext_$TYPE_ABBR.info average execution time of active checks over the last 5 minutes"
-
- exit 0
-fi
-
-echo "act_lat_$TYPE_ABBR.value " $(nagios2stats --mrtg --data AVGACT${TYPE_ABBR}LAT)
-echo "act_ext_$TYPE_ABBR.value " $(nagios2stats --mrtg --data AVGACT${TYPE_ABBR}EXT)
-
diff --git a/files/plugins/nagios_svc b/files/plugins/nagios_svc
deleted file mode 100755
index 3938999..0000000
--- a/files/plugins/nagios_svc
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-if [ "$1" = "config" ]; then
- echo 'graph_title Nagios service stats'
- echo 'graph_args --base 1000 -l 0'
- echo 'graph_vlabel services'
- echo 'graph_category nagios'
- echo 'graph_info The number of services checked by nagios'
- echo 'ok.label ok'
- echo 'ok.draw AREA'
- echo 'ok.info number of services OK'
- echo 'warn.label warn'
- echo 'warn.draw STACK'
- echo 'warn.info number of services WARNING'
- echo 'crit.label crit'
- echo 'crit.draw STACK'
- echo 'crit.info number of services CRITICAL'
- echo 'unkn.label unkn'
- echo 'unkn.draw STACK'
- echo 'unkn.info number of services UNKNOWN'
-
- exit 0
-fi
-
-echo -n 'ok.value '
-nagios2stats --mrtg --data NUMSVCOK
-echo -n 'warn.value '
-nagios2stats --mrtg --data NUMSVCWARN
-echo -n 'crit.value '
-nagios2stats --mrtg --data NUMSVCCRIT
-echo -n 'unkn.value '
-nagios2stats --mrtg --data NUMSVCUNKN
-
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(<I>){
- 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))