NAME
Linux::loadavg - Get system load averages (via getloadavg(3C) system call)
SYNOPSIS
use Linux::loadavg;
my @avgs = loadavg();
printf "Load average: %s (1m,5m,15m)\n", join(', ',@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
my @avgs = loadavg(2);
printf "first load avg (1min): %f\n", $avgs[LOADAVG_1MIN];
printf "second load avg (5min): %f\n", $avgs[LOADAVG_5MIN];
# Call and print only 5 minute value
printf "5 minute load: %f\n",(loadavg(2))[LOADAVG_5MIN];
AUTHOR
Niels van Dijke, <CpanDotOrgAtPerlboyDotNet>
CREDITS
The Linux::loadavg was nearly one on one based on Solaris::loadavg. Therefore credits should go to: Alexander Golomshtok (https://metacpan.org/author/AGOLOMSH). Version 0.10 and above the XS code has been improved using Sys::LoadAvg XS code by Jeremy Madea (https://metacpan.org/author/JEREMY).
This module has the same license as Perl 5 itself. The explicit license can be found in the LICENSE file distributed with the tar.gz archive.
SEE ALSO
perl,getloadavg(3C),Solaris::loadavg,Sys::LoadAvg
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 115:
Unknown directive: =head