-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpuutil.py
More file actions
41 lines (41 loc) · 1.59 KB
/
cpuutil.py
File metadata and controls
41 lines (41 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import psutil
import sys
import time
import curses
print("CPU Utilisation!!!")
print("1.CPU utilisation in percent 2.CPU utilisation corewise")
choice = input()
if choice == '1':
print (chr(27) + "[2J")
while True:
sys.stdout.write("\r")
sys.stdout.write("(utilisation:"+ str(psutil.cpu_percent())+'%' + ')')
time.sleep(1)
sys.stdout.flush()
elif choice == '2':
print (chr(27) + "[2J")
while True:
cores = psutil.cpu_percent(interval=1, percpu=True)
no_cores= len(cores)
if no_cores == 8:
def core_report():
stdscr.addstr(0,0,"core 1: "+str(cores[0])+"%"+" core 2: "+str(cores[1])+"%"+
" core 3: "+str(cores[2])+"%"+ " core 4: "+str(cores[3])+"%")
stdscr.addstr(1,0,"core 5: "+str(cores[0])+"%"+" core 6: "+str(cores[1])+"%"+
" core 7: "+str(cores[2])+"%"+ " core 8: "+str(cores[3])+"%")
stdscr = curses.initscr()
core_report()
time.sleep(1)
elif no_cores == 4:
sys.stdout.write("core 1: "+str(cores[0])+"%"+" core 2: "+str(cores[1])+"%"+
" core 3: "+str(cores[2])+"%"+ " core 4: "+str(cores[3])+"%")
time.sleep(1)
sys.stdout.flush()
elif no_cores == 2:
sys.stdout.write("core 1: "+str(cores[0])+"%"+" core 2: "+str(cores[1])+"%")
time.sleep(1)
sys.stdout.flush()
elif no_cores == 1:
sys.stdout.write("core 1: "+str(cores[0]))
time.sleep(1)
sys.stdout.flush()