rearranged some stuff
[puppet_munin.git] / files / plugins / xen_memory
1 #!/bin/sh
2 #
3 # Script to monitor memory status of the xen host
4 #
5 # Parameters understood:
6 #
7 #     config    (required)
8 #     autoconf  (optional - 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 Memory'
25         echo 'graph_args --base 1000 -l 0'
26         echo 'graph_scale no'
27         echo 'graph_vlabel MB'
28         echo 'graph_category xen'
29         echo 'graph_info This graph shows of many mS wall time where used by a domain'
30                 # xm info | while read name bla value; do echo "$name $value"; done
31         /usr/sbin/xm info | while read name bla value; do
32                                 #total_memory 2047
33                                 #free_memory 1476
34                 name=`echo $name | sed -e"s/-/_/"`
35
36                 if [ "$name" = "total_memory" ]; then
37                         echo "$name.label $name"
38                         echo "$name.type GAUGE"
39                         echo "$name.min 0"
40                         echo "$name.info total memory"
41                                 fi
42                 if [ "$name" = "free_memory" ]; then
43                         echo "$name.label $name"
44                         echo "$name.type GAUGE"
45                     echo "$name.draw AREA"
46 #                    echo "$name.draw STACK"
47                         echo "$name.min 0"
48                         echo "$name.info free memory"
49                                 fi
50         done
51         exit 0
52 fi
53
54 /usr/sbin/xm info | while read name bla value; do
55         name=`echo $name | sed -e"s/-/_/"`
56         if [ "$name" = "total_memory" ]; then
57                 echo "$name.value $value"
58         fi
59         if [ "$name" = "free_memory" ]; then
60                 echo "$name.value $value"
61         fi
62 done
63