Unix::S...u_stats(3)

๐Ÿ“ฆ version 0.112, in fedora 43

๐ŸŒธ 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 (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