Sys::CpuLoad(3pm)

Sys::CpuLoad3pm

Retrieve system load averages

Usage

 use Sys::CpuLoad 'load';
 print '1 min, 5 min, 15 min load average: ',
       join(',', load()), "\n";

Version

version 0.32

Overview

This module retrieves the 1 minute, 5 minute, and 15 minute load average of a machine.

Exports

load

This method returns the load average for 1 minute, 5 minutes and 15 minutes as an array.

On Linux, Solaris, FreeBSD, NetBSD and OpenBSD systems, it will make a call to "getloadavg".

If /proc/loadavg is available on non-Cygwin systems, it will call "proc_loadavg".

Otherwise, it will attempt to parse the output of "uptime".

On error, it will return an array of "undef" values.

As of v0.29, you can override the default function by changing $Sys::CpuLoad::LOAD:

  use Sys::CpuLoad 'load';
  no warnings 'once';
  $Sys::CpuLoad::LOAD = 'uptimr';
  @load = load();

If you are writing code to work on multiple systems, you should use the "load" function. But if your code is intended for specific systems, then you should use the appropriate function.

getloadavg

This is a wrapper around the system call to "getloadavg".

If this call is unavailable, or it is fails, it will return "undef".

Added in v0.22.

proc_loadavg

If /proc/loadavg is available, it will be used.

If the data cannot be parsed, it will return "undef".

Added in v0.22.

uptime

Parse the output of uptime.

If the uptime executable cannot be found, or the output cannot be parsed, it will return "undef".

Added in v0.22.

As of v0.24, you can override the executable path by setting $Sys::CpuLoad::UPTIME, e.g.

  use Sys::CpuLoad 'uptime';
  no warnings 'once';
  $Sys::CpuLoad::UPTIME = '/usr/bin/w';
  @load = uptime();

Source

The development version is on github at <https://github.com/robrwo/Sys-CpuLoad> and may be cloned from <git://github.com/robrwo/Sys-CpuLoad.git>

Contributors

•

Slaven Rezić <[email protected]>

•

Victor Wagner

•

Dmitry Dorofeev <[email protected]>

•

Vincent Lefèvre <[email protected]>

Releases

12 releases since Debian 3.0 (Woody); the text changed 9 times.

  1. 3.0
  2. 3.1–4.0
  3. 5.0–6.0
  4. 7
  5. 8
  6. 9
  7. 10
  8. 11
  9. 12
  10. 13

Bugs

Please report any bugs or feature requests on the bugtracker website <https://github.com/robrwo/Sys-CpuLoad/issues>

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

Authors

•

Robert Rothenberg <[email protected]>

•

Clinton Wong <[email protected]>

From libsys-cpuload-perl 0.32-2 in Debian 13 (Trixie). Parsed by carta from the page's man source.