Monitor CPU, RAM, and disk usage on your PC using Python #shorts

Posted by

Use Python to see CPU, RAM, and disk usage of your PC

Use Python to see CPU, RAM, and disk usage of your PC

Python is a versatile programming language that can be used for a wide range of tasks, including monitoring the performance of your computer. By using Python, you can easily see the CPU, RAM, and disk usage of your PC in real-time.

Python script for monitoring system performance

Here is a simple Python script that uses the psutil library to monitor the CPU, RAM, and disk usage of your PC:

  
import psutil

# Get CPU usage
cpu_usage = psutil.cpu_percent(interval=1)

# Get RAM usage
ram = psutil.virtual_memory()
ram_usage = ram.percent

# Get disk usage
disk = psutil.disk_usage('/')
disk_usage = disk.percent

print(f"CPU Usage: {cpu_usage}%")
print(f"RAM Usage: {ram_usage}%")
print(f"Disk Usage: {disk_usage}%")
  
  

Simply run this script in your Python environment, and you will see the current CPU, RAM, and disk usage of your PC printed to the console. You can also modify this script to save the data to a file or display it in a more user-friendly way.

Conclusion

Monitoring the performance of your computer is important to ensure it is running smoothly and efficiently. With Python and the psutil library, you can easily keep track of the CPU, RAM, and disk usage of your PC in real-time. This can help you identify any performance issues and take necessary actions to optimize your system.

0 0 votes
Article Rating
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@CodX710
1 month ago

You should put this into a GUI using tkinter

@gyanookharel7440
1 month ago

I didn’t know Python could do this. Good job.