public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* script for watching kvm_stat
@ 2008-03-17 15:09 Christian Ehrhardt
  2008-03-19 12:26 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Ehrhardt @ 2008-03-17 15:09 UTC (permalink / raw)
  To: kvm-ppc-devel, Hollis Blanchard, CBORNTRA,
	kvm-devel@lists.sourceforge.net

[-- Attachment #1: Type: text/plain, Size: 667 bytes --]

I added the kvm_stat support to ppc to watch my guest while executing e.g. to check things like "what does my guest do when I see nothing" ;-)
To be able to do that I also needed a script that reports in a iostat/vmstat like style, because of that I wrote a small shell script.
Additionally my colleague Christian Bornträger had the need for a top style output and wrote a script for that need.
I attached both to help everyone experimenting with kvm_stat.

They are just small helpers and might still contain issues, feel free to comment, correct, whatever ;-)

-- 

Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

[-- Attachment #2: kvmstat --]
[-- Type: text/plain, Size: 1231 bytes --]

#!/bin/bash

kvmstatdir="/sys/kernel/debug/kvm"
duration=2
summode="no"
lph=20
line=-1
if [ $summode = "no" ]
then
	declare -a values
	counter=0
	for i in `ls $kvmstatdir`
	do
		values[$counter]=0
		counter=`expr $counter + 1`
	done
fi

kvmstat_header() {
	for i in `ls $kvmstatdir`
	do
		printf "|%16s " $i
	done
	printf "|\n"
}

USAGE="Usage: `basename $0` [-d arg] [-l arg] [-hs]"
while getopts hvsd:l: OPT; do
    case "$OPT" in
	h)	echo $USAGE
		echo "d - sleep between reported lines"
		echo "l - number of lines betweeen headers"
		echo "s - summary mode (default is difference since last print)"
		exit 0
		;;
	v)	echo "`basename $0` version 0.1"
		exit 0
		;;
	d)	duration=$OPTARG
		;;
	l)	lph=$OPTARG
		;;
	s)	summode="yes"
		;;
	\?)	# getopts issues an error message
		echo $USAGE >&2
		exit 1
		;;
    esac
done

while true
do
	line=`expr $line + 1`
	line=`expr $line % $lph`
	if [ $line -eq "0" ]
	then
		kvmstat_header
	fi

	counter=0
	for i in `ls $kvmstatdir`
	do
		val=`cat $kvmstatdir/$i`
		if [ $summode = "no" ]
		then
			cval=$val;
			val=`expr $cval - ${values[$counter]}`
			values[$counter]=$cval
			counter=`expr $counter + 1`	
		fi
        	printf "|%16d " $val
	done
	printf "|\n"

	sleep $duration
done

[-- Attachment #3: kvmtop --]
[-- Type: text/plain, Size: 65 bytes --]

#!/bin/bash
watch --differences -n 1 " kvmtop_once | sort -n -r"

[-- Attachment #4: kvmtop_once --]
[-- Type: text/plain, Size: 92 bytes --]

#!/bin/bash
cd /sys/kernel/debug/kvm
for d in *
do
cat $d | tr -d \\n
echo -e :\\t $d

done

[-- Attachment #5: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #6: Type: text/plain, Size: 158 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-03-19 12:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-17 15:09 script for watching kvm_stat Christian Ehrhardt
2008-03-19 12:26 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox