connection: Better organize stats methods

This commit is contained in:
Cole Robinson 2011-04-14 12:20:02 -04:00
parent c6dcde8288
commit 845e6aa57e
1 changed files with 22 additions and 29 deletions

View File

@ -1575,11 +1575,6 @@ class vmmConnection(vmmGObject):
######################## ########################
# Stats getter methods # # Stats getter methods #
######################## ########################
def _get_record_helper(self, record_name):
if len(self.record) == 0:
return 0
return self.record[0][record_name]
def cpu_time_vector(self): def cpu_time_vector(self):
vector = [] vector = []
stats = self.record stats = self.record
@ -1596,18 +1591,6 @@ class vmmConnection(vmmGObject):
cpudata = cpudata[0:limit] cpudata = cpudata[0:limit]
return cpudata return cpudata
def cpu_time_percentage(self):
return self._get_record_helper("cpuTimePercent")
def stats_memory(self):
return self._get_record_helper("memory")
def pretty_stats_memory(self):
return util.pretty_mem(self.stats_memory())
def stats_memory_percentage(self):
return self._get_record_helper("memoryPercent")
def stats_memory_vector(self): def stats_memory_vector(self):
vector = [] vector = []
stats = self.record stats = self.record
@ -1618,32 +1601,42 @@ class vmmConnection(vmmGObject):
vector.append(0) vector.append(0)
return vector return vector
def disk_io_vector_limit(self, dummy):
#No point to accumulate unnormalized I/O for a conenction
return [0.0]
def network_traffic_vector_limit(self, dummy):
#No point to accumulate unnormalized Rx/Tx for a connection
return [0.0]
def _get_record_helper(self, record_name):
if len(self.record) == 0:
return 0
return self.record[0][record_name]
def stats_memory(self):
return self._get_record_helper("memory")
def stats_memory_percentage(self):
return self._get_record_helper("memoryPercent")
def cpu_time_percentage(self):
return self._get_record_helper("cpuTimePercent")
def network_rx_rate(self): def network_rx_rate(self):
return self._get_record_helper("netRxRate") return self._get_record_helper("netRxRate")
def network_tx_rate(self): def network_tx_rate(self):
return self._get_record_helper("netTxRate") return self._get_record_helper("netTxRate")
def network_traffic_rate(self): def network_traffic_rate(self):
return self.network_tx_rate() + self.network_rx_rate() return self.network_tx_rate() + self.network_rx_rate()
def pretty_stats_memory(self):
return util.pretty_mem(self.stats_memory())
def disk_read_rate(self): def disk_read_rate(self):
return self._get_record_helper("diskRdRate") return self._get_record_helper("diskRdRate")
def disk_write_rate(self): def disk_write_rate(self):
return self._get_record_helper("diskWrRate") return self._get_record_helper("diskWrRate")
def disk_io_rate(self): def disk_io_rate(self):
return self.disk_read_rate() + self.disk_write_rate() return self.disk_read_rate() + self.disk_write_rate()
def disk_io_vector_limit(self, dummy):
"""No point to accumulate unnormalized I/O for a conenction"""
return [0.0]
def network_traffic_vector_limit(self, dummy):
"""No point to accumulate unnormalized Rx/Tx for a conenction"""
return [0.0]
#################################### ####################################
# Per-Connection gconf preferences # # Per-Connection gconf preferences #