-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (22 loc) · 730 Bytes
/
main.py
File metadata and controls
30 lines (22 loc) · 730 Bytes
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
import psutil
import time
import os
from usage import Usage
def main():
try:
while True:
cpu_usage = Usage(psutil.cpu_percent())
ram_usage = Usage(psutil.virtual_memory().percent)
disk_usage = Usage(psutil.disk_usage('/').percent)
print(f"\rCPU Usage: {str(cpu_usage)}", end="")
print(f" RAM Usage: {str(ram_usage)}", end="")
print(f" Disk Usage: {str(disk_usage)}", end="\r")
time.sleep(0.5)
except KeyboardInterrupt:
clear_cmd()
os._exit(0)
def clear_cmd() -> None:
os.system('clear' if os.name == 'posix' else 'cls') # linux/windows
if __name__ == '__main__':
clear_cmd()
main()