#!/sw/bin/python # Yet Another Cpu Stat Checker # This is a small CPU checker, nothing more. from subprocess import Popen, PIPE try: proc = Popen(['/usr/bin/top', '-l', '1', '-n' '5'], shell=False, stdout=PIPE) proc_comm = proc.communicate()[0] top_out = proc_comm.splitlines()[3][11:] user = top_out.split()[0] system = top_out.split()[2] idle = top_out.split()[4] print "CPU STATISTICS OK: user=%s system=%s idle=%s | user=%s system=%s idle=%s"% (user,system,idle,user,system,idle) except: print "CPU STATISTICS UNKNOWN: the stsci_check_cpu script encountered an error."