Beispiel #1
0
def dom0Info(xenHost):

	tool = Tools()
	db = DBManager()
	dom0 = Dom0(xenHost)
	
	# Check if dom0 contain dom0_info on db
	dom0ID = db.returnDom0Id(dom0)
	
	if dom0ID != None:
		memory = psutil.phymem_usage()
		cpuTotal = psutil.cpu_percent(interval=1, percpu=True)
		disk = psutil.disk_usage("/")
		
		dom0.id = dom0ID[0]
		dom0.memTotal = tool.convertBytes(memory.total)
		dom0.memUsed = tool.convertBytes(memory.used)
		dom0.memFree = tool.convertBytes(memory.free)
		dom0.memPercent = memory.percent
		dom0.diskTotal = tool.convertBytes(disk.total)
		dom0.diskUsed = tool.convertBytes(disk.used)
		dom0.diskFree = tool.convertBytes(disk.free)
		dom0.diskPercent = disk.percent
		dom0.cpu = tool.returnCpuInfo(cpuTotal)
		if db.checkDom0Info(str(dom0ID[0])) == None:
			db.insertDom0Info(dom0)
		else:
			db.updateDom0Info(dom0)
	else:
		print "Invalid dom0"