def _sendLinuxMetrics(self): cpu_percents = {} for k, v in cpu_stat.cpu_percents().items(): cpu_percents['cpu_' + k] = v load_avg = cpu_stat.load_avg() assert(len(load_avg) == 3) file_desc = cpu_stat.file_desc() assert(len(file_desc) == 3) stats = cpu_percents.items() stats += zip(['load_1min', 'load_5min', 'load_15min'], load_avg) stats += {'procs_running': cpu_stat.procs_running(), 'procs_blocked': cpu_stat.procs_blocked()}.items() stats += zip(['filedesc_allocated', 'filedesc_allocated_free', 'filedesc_max'], file_desc) self.sendEvent('cpu', dict(stats)) for nic in ['wlan0', 'eth0', 'usb0']: rx, tx = net_stat.rx_tx_bytes(nic) self.sendEvent('net', {'nic': nic, 'rx_bytes': rx, 'tx_bytes': tx})
def test_procs_blocked(self): value = cpu_stat.procs_blocked() self.assertTrue(value >= 0, value)