#!/usr/bin/python import sys import time from pcp import pmapi from pcp import pmcc IDLE = "kernel.percpu.cpu.idle" METRICS = [ IDLE ] def curvals(group, name): return dict(map(lambda x: (x[1], x[2]), group[name].netValues)) def instlist(group, name): return sorted(dict(map(lambda x: (x[1], x[2]), group[name].netValues)).keys()) def report(g): c_idle = curvals(g, IDLE) for inst in instlist(g, IDLE): print inst, c_idle[inst] print if __name__ == '__main__': try: mgm = pmcc.MetricGroupManager() mgm["cpu"] = METRICS for i in range(10): mgm["cpu"].mgFetch() report(mgm["cpu"]) time.sleep(2) except pmapi.pmErr, error: print "Error: ", error.message() except KeyboardInterrupt: pass