NAME

Linux::loadavg - Get system load averages (via getloadavg(3C) system call)

SYNOPSIS

use Linux::loadavg;

@avgs = loadavg();
printf "load average: %f %f %f\n", @avgs;

DESCRIPTION

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.

EXPORT

loadavg
LOADAVG_1MIN
LOADAVG_5MIN
LOADAVG_15MIN

EXAMPLE

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];

AUTHOR

Niels van Dijke, <CpanDotOrgAtPerlboyDotNet>

CREDITS

The Linux::loadavg is nearly one on one based on Solaris::loadavg. Therefore credits should go to: Alexander Golomshtok (http://search.cpan.org/~agolomsh/)

SEE ALSO

perl,getloadavg(3C),Solaris::loadavg