Munin::Node::OS(3)
π Munin::Node::OS β the manual, but make it make sense
okay so this is Munin::Node::OS(3), a Perl module β like, from the User Contributed Perl Documentation corner of the internet π β and it's basically the OS-related utility methods for the Munin node. think of it as the little toolkit that goes "who's this user? what's the hostname? is this file safe? lemme fork that." lowkey iconic, ngl.
β¨ NAME β¨
Munin::Node::OS β OS related utility methods for the Munin node. that's it, that's the whole vibe π«Ά
π¦ SYNOPSIS π¦
okay bestie, here's how you actually pull it in:
use Munin::Node::OS;
my $uid = Munin::Node::OS->get_uid('foo');
my $host = Munin::Node::OS->get_fq_hostname();
see? two lines in and you're already doing OS crimes. slay β¨
π METHODS π
every method, no skipping, we're doing the full tour π
π get_uid
$uid = $class->get_uid($user)
hands you back the user ID. and here's the cute part: $user can be either a user name or a user ID, so you don't gotta care which one you're holding. if the user literally doesn't exist? you get undef. no drama, just undef π
πΈ get_gid
$gid = $class->get_gid($group)
same energy but for groups β returns the group ID. $group can be a group name or a group ID (yes, flexible, we love her). group doesn't exist? undef again. equal opportunity undef fr fr.
π§ get_fq_hostname
$host = $class->get_fq_hostname()
returns the fully qualified host name of the machine. that's the whole thing. no args, no notes, main character energy π
π₯ check_perms_if_paranoid
$bool = $class->check_perms_if_paranoid($target);
okay so this one only kicks in if paranoia is enabled β and if it is, it returns false unless $target is owned by root AND has safe permissions. and if $target happens to be a file, it also checks the directory it lives in π (yes, the whole neighborhood gets vibe-checked, not just the file).
ngl this is the "trust but verify, actually just verify" method π
π run_as_child
$result = run_as_child($timeout, $coderef, @arguments);
creates a child process to run $code and waits up to $timeout seconds for it to finish. then it returns a hashref with these keys, and you WILL read all of them:
"stdout","stderr"β array references containing the output of these filehandles π"retval"β the result ofwait()"timed_out"β true if the child had to be interrupted (rip little guy π)
and heads up: system errors will cause it to carp. so like, don't be surprised.
π reap_child_group
$class->reap_child_group($pid);
sends SIGHUP and SIGKILL to the process group identified by $pid. and yes, it sleeps for 2 seconds between SIGHUP and SIGKILL β a little moment of silence, a little grace period, then absolute destruction π
β possible_to_signal_process
my $bool = $class->possible_to_signal_process($pid)
checks whether it's even possible to send a signal to $pid. what does that mean, you ask? to be brief: the process is owned by the same user, or we're the super-user. super useful for checking that a child process is still alive (even if it's only alive as a zombie π§) and that it hasn't gone and changed its UID on you. sneaky.
π¦ set_effective_user_id
eval {
$class->set_effective_user_id($uid);
};
if ($@) {
# Failed to set EUID
}
the name says it all ...
(no genuinely, that's the documentation. the name says it all. we're trusting you with this one π)
π set_effective_group_id
see documentation for set_effective_user_id(). same deal, but group-y.
π set_real_user_id
see documentation for set_effective_user_id(). yup. again.
π set_real_group_id
see documentation for set_effective_user_id(). the last of the quartet, bestie πΈ
π§ set_umask
sets the umask so that files created by plugins are group writable. and this is important: only call it right before exec-ing a plugin. like, timing matters, don't just be setting umasks recreationally β¨
π‘ real talk: those four set_*_id methods are the ones where getting it wrong is not cute. read the code, not just the vibes.
and that's the whole page!! no cap, every single method accounted for π«Ά
this little gem is Munin::Node::OS(3), part of the User Contributed Perl Documentation, and it shipped with perl v5.42.3 dated 1980-01-01 (yes really, that date, iconic behavior π). go forth and check your perms, bestie ππ
π¦ where this page comes from
- nixos 26.05: munin 2.0.76
- nixpkgs unstable: munin 2.0.78
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms