rearranged some stuff
[puppet_munin.git] / files / plugins / xen
1 #!/bin/sh
2 #
3 # Script to monitor CPU usage of Xen domains
4 #
5 # Parameters understood:
6 #
7 #     conifg    (required)
8 #     autoconf  (optinal - used by munin-config)
9 #
10
11 MAXDOMAINS=16
12
13 if [ "$1" = "autoconf" ]; then
14         if which xm > /dev/null ; then
15                 echo yes
16                 exit 0
17         fi
18         echo "no (xm not found)"
19         exit 1
20 fi
21
22 if [ "$1" = "config" ]; then
23
24         echo 'graph_title Xen Domain Utilerisation'
25         echo 'graph_args --base 1000 -l 0'
26         echo 'graph_scale no'
27         echo 'graph_vlabel mS'
28         echo 'graph_category xen'
29         echo 'graph_info This graph shows of many mS wall time where used by a domain'
30         /usr/sbin/xm list | grep -v "^Name .* Console$" | \
31         while read name domid mem cpu state time console; do
32                 name=`echo $name | sed -e"s/-/_/"`
33                 echo "$name.label $name"
34                 echo "$name.type COUNTER"
35 #               if [ "$name" = "Domain_0" ]; then
36 #                       echo "$name.draw AREA"
37 #               else
38 #                       echo "$name.draw STACK"
39 #               fi
40                 echo "$name.min 0"
41                 echo "$name.info Wall clock time spend for $name"
42         done
43         exit 0
44 fi
45
46 /usr/sbin/xm list | grep -v "^Name" | grep -v "^Name .* Console$" | \
47 while read name domid mem cpu state time console; do
48         name=`echo $name | sed -e"s/-/_/"`
49         time=`echo $time | sed -e "s/\.//"`
50         echo "$name.value $time"
51 done
52