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

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

πŸ’– Sys::Statistics::Linux::MemStats β€” the bestie who reads your memory πŸ’–

okay so this is a Perl module, part of the User Contributed Perl Documentation, manual section 3pm. Its whole personality is Sys::Statistics::Linux::MemStats and its whole job is collecting linux memory information. no cap. 🧠✨


✨ NAME ✨

Sys::Statistics::Linux::MemStats β€” Collect linux memory information.


🌸 SYNOPSIS 🌸

use Sys::Statistics::Linux::MemStats;

my $lxs  = Sys::Statistics::Linux::MemStats->new;
my $stat = $lxs->get;

πŸ¦‹ DESCRIPTION πŸ¦‹

Sys::Statistics::Linux::MemStats gathers memory statistics from the virtual /proc filesystem, aka procfs. it just walks in there and reads the vibes, respectfully. πŸ’…

for more info, go read the documentation of the front-end module Sys::Statistics::Linux. it's giving ✨main character✨, go say hi.


πŸ“ MEMORY INFORMATIONS πŸ“

Generated by /proc/meminfo. this is where the numbers live, bestie:

  • memused β€” Total size of used memory in kilobytes.
  • memfree β€” Total size of free memory in kilobytes.
  • memusedper β€” Total size of used memory in percent.
  • memtotal β€” Total size of memory in kilobytes.
  • buffers β€” Total size of buffers used from memory in kilobytes.
  • cached β€” Total size of cached memory in kilobytes.
  • realfree β€” Total size of memory is real free (memfree + buffers + cached).
  • realfreeper β€” Total size of memory is real free in percent of total memory.
  • swapused β€” Total size of swap space is used is kilobytes.
  • swapfree β€” Total size of swap space is free in kilobytes.
  • swapusedper β€” Total size of swap space is used in percent.
  • swaptotal β€” Total size of swap space in kilobytes.
  • swapcached β€” Memory that once was swapped out, is swapped back in but still also is in the swapfile.
  • active β€” Memory that has been used more recently and usually not reclaimed unless absolutely necessary.
  • inactive β€” Memory which has been less recently used and is more eligible to be reclaimed for other purposes. On earlier kernels (2.4) Inact_dirty + Inact_laundry + Inact_clean.

the following statistics are only available by kernels from 2.6. so if you're on something ancient, sorry bestie, these are not for you 😭

  • slab β€” Total size of memory in kilobytes that used by kernel for data structure allocations.
  • dirty β€” Total size of memory pages in kilobytes that waits to be written back to disk.
  • mapped β€” Total size of memory in kilbytes that is mapped by devices or libraries with mmap.
  • writeback β€” Total size of memory that was written back to disk.
  • committed_as β€” The amount of memory presently allocated on the system.

the following statistic is only available by kernels from 2.6.9. yes, a whole one (1) field, and it's iconic for it. πŸ‘‘

  • commitlimit β€” Total amount of memory currently available to be allocated on the system.

πŸŽ€ METHODS πŸŽ€

πŸ’œ new()

call new() to create a new object. literally just spawn it.

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

it's possible to set the path to the proc filesystem. so if your procfs is somewhere else (no judgement), say so:

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

πŸ’œ get()

call get() to get the statistics. get() returns the statistics as a hash reference. yes, a hashref. go get your numbers 🫢

my $stat = $lxs->get;

🌈 EXPORTS 🌈

No exports. she gives nothing away, and honestly? respect. πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

proc(5)


😭 REPORTING BUGS 😭

Please report all bugs to <jschulz.cpan(at)bloonix.de>.


πŸ‘‘ AUTHOR πŸ‘‘

Jonny Schulz <jschulz.cpan(at)bloonix.de>.


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, bestie πŸ’– documented as perl v5.36.0, dated 2022-11-19, and yes the manual page header said Sys::S...mStats(3pm) and the footer said Sys::S...mStats(3pm) too. we folded those in up top so you didn't have to read them twice. slay. βœ¨πŸ¦‹πŸŽ€
πŸ“¦ where this page comes from