From da5a70f654cbbd2a455fd5ab0680d2621d4087b8 Mon Sep 17 00:00:00 2001 From: Matthias Pfafferodt Date: Sat, 2 Dec 2006 21:41:08 +0100 Subject: [PATCH] Initial version --- plugins/other/xen | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 plugins/other/xen diff --git a/plugins/other/xen b/plugins/other/xen new file mode 100755 index 00000000..eab77151 --- /dev/null +++ b/plugins/other/xen @@ -0,0 +1,77 @@ +#!/bin/sh +# +# Script to monitor CPU usage of Xen domains +# +# Author: unknown +# Modifications: Matthias Pfafferodt, syntron@web.de +# License: GPL v. 2 +# +# Parameters understood: +# +# conifg (required) +# autoconf (optional - used by munin-config) +# +#%# family=auto +#%# capabilities=autoconf + +# statefile: name of seen xen domains +statefile="/var/lib/munin/plugin-state/munin-plugin-xen.state" + +if [ "$1" = "autoconf" ]; then + if which xm > /dev/null ; then + echo yes + exit 0 + fi + echo "no (xm not found)" + exit 1 +fi + +if [ "$1" = "config" ]; then + + if [ ! -e $statefile ]; then + touch $statefile + fi + + echo 'graph_title Xen Domain Utilerisation' + echo 'graph_args --base 1000 -l 0 --upper-limit 100 --rigid' +# echo 'graph_scale no' + echo 'graph_vlabel %' + echo 'graph_category xen' + echo 'graph_info This graph shows how many % of the CPU time where used by a domain' + + xm list | grep -v "^Name .* Time(s)$" | \ + while read name domid mem cpu state time console; do + name=`echo $name | sed -e"s/-/_/"` + TEST=`less $statefile | grep "^${name}$" | wc -l` + if [ $TEST -ne 1 ]; then + echo "$name" >> $statefile + fi + done + + FIRST=1 + cat $statefile | sort | \ + while read name; do + echo "$name.label $name" + echo "$name.type COUNTER" + if [ $FIRST -eq 1 ]; then + echo "$name.draw AREA" + FIRST=0 + else + echo "$name.draw STACK" + fi + echo "$name.min 0" + echo "$name.max 100" + echo "$name.info % of the CPU time spend for $name" + done + exit 0 +fi + +xm list | grep -v "^Name .* Time(s)$" | \ +while read name domid mem cpu state time console; do + name=`echo $name | sed -e "s/-/_/"` + # only seconds + time=`echo $time | sed -e "s/\..//"` + # scale 60s/60s => 100%/60s + time=`echo "$time*100/60" | bc` + echo "$name.value $time" +done