XenServer Virtual Machine Real-time performance view Method _xenserver

Source: Internet
Author: User

Login server, execute script/opt/tools/real_time_status.sh: (the script's related data is extracted from the xentop command)

#!/bin/bash # Program: # Real-time Performance # History: # 2014/09/29 Caishunzhi-A-dir= "/opt/tools" HOS Tname= '/bin/hostname ' sort=${1:-4} num=${2:-6} function Get_performance () {#cpu >/tmp/xentopcpu_ #/usr/sbin/xento P-i2-d1-b-F >/tmp/xentopcpu_ #CPU = ' awk-f ' [r] ' {print $NF} '/tmp/xentopcpu_ |grep-v vbd_wr ' |awk Um+=$2}end{print sum} ' #traffic and Io/usr/sbin/xentop-i1-d1-b-F |grep-v vbd_wr >/tmp/xentop_1 tx1= ' awk-f ' [-r] ' {print $NF} '/tmp/xentop_1 |awk ' begin{sum=0}{sum+=$9}end{print sum} ' rx1= ' awk-f ' [r] ' ' {print $NF} '/tmp/xentop _1 |awk ' begin{sum=0}{sum+=$10}end{print sum} ' vdb_rd1= ' awk-f ' [r] ' ' {print $NF} '/tmp/xentop_1 |awk ' begin{sum=0}{sum +=$13}end{print sum} ' vdb_wr1= ' awk-f ' [r] ' ' {print $NF} '/tmp/xentop_1 |awk ' begin{sum=0}{sum+=$14}end{print sum} ' SL Eep 1/usr/sbin/xentop-i1-d1-b-F |grep-v vbd_wr >/tmp/xentop_2 tx2= ' awk-f ' [-r] ' {print $NF} '/tmp/xentop_2 |aw K ' Begin{sum=0}{sum+=$9}eNd{print sum} ' rx2= ' awk-f ' [r] ' ' {print $NF} '/tmp/xentop_2 |awk ' begin{sum=0}{sum+=$10}end{print sum} ' vdb_rd2= ' awk -F ' [r] ' {print $NF} '/tmp/xentop_2 |awk ' begin{sum=0}{sum+=$13}end{print sum} ' vdb_wr2= ' awk-f ' [r] ' {print $NF} '/tm p/xentop_2 |awk ' begin{sum=0}{sum+=$14}end{print sum} ' ' date1= ' stat/tmp/xentop_1 |grep ' Modify ' {print |awk} ' d Ate2= ' stat/tmp/xentop_2 |grep Modify |awk ' {print $2,$3} ' start= ' date +%s-d "$date 1" ' end= ' date +%s-d "$date 2" ' L ET sleep=end-start #VM performance Output awk ' {print} '/tmp/xentop_1 >/tmp/vmname_ awk-f ' [r] ' ' {print $NF} ' /tmp/xentop_1 >/tmp/xentop_11 awk-f ' [-r] ' {print $NF} '/tmp/xentop_2 >/tmp/xentop_22 awk-f ' [r] ' ' {print $NF} ' /tmp/xentopcpu_ |sed ' 1,/name/d ' |awk ' {print $} ' >/tmp/xentop_33 printf ' \n%50s%6s%12s%12s%6s ' NAME CPU ' n  Etin (KB) ' Netout (KB) ' IOr iow paste/tmp/vmname_/tmp/xentop_11/tmp/xentop_22/tmp/xentop_33 |awk-v n= $sleep ' {printf "%50s%6s%12d%12d%6d %6d\n ", $, $NF, ($27-$10)/n, ($28-$11)/n, ($31-$14)/n, ($32-$15)/n} ' |sort-k ' $SORT '-rn |head-" $NUM "} while true; Do get_performance done

[Root@xen-host01 ~]# sh/opt/tools/real_time_status.sh

The default is sorted by outgoing traffic (column fourth), displaying the top 6 names.

If you want to sort by a different column, connect the column numbers directly after the script, and if you want to display more virtual machines, then the number of items to display after the column number.
The following commands are sorted by IO read requests (column fifth), displaying the top 10:
[root@xen-host01 ~]# sh/opt/tools/real_time_status.sh 5 10

Note:
Default does not show the virtual machine CPU utilization, if you want to display, please edit the script, the following two lines of comments (#) removed, save exit, and then execute the script.

Xentop Official Use instructions:
How to use the XenServer xentop Utility

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.