Last active
June 8, 2024 13:21
-
-
Save esirK/09ac8f04eea008a0e5feb4b81d9f10d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
os.getloadavg() throws Attribute error
AttributeError: module 'os' has no attribute 'getloadavg'
are you trying to run this on windows?
If yes then that's the issue because this method is available on UNIX platforms only.
yes i was doing on windows...
can you please tell me the equivalent command of os.getloadavg() on windows ??
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
os.getloadavg() throws Attribute error
AttributeError: module 'os' has no attribute 'getloadavg'