summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Cohen <bencoh@notk.org>2011-12-25 20:37:28 +0100
committerBenjamin Cohen <bencoh@notk.org>2011-12-25 20:37:28 +0100
commitc619bf86e2f6ba9cd84e1f6ec70ae7a3a0ffee0f (patch)
treeb22aeb1d1ee5c1e9d7d575c3ba3ccf0d55ef2a6e
parentfc73dc3225fb010516d1157b61d82319445ff6e1 (diff)
Add top command (launch top on a few pids)
-rw-r--r--host_config/bash_completion.d-kvm-wrapper2
-rwxr-xr-xkvm-wrapper.sh14
2 files changed, 15 insertions, 1 deletions
diff --git a/host_config/bash_completion.d-kvm-wrapper b/host_config/bash_completion.d-kvm-wrapper
index c25950c..f9ae450 100644
--- a/host_config/bash_completion.d-kvm-wrapper
+++ b/host_config/bash_completion.d-kvm-wrapper
@@ -13,7 +13,7 @@ _kvm_wrapper()
command=${COMP_WORDS[1]}
if [[ "$COMP_CWORD" == "1" ]]; then
- COMPREPLY=( $( compgen -W 'help attach create-desc start stop list screen create bootstrap remove edit create-disk status mount-disk umount-disk migrate receive-migrate save-state load-state balloon monitor serial conf' -- "$cur" ) )
+ COMPREPLY=( $( compgen -W 'help attach create-desc start stop list screen create bootstrap remove edit create-disk status mount-disk umount-disk migrate receive-migrate save-state load-state balloon monitor serial conf top' -- "$cur" ) )
return 0
fi
diff --git a/kvm-wrapper.sh b/kvm-wrapper.sh
index 101cbd3..d101fb4 100755
--- a/kvm-wrapper.sh
+++ b/kvm-wrapper.sh
@@ -406,6 +406,14 @@ function kvm_status ()
fi
}
+function kvm_top ()
+{
+ local nodelist="{local,$KVM_CLUSTER_NODE}"
+ local pattern="$PID_DIR/$nodelist:*-vm.pid"
+ pidlist=$(eval cat $pattern 2>/dev/null | xargs | sed 's/ /,/g')
+ top -d 2 -cp $pidlist
+}
+
# Main function : start a virtual machine
function kvm_start_vm ()
{
@@ -904,6 +912,8 @@ function print_help ()
echo -e ""
echo -e " $SCRIPT_NAME status [virtual-machine]"
echo -e " $SCRIPT_NAME list [node]"
+ echo -e " $SCRIPT_NAME top"
+ echo -e " $SCRIPT_NAME conf"
echo
echo -e " $SCRIPT_NAME balloon virtual-machine target_RAM"
echo -e " $SCRIPT_NAME create [flags] virtual-machine #for flag list, try $SCRIPT_NAME help create"
@@ -944,6 +954,10 @@ case "$1" in
else kvm_status "all"; fi
exit 0
;;
+ top)
+ kvm_top
+ exit 0
+ ;;
rundisk)
if [[ $# -eq 2 ]]; then
kvm_run_disk "$2"