xenserver虚拟机实时性能查看方法

2025-05-27 0 93

登陆服务器,执行脚本/opt/tools/real_time_status.sh:(该脚本的相关数据都是从xentop命令中提取的)

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51
#!/bin/bash

# Program:

# Real-time Performance

# History:

# 2014/09/29 caishunzhi First release

DIR="/opt/tools"

HOSTNAME=`/bin/hostname`

SORT=${1:-4}

NUM=${2:-6}

function get_performance()

{

#cpu

>/tmp/xentopcpu_

#/usr/sbin/xentop -i2 -d1 -b -f >/tmp/xentopcpu_

#CPU=`awk -F'[-r]' '{print $NF}' /tmp/xentopcpu_ |grep -v VBD_WR |awk 'BEGIN{sum=0}{sum+=$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}'`

sleep 1

/usr/sbin/xentop -i1 -d1 -b -f |grep -v VBD_WR >/tmp/xentop_2

TX2=`awk -F'[-r]' '{print $NF}' /tmp/xentop_2 |awk '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}' /tmp/xentop_2 |awk 'BEGIN{sum=0}{sum+=$14}END{print sum}'`

date1=`stat /tmp/xentop_1 |grep Modify |awk '{print $2,$3}'`

date2=`stat /tmp/xentop_2 |grep Modify |awk '{print $2,$3}'`

start=`date +%s -d "$date1"`

end=`date +%s -d "$date2"`

let sleep=end-start

#VM Performance Output

awk '{print $1}' /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 $2}' >/tmp/xentop_33

printf "\\n%50s %6s %12s %12s %6s %6s\\n" NAME CPU 'NETin(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",$1,$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

xenserver虚拟机实时性能查看方法

默认以流出流量(第四列)排序,显示前6名。

如果要以其它列排序,直接在脚本后接列号;如果要显示更多的虚拟机,在列号后接要显示的数量。
如下命令以IO读请求数排序(第五列),显示前10名:
[root@xen-host01 ~]# sh /opt/tools/real_time_status.sh 5 10

xenserver虚拟机实时性能查看方法

注:
默认没有显示虚拟机的cpu使用率,如果要显示,请编辑脚本,将如下两行的注释(#)去掉,保存退出,再执行脚本即可。

xenserver虚拟机实时性能查看方法

xentop官方使用说明:
How to Use the XenServer Xentop Utility

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 行业资讯 xenserver虚拟机实时性能查看方法 https://www.kuaiidc.com/68769.html

相关文章

发表评论
暂无评论