class Sar(object):
+
def __init__(self):
self.sar_cmd_str = "sar -u %(interval)s"
self.child_process = {}
def start(self, interval=2):
cmd = self.sar_cmd_str % {'interval': interval}
- child = my_popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ child = my_popen(
+ cmd.split(),
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
time.sleep(1)
if child.poll() is not None:
print child.poll()
data = {}
for h, d in zip(head, average):
data[h.strip('%')] = float(d)
- cpu_num = check_output('cat /proc/cpuinfo | grep processor | wc -l', shell=True).strip()
+ cpu_num = check_output(
+ 'cat /proc/cpuinfo | grep processor | wc -l',
+ shell=True).strip()
data.update({'cpu_num': int(cpu_num)})
return data