Sys::CpuLoad(3pm)

πŸ“¦
version 0.32 Β· 5 versions
, in debian trixie, ubuntu resolute

✨ Sys::CpuLoad β€” the manual page, but make it cute ✨

okay bestie, so this is a User Contributed Perl Documentation page for Sys::CpuLoad (that's the 3pm one, iykyk) and it's literally just here to tell you how to grab your machine's load averages. no cap. let's go πŸ’…


🌸 NAME 🌸

Sys::CpuLoad β€” retrieve system load averages 🫢

like, it gets them. for you. the whole vibe is "what's the machine going through rn".


πŸ’– VERSION πŸ’–

version 0.32 ✨


πŸŽ€ SYNOPSIS πŸŽ€

the main character moment, fr:

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

that's it. that's the whole thing. slay.


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically this module retrieves the 1 minute, 5 minute, and 15 minute load average of a machine. three numbers, three time windows, one very nosy little module. iconic behavior honestly.


πŸ‘‘ EXPORTS πŸ‘‘

🌈 load

this method returns the load average for 1 minute, 5 minutes and 15 minutes as an array. three values, in order, no drama.

here's the tea on how it actually gets them, depending on where you are:

  • On Linux, Solaris, FreeBSD, NetBSD and OpenBSD systems, it will make a call to getloadavg. very direct of it.
  • If /proc/loadavg is available on non-Cygwin systems, it will call proc_loadavg. (note the "non-Cygwin" part, bestie β€” Cygwin doesn't get this route.)
  • Otherwise, it will attempt to parse the output of uptime. old school but it works.
on error, it will return an array of undef values. so if you see undefs, that's not a vibe, that's a failure. πŸ’€

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();

(and yes, 'uptimr' is spelled exactly like that in the docs. not me proofreading, just copying the lore fr πŸ™ˆ)

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. pick your fighter 🫢

⭐ getloadavg

this is a wrapper around the system call to getloadavg. little glow-up, little wrapper, you know how it is.

If this call is unavailable, or it is fails, it will return undef. (yes the original says "or it is fails", we love a grammatically chaotic icon 😭)

Added in v0.22. ✨

πŸ“ proc_loadavg

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

If the data cannot be parsed, it will return undef. sad, but honest.

Added in v0.22. πŸ’œ

🧚 uptime

Parse the output of uptime. that's the job. that's the whole job.

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();

okay customize your path, periodt πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

Sys::CpuLoadX β€” the sequel. the remix. go look at it.


🌟 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> 🫢

go clone it. it's right there. it's giving open source.


πŸ’€ 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. no "it's broken trust me" β€” show us the receipts bestie, include the test file or patch πŸ™


🌈 AUTHORS 🌈

  • Robert Rothenberg <rrwo@cpan.org>
  • Clinton Wong <clintdw@cpan.org>

πŸ’œ CONTRIBUTORS πŸ’œ

  • Slaven ReziΔ‡ <slaven@rezic.de>
  • Victor Wagner
  • Dmitry Dorofeev <dima@yasp.com>
  • Vincent LefΓ¨vre <vincent@vinc17.net>

look at this little group chat of legends. obsessed. πŸ‘‘


This software is copyright (c) 1999-2002, 2020, 2025 by Clinton Wong <clintdw@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free as in go wild, just follow the Perl 5 terms, mwah πŸ’‹


and that's the whole page bestie! this was rendered with perl v5.40.1, dated 2025-05-06, and it was Sys::CpuLoad(3pm) the entire time. main character energy from start to finish. bye ily πŸ¦‹βœ¨

πŸ“¦ where this page comes from