Exemplo n.º 1
0
	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}		
Exemplo n.º 2
0
	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}		
Exemplo n.º 3
0
Arquivo: kvm.py Projeto: 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}