Linux::loadavg - Get system load averages (via getloadavg(3C) system call)
use Linux::loadavg; @avgs = loadavg(); printf "load average: %f %f %f\n", @avgs;
The Linux::loadavg module provides simple interface to Linux getloadavg(3C) library function, which returns the number of processes in the system run queue averaged over various periods of time. Up to 3 samples are retrieved and returned to successive elements of the output array. The system imposes a maximum of 3 samples, representing averages over the last 1, 5 and 15 minutes, respectively.
The LOADAVG_1MIN, LOADAVG_5MIN, and LOADAVG_15MIN indices can be used to extract the data from the appropriate element of the output array.
When called without an argument, the loadavg() function returns all three load averages.
use strict; # Autodetect Linux::loadavg or Solaris::loadavg die $@ if eval sprintf('use %s::loadavg qw(loadavg)', ucfirst $^O) || $@; # get the first two load averages @avgs = loadavg(2); printf "first load avg (1min): %f\n", @avgs[LOADAVG_1MIN]; printf "second load avg (5min): %f\n", @avgs[LOADAVG_5MIN];
Niels van Dijke, <CpanDotOrgAtPerlboyDotNet>
The Linux::loadavg is nearly one on one based on Solaris::loadavg. Therefore credits should go to: Alexander Golomshtok (http://search.cpan.org/~agolomsh/)
perl,getloadavg(3C),Solaris::loadavg
To install Linux::loadavg, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Linux::loadavg
CPAN shell
perl -MCPAN -e shell install Linux::loadavg
For more information on module installation, please visit the detailed CPAN module installation guide.