debuggers.hg

view tools/xenballoon/xenballoon-monitor @ 21067:b4a1832a916f

Update Xen version to 4.0.0-rc6
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 09 18:18:05 2010 +0000 (2010-03-09)
parents 8373971089a7
children
line source
1 #!/bin/bash
2 #
3 # xenballoon-monitor - monitor certain stats from xenballoond
4 # (run in dom0 with "watch -d xenballoon-monitor" for xentop-like output)
5 # updated 090610 to include tmem stats
6 #
7 # Copyright (C) 2009 Oracle Corporation and/or its affiliates.
8 # All rights reserved
9 # Written by: Dan Magenheimer <dan.magenheimer@oracle.com>
10 #
11 # Hint: Use "xm sched-credit -d 0 -w 2000" to watch on heavily loaded machines
12 #
13 TMEMTMP=$(/bin/mktemp -q /tmp/xenballoon-monitor.XXXXXX)
14 echo "id mem-kb tgt-kb commit swapin swapout pgin pgout preswap precache"
15 for i in `xenstore-list /local/domain`; do
16 if [ "$i" -ne 0 ]; then
17 tot=0; tgt=0; sin=0; sout=0; pgin=0; pgout=0; cmt=0; up=0; idle=0;
18 act=0; preswap=0; precache=0
19 if xenstore-exists /local/domain/$i/memory/meminfo; then
20 tot=`xenstore-read /local/domain/$i/memory/meminfo | grep MemTotal \
21 | sed 's/[^1-9]*\([1-9][0-9]*\).*/\1/'`
22 cmt=`xenstore-read /local/domain/$i/memory/meminfo | grep Committed_AS \
23 | sed 's/[^1-9]*\([1-9][0-9]*\).*/\1/'`
24 fi
25 if xenstore-exists /local/domain/$i/memory/selftarget; then
26 tgt=`xenstore-read /local/domain/$i/memory/selftarget`
27 fi
28 if xenstore-exists /local/domain/$i/memory/vmstat; then
29 sin=$(xenstore-read /local/domain/$i/memory/vmstat | tr '\\\n' '\n' \
30 | grep pswpin | cut -d" " -f2)
31 sout=$(xenstore-read /local/domain/$i/memory/vmstat | tr '\\\n' '\n' \
32 | grep pswpout | cut -d" " -f2)
33 pgin=$(xenstore-read /local/domain/$i/memory/vmstat | tr '\\\n' '\n' \
34 | grep pgpgin | cut -d" " -f2)
35 pgout=$(xenstore-read /local/domain/$i/memory/vmstat | tr '\\\n' '\n' \
36 | grep pgout | cut -d" " -f2)
37 fi
38 xm tmem-list --all --long > $TMEMTMP
39 precache=`grep "C=CI:$i" $TMEMTMP | sed 's/C=CI.*Ec:\([0-9][0-9]*\).*/\1/'`
40 if xenstore-exists /local/domain/$i/memory/preswap; then
41 preswap=`xenstore-read /local/domain/$i/memory/preswap`
42 printf "%2d %8d%8d%8d%7d%8d%9d%9d%9d%9d\n" $i $tot $tgt $cmt $sin $sout $pgin $pgout $preswap $precache
43 else
44 printf "%2d %8d%8d%8d%9d%9d%10d%10d\n" $i $tot $tgt $cmt $sin $sout $pgin $pgout
45 fi
46 fi
47 done
48 echo -n Free memory: `xm info | grep free | sed 's/[^1-9]*\([1-9][0-9]*\).*/\1/'` MiB " "
49 tmem_free_pages=`grep "G=" $TMEMTMP | sed 's/G=.*Ta:\([0-9][0-9]*\).*/\1/'`
50 if [ ! -z "$tmem_free_pages" ]; then
51 let "tmem_free_mb=$tmem_free_pages/256"
52 echo -n Idle tmem: $tmem_free_mb MiB " "
53 fi
54 tmem_eph_pages=`grep "G=" $TMEMTMP | sed 's/G=.*Ec:\([0-9][0-9]*\).*/\1/'`
55 if [ ! -z "$tmem_eph_pages" ]; then
56 let "tmem_eph_mb=$tmem_eph_pages/256"
57 echo -n Ephemeral tmem: $tmem_eph_mb MiB
58 fi
59 echo ""