The os.loadavg() method is an inbuilt application programming interface of the os module which is used to get load average. Load average is a measure of system activity, expressed in fractional number, calculated by operating system.
Parameters: This method does not accept any parameters.
Return Value: This method returns an array containing fractional number of size three signifies 1, 5 and 15 minutes load average calculated by the operating system. On windows, it will return [0, 0, 0] as load average is Unix-Specific concept.
Below examples illustrate the use of os.loadavg() method in Node.js:
[ 13.42041015625, 12.95166015625, 12.72509765625 ]
[ 0, 0, 0 ]
Load average (1 minute):15.87158203125 Load average (5 minute):14.193359375 Load average (15 minute):13.365234375
Note: The above program will compile and run by using the
node index.js command.