File: cpu_usage_file.py

package info (click to toggle)
labplot 2.12.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,624 kB
  • sloc: cpp: 241,048; ansic: 6,324; python: 915; xml: 400; yacc: 237; sh: 221; awk: 35; makefile: 11
file content (12 lines) | stat: -rwxr-xr-x 260 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/python

import psutil

while True:
    cpu_percents = str(psutil.cpu_percent(interval=0.5, percpu=True))
    line = str(cpu_percents)[1:-1]
    print line

    datafile = open("cpuData.txt", "a")
    datafile.write(line + "\n")
    datafile.close()