File: cpu_usage_file.py

package info (click to toggle)
labplot 2.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 70,348 kB
  • sloc: cpp: 145,806; ansic: 4,534; python: 881; yacc: 540; xml: 357; sh: 185; awk: 35; makefile: 7
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()