root / plugins / virtualization / xen @ e5ce7492
Historique | Voir | Annoter | Télécharger (1,99 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# |
| 3 |
# Script to monitor CPU usage of Xen domains |
| 4 |
# |
| 5 |
# Author: unknown |
| 6 |
# Modifications: Matthias Pfafferodt, syntron@web.de, Roland Mohrbacher |
| 7 |
# License: GPL v. 2 |
| 8 |
# |
| 9 |
# Parameters understood: |
| 10 |
# |
| 11 |
# conifg (required) |
| 12 |
# autoconf (optional - used by munin-config) |
| 13 |
# |
| 14 |
#%# family=auto |
| 15 |
#%# capabilities=autoconf |
| 16 |
|
| 17 |
# statefile: name of seen xen domains |
| 18 |
statefile="/var/lib/munin/plugin-state/munin-plugin-xen.state" |
| 19 |
|
| 20 |
if [ "$1" = "autoconf" ]; then |
| 21 |
if which xm > /dev/null ; then |
| 22 |
echo yes |
| 23 |
exit 0 |
| 24 |
fi |
| 25 |
echo "no (xm not found)" |
| 26 |
exit 1 |
| 27 |
fi |
| 28 |
|
| 29 |
if [ "$1" = "config" ]; then |
| 30 |
|
| 31 |
if [ ! -e $statefile ]; then |
| 32 |
touch $statefile |
| 33 |
fi |
| 34 |
|
| 35 |
echo 'graph_title Xen Domain Utilerisation' |
| 36 |
echo 'graph_args --base 1000 -l 0 --upper-limit 100 --rigid' |
| 37 |
echo 'graph_scale no' |
| 38 |
echo 'graph_vlabel %' |
| 39 |
echo 'graph_category xen' |
| 40 |
echo 'graph_info This graph shows how many % of the CPU time where used by a domain' |
| 41 |
|
| 42 |
xm list | grep -v "^Name .* Time(s)$" | \ |
| 43 |
while read name domid mem cpu state time console; do |
| 44 |
name=`echo $name | sed -e"s/[-.]/_/g"` |
| 45 |
TEST=`less $statefile | grep "^${name}$" | wc -l`
|
| 46 |
if [ $TEST -ne 1 ]; then |
| 47 |
echo "$name" >> $statefile |
| 48 |
fi |
| 49 |
done |
| 50 |
|
| 51 |
FIRST=1 |
| 52 |
cat $statefile | sort | \ |
| 53 |
while read name; do |
| 54 |
echo "$name.label $name" |
| 55 |
echo "$name.type COUNTER" |
| 56 |
if [ $FIRST -eq 1 ]; then |
| 57 |
echo "$name.draw AREA" |
| 58 |
FIRST=0 |
| 59 |
else |
| 60 |
echo "$name.draw STACK" |
| 61 |
fi |
| 62 |
echo "$name.min 0" |
| 63 |
echo "$name.max 100" |
| 64 |
echo "$name.info % of the CPU time spend for $name" |
| 65 |
done |
| 66 |
exit 0 |
| 67 |
fi |
| 68 |
|
| 69 |
xm list | grep -v "^Name .* Time(s)$" | \ |
| 70 |
while read name domid mem cpu state time console; do |
| 71 |
name=`echo $name | sed -e "s/[-.]/_/g"` |
| 72 |
# only seconds |
| 73 |
time=`echo $time | sed -e "s/\..//"` |
| 74 |
# scale 60s/60s => 100%/60s |
| 75 |
time=`echo "$time*100/60" | bc` |
| 76 |
echo "$name.value $time" |
| 77 |
done |
