TIL
/
Getting CPU and RAM usage in Python
Search
Duplicate
⌨️
Getting CPU and RAM usage in Python
import
psutil
# CPU usage.
psutil.cpu_percent
(
)
# Memory usage.
psutil.virtual_memory
(
)
.percent
# Memory usage in GB.
psutil.virtual_memory
(
)
.used /
2
**
30
# Total memory in GB.
psutil.virtual_memory
(
)
.total /
2
**
30
Shell
복사