Created
December 5, 2013 02:04
-
-
Save Celeo/7799013 to your computer and use it in GitHub Desktop.
Uses Pygal and Psutil to create a graph of CPU usage over 60 seconds.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psutil | |
import pygal | |
from time import sleep | |
c = pygal.Line() | |
c.title = 'CPU Usage Over 1 Minute' | |
data = [] | |
count = 0 | |
print 'Starting ...' | |
while True: | |
count += 1 | |
if count == 120: | |
c.add('', data) | |
c.render_to_file('out.svg') | |
print 'Done!' | |
break | |
data.append(psutil.cpu_percent()) | |
if count % 10 == 0: | |
print count | |
sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment