コード例 #1
0
ファイル: kvm.py プロジェクト: joanmarkt/ToMaTo
	def getResourceUsage(self):
		disk = 0
		memory = 0
		ports = 1 if self.state == State.STARTED else 0		
		if self.host and self.getVmid():
			disk = qm.getDiskUsage(self.host, self.getVmid())
			memory = qm.getMemoryUsage(self.host, self.getVmid())
		return {"disk": disk, "memory": memory, "ports": ports}		
コード例 #2
0
ファイル: kvm.py プロジェクト: david-hock/ToMaTo
	def getResourceUsage(self):
		traffic = 0
		disk = 0
		memory = 0
		ports = 1 if self.state == State.STARTED else 0		
		if self.host and self.getVmid():
			disk = qm.getDiskUsage(self.host, self.getVmid())
			memory = qm.getMemoryUsage(self.host, self.getVmid())
		if self.state == State.STARTED:
			for iface in self.interfaceSetAll():
				dev = self.interfaceDevice(iface)
				traffic += ifaceutil.getRxBytes(self.host, dev)
				traffic += ifaceutil.getTxBytes(self.host, dev)
		return {"disk": disk, "memory": memory, "ports": ports, "traffic": traffic}		
コード例 #3
0
ファイル: kvm.py プロジェクト: m3z/ToMaTo
	def getResourceUsage(self):
		traffic = 0
		disk = 0
		memory = 0
		ports = 1 if self.state == State.STARTED else 0		
		if self.host and self.getVmid():
			disk = qm.getDiskUsage(self.host, self.getVmid())
			memory = qm.getMemoryUsage(self.host, self.getVmid())
		if self.state == State.STARTED:
			for iface in self.interfaceSetAll():
				try:
					dev = self.interfaceDevice(iface)
					traffic += ifaceutil.getRxBytes(self.host, dev)
					traffic += ifaceutil.getTxBytes(self.host, dev)
				except:
					#might fail if VM is not actually started
					self._changeState(self.getState())
		return {"disk": disk, "memory": memory, "ports": ports, "traffic": traffic}