Net::P...:linux(3pm)

πŸ’– NAME πŸ’–

ok so bestie, this is "Net::Prometheus::ProcessCollector::linux" β€” a Process Collector for the linux OS. yes the quotes are literally part of the name in the manpage, we keep them, we don't question them. periodt. ✨


🌸 SYNOPSIS 🌸

the whole vibe, verbatim, no notes:

use Net::Prometheus;
use Net::Prometheus::ProcessCollector::linux;

my $prometheus = Net::Prometheus->new;

$prometheus->register( Net::Prometheus::ProcessCollector::linux->new );

that's it. that's the whole glow-up. πŸ¦‹


πŸ‘‘ DESCRIPTION πŸ‘‘

okay so this class hands you a Net::Prometheus collector instance whose entire job is to serve up process-wide metrics for a process running on the linux operating system. linux girlies rise πŸ’…

and here's the cute part: at collection time, if the requested process does not exist, no metrics are returned. like, zero. nothing. ghosted. πŸ’€

πŸŽ€ Other Process Collection πŸŽ€

the pid argument lets the collector collect from processes other than the one actually running the code. main character energy is not required β€” you can stan someone else's process fr fr.

but bestie, heads up: scraping processes owned by other users may not be possible for non-root users. in particular, most systems do not let non-root users see the /proc/self/fd directory of processes they don't own. in this case, the process_open_fds metric will not be returned. no metric, no apology, that's just the permission vibe check. πŸ™ˆ

✨ CONSTRUCTOR ✨

new

$collector = Net::Prometheus::ProcessCollector::linux->new( %args )

as well as the default arguments supported by Net::Prometheus::ProcessCollector, the following extra named arguments are recognised β€” yes, just one, she's an icon:

  • pid => STR β€” the numerical PID to collect information about; defaults to the string "self" allowing the exporter to collect information about itself, even over fork calls.

and here's the fine print, pay attention: if the collector is collecting from "self" or from a numerical PID that matches its own PID, then it will subtract 1 from the count of open file handles, to account for the readdir() handle being used to collect that count. if it is collecting a different process, it will not. the math is mathing, but only for yourself. πŸ”₯


πŸ’œ AUTHOR πŸ’œ

Paul Evans <leonerd@leonerd.org.uk> β€” the legend, the moment, the whole origin story. 🫢


and that's the tea, bestie πŸ“ β€” this absolute gem lives in the perl v5.42.3 docs, dated 2026-08-20, filed under Net::P...:linux(3pm). go forth and collect. slay. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from