Skip to content

Instantly share code, notes, and snippets.

@esirK
Last active June 8, 2024 13:21
Show Gist options
  • Save esirK/09ac8f04eea008a0e5feb4b81d9f10d6 to your computer and use it in GitHub Desktop.
Save esirK/09ac8f04eea008a0e5feb4b81d9f10d6 to your computer and use it in GitHub Desktop.
import os
import subprocess
import re
statistics = {}
# Get Physical and Logical CPU Count
physical_and_logical_cpu_count = os.cpu_count()
statistics['physical_and_logical_cpu_count'] = physical_and_logical_cpu_count
"""
# Load average
# This is the average system load calculated over a given period of time of 1, 5 and 15 minutes.
# In our case, we will show the load average over a period of 15 minutes.
# The numbers returned by os.getloadavg() only make sense if
# related to the number of CPU cores installed on the system.
# Here we are converting the load average into percentage. The higher the percentage the higher the load
"""
cpu_load = [x / os.cpu_count() * 100 for x in os.getloadavg()][-1]
statistics['cpu_load'] = cpu_load
@debjit31
Copy link

yes i was doing on windows...
can you please tell me the equivalent command of os.getloadavg() on windows ??

@esirK
Copy link
Author

esirK commented Jun 15, 2020

@esirK
Copy link
Author

esirK commented Jun 15, 2020

This PR shows this should work on windows too giampaolo/psutil#1485

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment