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.
import os
load1, load5, load15 = os.getloadavg()
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)
|
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
Last Updated :
25 Jun, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...