.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Sys::CpuLoad 3pm" .TH Sys::CpuLoad 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Sys::CpuLoad \- retrieve system load averages .SH VERSION .IX Header "VERSION" version 0.31 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 3 \& use Sys::CpuLoad \*(Aqload\*(Aq; \& print \*(Aq1 min, 5 min, 15 min load average: \*(Aq, \& join(\*(Aq,\*(Aq, load()), "\en"; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module retrieves the 1 minute, 5 minute, and 15 minute load average of a machine. .SH EXPORTS .IX Header "EXPORTS" .SS load .IX Subsection "load" This method returns the load average for 1 minute, 5 minutes and 15 minutes as an array. .PP On Linux, Solaris, FreeBSD, NetBSD and OpenBSD systems, it will make a call to "getloadavg". .PP If \fI/proc/loadavg\fR is available on non-Cygwin systems, it will call "proc_loadavg". .PP Otherwise, it will attempt to parse the output of \f(CW\*(C`uptime\*(C'\fR. .PP On error, it will return an array of \f(CW\*(C`undef\*(C'\fR values. .PP As of v0.29, you can override the default function by changing \&\f(CW$Sys::CpuLoad::LOAD\fR: .PP .Vb 1 \& use Sys::CpuLoad \*(Aqload\*(Aq; \& \& no warnings \*(Aqonce\*(Aq; \& \& $Sys::CpuLoad::LOAD = \*(Aquptimr\*(Aq; \& \& @load = load(); .Ve .PP If you are writing code to work on multiple systems, you should use the \f(CW\*(C`load\*(C'\fR function. But if your code is intended for specific systems, then you should use the appropriate function. .SS getloadavg .IX Subsection "getloadavg" This is a wrapper around the system call to \f(CW\*(C`getloadavg\*(C'\fR. .PP If this call is unavailable, or it is fails, it will return \f(CW\*(C`undef\*(C'\fR. .PP Added in v0.22. .SS proc_loadavg .IX Subsection "proc_loadavg" If \fI/proc/loadavg\fR is available, it will be used. .PP If the data cannot be parsed, it will return \f(CW\*(C`undef\*(C'\fR. .PP Added in v0.22. .SS uptime .IX Subsection "uptime" Parse the output of uptime. .PP If the uptime executable cannot be found, or the output cannot be parsed, it will return \f(CW\*(C`undef\*(C'\fR. .PP Added in v0.22. .PP As of v0.24, you can override the executable path by setting \&\f(CW$Sys::CpuLoad::UPTIME\fR, e.g. .PP .Vb 1 \& use Sys::CpuLoad \*(Aquptime\*(Aq; \& \& no warnings \*(Aqonce\*(Aq; \& \& $Sys::CpuLoad::UPTIME = \*(Aq/usr/bin/w\*(Aq; \& \& @load = uptime(); .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Sys::CpuLoadX .SH SOURCE .IX Header "SOURCE" The development version is on github at and may be cloned from .SH BUGS .IX Header "BUGS" Please report any bugs or feature requests on the bugtracker website .PP 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. .SH AUTHORS .IX Header "AUTHORS" .IP \(bu 4 Robert Rothenberg .IP \(bu 4 Clinton Wong .SH CONTRIBUTORS .IX Header "CONTRIBUTORS" .IP \(bu 4 Slaven Rezić .IP \(bu 4 Victor Wagner .IP \(bu 4 Dmitry Dorofeev .IP \(bu 4 Vincent Lefèvre .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 1999\-2002, 2020 by Clinton Wong . .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.