from commands import getoutput # For python 3, getoutput is in subprocess not commands lines = open("/proc/interrupts").readlines() cpu_count = int(getoutput("cat /proc/cpuinfo | grep processor | wc -l")) for line in lines: lsp = line.split() try: count = sum([int(i) for i in lsp[1:cpu_count + 1]]) spaces = " "[:12 - len(str(count))] print lsp[0], " ", spaces + str(count), " ", for piece in lsp[cpu_count + 1:]: print piece, print except: print "Int Count Name"