Skip to content

Instantly share code, notes, and snippets.

@Celeo
Created December 5, 2013 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Celeo/7799013 to your computer and use it in GitHub Desktop.
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.
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