public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
To: kvm-ppc-devel <kvm-ppc-devel@lists.sourceforge.net>,
	Hollis Blanchard <hollisb@us.ibm.com>,
	CBORNTRA@de.ibm.com,
	"kvm-devel@lists.sourceforge.net"
	<kvm-devel@lists.sourceforge.net>
Subject: script for watching kvm_stat
Date: Mon, 17 Mar 2008 16:09:17 +0100	[thread overview]
Message-ID: <47DE899D.7000207@linux.vnet.ibm.com> (raw)

[-- 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

             reply	other threads:[~2008-03-17 15:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17 15:09 Christian Ehrhardt [this message]
2008-03-19 12:26 ` script for watching kvm_stat Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47DE899D.7000207@linux.vnet.ibm.com \
    --to=ehrhardt@linux.vnet.ibm.com \
    --cc=CBORNTRA@de.ibm.com \
    --cc=hollisb@us.ibm.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=kvm-ppc-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox