Sys::S...uStats(3pm)
π Sys::Statistics::Linux::CpuStats β the perl manual page, bestie edition π
okay so this is Sys::Statistics::Linux::CpuStats, and it lives in the User Contributed Perl Documentation section of the perl man pages (you know, the 3pm girlies). she collects linux cpu statistics and she is lowkey iconic for it. let's get into it β¨
πΈ NAME πΈ
Sys::Statistics::Linux::CpuStats β Collect linux cpu statistics. that's it, that's the job. she gathers the cpu tea from your machine. periodt π
β¨ SYNOPSIS β¨
the basic serve:
use Sys::Statistics::Linux::CpuStats;
my $lxs = Sys::Statistics::Linux::CpuStats->new;
$lxs->init;
sleep 1;
my $stats = $lxs->get;
Or, if you're feeling fancy with a file:
my $lxs = Sys::Statistics::Linux::CpuStats->new(initfile => $file);
$lxs->init;
my $stats = $lxs->get;
π¦ DESCRIPTION π¦
Sys::Statistics::Linux::CpuStats gathers cpu statistics from the virtual /proc filesystem (aka procfs). yes bestie, it's reading /proc and pulling the numbers out, that's the whole vibe.
For more information read the documentation of the front-end module Sys::Statistics::Linux. (that's the main character, this one is her supporting role π«Ά)
π CPU STATISTICS π
Generated by /proc/stat for each cpu (cpu0, cpu1 ...). and listen, a cpu with no number attached is the summary. the group chat total, if you will.
userβ Percentage of CPU utilization at the user level.niceβ Percentage of CPU utilization at the user level with nice priority.systemβ Percentage of CPU utilization at the system level.idleβ Percentage of time the CPU is in idle state.totalβ Total percentage of CPU utilization.
Statistics with kernels >= 2.6. (old kernels, we don't know her π)
iowaitβ Percentage of time the CPU is in idle state because an I/O operation is waiting to complete.irqβ Percentage of time the CPU is servicing interrupts.softirqβ Percentage of time the CPU is servicing softirqs.stealβ Percentage of stolen CPU time, which is the time spent in other operating systems when running in a virtualized environment (>=2.6.11).
π METHODS π
π new()
Call new() to create a new object. brand new baby object, fresh out the box β¨
my $lxs = Sys::Statistics::Linux::CpuStats->new;
Maybe you want to store/load the initial statistics to/from a file:
my $lxs = Sys::Statistics::Linux::CpuStats->new(initfile => '/tmp/cpustats.yml');
If you set initfile it's not necessary to call sleep before get(). no sleeping on the job, we love efficiency π
It's also possible to set the path to the proc filesystem.
Sys::Statistics::Linux::CpuStats->new(
files => {
# This is the default
path => '/proc'
stat => 'stat',
}
);
note thatpath => '/proc'andstat => 'stat'are literally marked as the default right there in the comment, so don't come for me if you change them and things get weird π
π init()
Call init() to initialize the statistics.
$lxs->init;
she needs a lil setup moment before she performs, okay?
β get()
Call get() to get the statistics. get() returns the statistics as a hash reference.
my $stats = $lxs->get;
hash ref, bestie. dereference accordingly π
π§ raw()
Get raw values.
π EXPORTS π
No exports.
not a single one. nothing to import. we keep it contained π
π₯ SEE ALSO π₯
go read that one too, it's giving lore.
π REPORTING BUGS π
Please report all bugs to <jschulz.cpan(at)bloonix.de>.
like genuinely please tell him, don't just suffer in silence π«Ά
πΈ AUTHOR πΈ
Jonny Schulz <jschulz.cpan(at)bloonix.de>.
π COPYRIGHT π
Copyright (c) 2006, 2007 by Jonny Schulz. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, no cap. this lil manpage came from perl v5.36.0, dated 2022-11-19, filed under Sys::S...uStats(3pm) in the User Contributed Perl Documentation β¨ go collect those cpu stats, queen ππ
π¦ where this page comes from
- debian bookworm: libsys-statistics-linux-perl 0.66-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libsys-statistics-linux-perl 0.66-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libsys-statistics-linux-perl 0.66-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsys-statistics-linux-perl 0.66-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsys-statistics-linux-perl 0.66-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms