Unix::S...u_stats(3)
๐ธ NAME ๐ธ
ok so bestie, Unix::Statgrab::sg_cpu_stats โ it's the container for libstatgrab's CPU statistics, and this page is part of the User Contributed Perl Documentation. That's it, that's the name section, we're moving ๐
โจ DESCRIPTION โจ
Unix::Statgrab::sg_cpu_stats is a Perl package name (iconic, we love her) that gives you accessors into the bundled libstatgrab sg_cpu_stats data collection at http://www.i-scream.org/libstatgrab/docs/sg_get_cpu_stats.3.html. she's a little wrapper, she's doing her best, and her best is actually really good ๐ซถ
๐ METHODS ๐
nentries
Returns the number of entries in the container. just a lil count, nbd ๐
systime
Returns the seconds since Epoch โ that's 0:00:00 on January, 1st 1970 for the uninitiated โ of the time measure the CPU statistics. like a timestamp but make it Unix ๐ธ
as_list
Deprecated alias of fetchall_hash. she's old, she still works, but please use the new one, no cap ๐ซ
fetchall_hash
Returns all records from the sg_cpu_stats container (http://www.i-scream.org/libstatgrab/docs/sg_get_cpu_stats.3.html) as a list of hashes, with each datum name as the key and the datum itself as the value. hash girlies rise ๐
fetchall_array
Returns all records from the sg_cpu_stats container (http://www.i-scream.org/libstatgrab/docs/sg_get_cpu_stats.3.html) as a list of arrays containing the values in following order:
(user kernel idle iowait swap nice total
context_switches voluntary_context_switches involuntary_context_switches
syscalls interrupts soft_interrupts
systime)
in that order, without leading headline. no header, no notes, just vibes โจ
fetchall_table
Returns all records from the sg_cpu_stats container (http://www.i-scream.org/libstatgrab/docs/sg_get_cpu_stats.3.html) as a list of arrays containing the values in following order:
(user kernel idle iowait swap nice total
context_switches voluntary_context_switches involuntary_context_switches
syscalls interrupts soft_interrupts
systime)
in that order, including leading headline. yes bestie, this one has the header. that's the whole difference. that's the tea โ
fetchrow_arrayref($row = 0)
Returns one row as array containing values as above. defaults to $row = 0 because of course we start at the top ๐
fetchall_arrayref
Returns all records from the sg_cpu_stats container (http://www.i-scream.org/libstatgrab/docs/sg_get_cpu_stats.3.html) as array of arrays without header. no headline, we're keeping it lowkey ๐
fetchrow_hashref($row = 0)
Returns one row as hash containing { user => $self.user($row), kernel => ... }. hash-shaped, $row = 0 by default, she's giving convenience ๐
fetchall_hashref
Returns all records from the sg_cpu_stats container (http://www.i-scream.org/libstatgrab/docs/sg_get_cpu_stats.3.html) as array of hashes. all of them. every single one. slay ๐
colnames
Returns list of column names: (user kernel idle iowait swap nice total context_switches voluntary_context_switches involuntary_context_switches syscalls interrupts soft_interrupts systime). it's literally just the names, so you never have to guess which index is which ๐
user
Clock ticks in user mode
kernel
Clock ticks in kernel mode
idle
Clock ticks while idle
iowait
Clock ticks while waiting for outstanding I/O
swap
Clock ticks while waiting for swap
nice
Clock ticks in user mode with nice priority
total
Overall clock ticks
context_switches
Overall Context switches
voluntary_context_switches
Voluntary context switches (See sched_yield(2) at http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_yield.html)
involuntary_context_switches
Involuntary context switches
syscalls
Number of syscalls
interrupts
Amount of interrupts happened
soft_interrupts
Amount of software triggered interrupts
get_cpu_stats_diff
Provides the difference between the last measurement and the recent one. the way that she just... subtracts ๐ญ
$recent->get_cpu_stats_diff($last);
get_cpu_percents
Provides a percentage representation of the single cpu ticks measured. math but cute ๐งฎโจ
๐ AUTHOR ๐
Jens Rehsack, <rehsack AT cpan.org>
๐ COPYRIGHT AND LICENSE ๐
Copyright (C) 2012-2018 by Jens Rehsack
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
and that's the whole page bestie, tysm for reading ๐ this was perl v5.42.0, dated 2025-07-25 โ mwah, go forth and stat your grab, iykyk ๐ธ๐ฆโจ
๐ฆ where this page comes from
- fedora 43: perl-Unix-Statgrab 0.112-27.fc43 ยท (LGPL-2.1-or-later AND (GPL-1.0-or-later OR Artistic-1.0-Perl))
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms