Python | os.getloadavg() method

OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.

os.getloadavg() method in Python is used to get the load average over the last 1, 5, and 15 minutes. The load average is the average of the number of processes in the system run queue over a given period of time over 1, 5 and 15 minutes. This method raises OSError if the load average is unobtainable.

Note: This method is available on UNIX platforms only.



Syntax: os.getloadavg()

Parameter: No parameter is required.

Return Type: This method returns a tuple object consisting of float values which denotes the load average over the last 1, 5, and 15 minutes.

Code: Use of os.getloadavg() method to get the load average over the last 1, 5, and 15 minutes.

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to explain os.getloadavg() method  
  
# importing os module 
import os
  
# Get the load average over
# the last 1, 5, and 15 minutes 
# using os.getloadavg() method
load1, load5, load15 = os.getloadavg()
  
# Print the load average over
# the last 1, 5, and 15 minutes 
print("Load average over the last 1 minute:", load1)
print("Load average over the last 5 minute:", load5)
print("Load average over the last 15 minute:", load15)

chevron_right


Output:

Load average over the last 1 minute: 0.34
Load average over the last 5 minute: 0.42
Load average over the last 15 minute: 0.46


My Personal Notes arrow_drop_up

self motivated and passionate programmer

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.