def read_disk_usage_stats(): # If the device raises an intermittent exception during metric collection process it will be required # to be handled in the user code otherwise if an exception is thrown from user code # the collection process will be stopped for that metric. # If the None value is returned by UDM then metric value for that particular collector instance won't be published. try: disk_stat_value = round(disk_stat.disk_reads_writes(disk_name)[0], 2) except Exception: return None return disk_stat_value
def main(): # cpu print 'procs running: %d' % cpu_stat.procs_running() cpu_pcts = cpu_stat.cpu_percents(sample_duration=1) print 'cpu utilization: %.2f%%' % (100 - cpu_pcts['idle']) # disk print 'disk busy: %s%%' % disk_stat.disk_busy('sda', sample_duration=1) r, w = disk_stat.disk_reads_writes('sda') print 'disk reads: %s' % r print 'disk writes: %s' % w # memory used, total = mem_stat.mem_stats() print 'mem used: %s' % used print 'mem total: %s' % total # network rx_bits, tx_bits = net_stat.rx_tx_bits('eth0') print 'net bits received: %s' % rx_bits print 'net bits sent: %s' % tx_bits
def read_disk_usage_stats(): return round(disk_stat.disk_reads_writes(disk_name)[0], 2)
def read_disk_usage_stats(): return disk_usage_filter.filter( round(disk_stat.disk_reads_writes(disk_name)[0], 2))
def read_disk_usage_stats(): return disk_usage_filter.filter(round(disk_stat.disk_reads_writes(disk_name)[0], 2))
def test_disk_writes(self): _, value = disk_stat.disk_reads_writes(self.device) self.assertTrue(value >= 0, value)