Sys::S...tStats(3pm)

πŸ“¦
version 0.66 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Sys::S...tStats(3pm) β€” aka Sys::Statistics::Linux::NetStats πŸ’–

okay bestie, so this is a User Contributed Perl Documentation page, and it's the manual for Sys::Statistics::Linux::NetStats (the header up top is just being dramatic and abbreviating it to Sys::S...tStats(3pm), we don't have to talk about it πŸ’€).


✨ NAME ✨

Sys::Statistics::Linux::NetStats β€” collect linux net statistics. that's it, that's the whole vibe. 🌐


✨ SYNOPSIS ✨

the classic three-step:

use Sys::Statistics::Linux::NetStats;

my $lxs = Sys::Statistics::Linux::NetStats->new;
$lxs->init;
sleep 1;
my $stat = $lxs->get;

Or:

my $lxs = Sys::Statistics::Linux::NetStats->new(initfile => $file);
$lxs->init;
my $stat = $lxs->get;

✨ DESCRIPTION ✨

Sys::Statistics::Linux::NetStats gathers net statistics from the virtual /proc filesystem (procfs). iconic behaviour tbh. 🌸

if you want more info, go read the docs of the front-end module Sys::Statistics::Linux. it's giving "the main character module" and this one is its little sister. πŸ‘‘


✨ NET STATISTICS ✨

these are generated by /proc/net/dev. every single one is a per second number, no cap:

  • rxbyt β€” Number of bytes received per second.
  • rxpcks β€” Number of packets received per second.
  • rxerrs β€” Number of errors that happend while received packets per second.
  • rxdrop β€” Number of packets that were dropped per second.
  • rxfifo β€” Number of FIFO overruns that happend on received packets per second.
  • rxframe β€” Number of carrier errors that happend on received packets per second.
  • rxcompr β€” Number of compressed packets received per second.
  • rxmulti β€” Number of multicast packets received per second.
  • txbyt β€” Number of bytes transmitted per second.
  • txpcks β€” Number of packets transmitted per second.
  • txerrs β€” Number of errors that happend while transmitting packets per second.
  • txdrop β€” Number of packets that were dropped per second.
  • txfifo β€” Number of FIFO overruns that happend on transmitted packets per second.
  • txcolls β€” Number of collisions that were detected per second.
  • txcarr β€” Number of carrier errors that happend on transmitted packets per second.
  • txcompr β€” Number of compressed packets transmitted per second.
  • ttpcks β€” Number of total packets (received + transmitted) per second.
  • ttbyt β€” Number of total bytes (received + transmitted) per second.

✨ METHODS ✨

🌟 new()

call new() to create a new object. brand new, fresh out the box, main character energy.

my $lxs = Sys::Statistics::Linux::NetStats->new;

maybe you wanna store/load the initial statistics to/from a file? go off:

my $lxs = Sys::Statistics::Linux::NetStats->new(initfile => '/tmp/netstats.yml');

if you set initfile it's not necessary to call sleep before get(). so you can skip the nap. 😴➑️🚫

it's also possible to set the path to the proc filesystem:

 Sys::Statistics::Linux::NetStats->new(
    files => {
        # This is the default
        path   => '/proc',
        netdev => 'net/dev',
    }
 );

🌟 init()

call init() to initialize the statistics. gotta warm up first, yk?

$lxs->init;

🌟 get()

call get() to get the statistics. get() returns the statistics as a hash reference.

my $stat = $lxs->get;

🌟 raw()

the same as get_raw() but it's not necessary to call init() first. lowkey the convenient one. πŸ™ˆ

🌟 get_raw()

call get_raw() to get the raw data β€” no deltas. just the honest raw numbers, no math, no filter. πŸ’…


✨ EXPORTS ✨

No exports. none. zero. empty. it's giving minimalist. ✨


✨ SEE ALSO ✨

proc(5) β€” go read it, bestie, it's where all the lore lives. πŸ“–


✨ REPORTING BUGS ✨

Please report all bugs to <jschulz.cpan(at)bloonix.de>. (yes that's the actual email format, don't come for me, I'm just the messenger 🫢)


✨ AUTHOR ✨

Jonny Schulz <jschulz.cpan(at)bloonix.de>. legend behaviour. πŸ‘‘


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. slay. πŸ’œ


and that's the whole page, bestie!! no notes, we ate. πŸ“

okay so the fine print: this whole thing came from perl v5.36.0, dated 2022-11-19, and it's the Sys::S...tStats(3pm) page from User Contributed Perl Documentation. periodt. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from