检查ESXi主机是否使能VT-x/AMD-V

简介

Intel VT-x和AMD AMD-V硬件虚拟化特性能够使虚拟机更高效的运行。 如果BIOS中使能该选项,VMware ESXi主机能够利用此功能来提高性能。本文介绍如何在ESXi主机中查看已经使能了该特性。

使用esxcfg-info命令查看

在ESXi shell中可以运行esxcfg-info命令来查看VT-X/ADM-V的配置和使用情况。

~ # esxcfg-info -w | grep "HV Support"
      |----HV Support...............................................3
下面的表格中,列出了HV Support支持的值及含义

含义
0VT-X/AMD-V support is not avaliable for this hardware
1VT-X/AMD-V might be avaiiable on this CPU but it is not supported for this hardware
2VT-X/AMD-V is available but is currently not enabled in the BIOS
VT-X/AMD-V is enabled in the BIOS and can be used






脚本批量查询

编写了一个Python脚本,支持批量查询:

#!/usr/bin/env python

import os
import paramiko

def ping(host, cnt):
    '''ping test'''
    import subprocess,traceback, platform
    print platform.system()
    if platform.system()=='Windows':
        cmd = 'ping -n %d %s' % (cnt, host)
    else:
        cmd = 'ping -c %d %s' % (cnt, host)
        
    try:
        p = subprocess.Popen(args=cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        (stdoutput,erroutput) = p.communicate()
        # print stdoutput
    except Exception, e:
        traceback.print_exc()
    
    if platform.system()=='Windows':
        return stdoutput.find('Received = %d' % cnt )>=0
    else:
        return stdoutput.find('%d received' % cnt)>=0

def collect_platform_info(ip, fd):
    fd.write("%-20s" % ip)
    
    if not ping(ip, 3):
        fd.write("--\n")
        return
    
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(ip, 22, "root", "infinera")
    
    stdin, stdout, stderr = ssh.exec_command("esxcfg-info -w | grep 'HV Support'")
    for l in stdout.readlines():
        fd.write("%s\n" % l.strip())
 
    ssh.close()

if __name__ == "__main__":
    result_file = "/home/infinera/server_stats.txt"
    os.remove(result_file)
    fd_res = open(result_file, "w")
    fd_res.write("%-20s|%s\n" % ("HV IP", "VT-X"))
    fd_res.write(80 * "-")
    fd_res.write("\n")
        
    fd_ips = open("/home/infinera/server_list.txt", "r")
    for l in fd_ips.readlines():
        ip = l.strip()
        collect_platform_info(ip, fd_res)
    
    fd_ips.close()
    fd_res.close()

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值