File: cpu_usage_file.py

package info (click to toggle)
labplot 2.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 41,104 kB
  • sloc: cpp: 89,715; ansic: 4,251; python: 741; yacc: 480; xml: 174; sh: 124; makefile: 40; awk: 35
file content (15 lines) | stat: -rwxr-xr-x 286 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/python

import socket
import psutil
import time


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()