我们在公司内部运行Citrix XenServer和Gentoo / Xen虚拟化平台.通常,我们使用XenServer,我们有共享存储(SAN,iSCSI或其他)和Gentoo / Xen,我们希望使用本地存储.
使用XenServer,我们可以获得平台上Dom0和各种DomU的详细利用率统计信息.我们还通过SNMP(Cacti)监控DomUs.我们可以使用SNMP或SAR或其他任何东西从Gentoo / Xen DomU获取统计数据,但我们无法从Dom0获得良好的使用统计数据.如果没有这个,我们无法评估我们使用硬件的效率以及何时需要考虑构建.
我相信这一定是一个已经解决的问题,但是我的Google-Fu让我失望了,所以我希望这里的某些人可能会有一些想法.
干杯
戴夫
解决方法@H_301_12@
关于您希望从dom0中收集哪种统计数据,您的问题有点不清楚,但我认为您正在寻找的是了解现有硬件资源的分配方式.
我们使用libvirt的Python绑定获得这些信息取得了巨大成功.这是一个Python脚本片段,说明了这个想法:
#!/usr/bin/env python
import sys
import libvirt
def main(options,args):
hypervisors = sys.argv[1:]
print "%16s%18s%18s%18s" % ("dom0 IP","Free Memory (MB)","Disk Used (GB)","Disk Free (GB)")
for ip in hypervisors:
# this assumes "remote" connection to libvirtd using TCP
url = "xen+tcp://%s" % (ip)
conn = libvirt.open(url)
# you may want to do more error handling here
if conn == None:
continue
mem = conn.getFreeMemory() / 1048576 #convert bytes -> megabytes
pool = conn.storagePoolLookupByName('vol0')
# a refresh() is necessary because libvirtd's internal information isn't
# always in sync with the host.
pool.refresh(0)
disk_info = pool.info()
disk_used = disk_info[2] / 1073741824 #convert bytes -> gigabytes
disk_free = disk_info[3] / 1073741824 #convert bytes -> gigabytes
print "%16s%18d%18s%18d" % (ip,mem,disk_used,disk_free)
if __name__ == '__main__':
sys.exit(main(options,args))
我们使用libvirt的Python绑定获得这些信息取得了巨大成功.这是一个Python脚本片段,说明了这个想法:
#!/usr/bin/env python import sys import libvirt def main(options,args): hypervisors = sys.argv[1:] print "%16s%18s%18s%18s" % ("dom0 IP","Free Memory (MB)","Disk Used (GB)","Disk Free (GB)") for ip in hypervisors: # this assumes "remote" connection to libvirtd using TCP url = "xen+tcp://%s" % (ip) conn = libvirt.open(url) # you may want to do more error handling here if conn == None: continue mem = conn.getFreeMemory() / 1048576 #convert bytes -> megabytes pool = conn.storagePoolLookupByName('vol0') # a refresh() is necessary because libvirtd's internal information isn't # always in sync with the host. pool.refresh(0) disk_info = pool.info() disk_used = disk_info[2] / 1073741824 #convert bytes -> gigabytes disk_free = disk_info[3] / 1073741824 #convert bytes -> gigabytes print "%16s%18d%18s%18d" % (ip,mem,disk_used,disk_free) if __name__ == '__main__': sys.exit(main(options,args))