Rex::Co...::Gather(3)
π¦ Rex::Co...::Gather(3) β aka Rex::Commands::Gather π¦
okay so bestie, quick vibe check: this is a page from the User Contributed Perl Documentation section, and it's about gathering literally everything you'd ever wanna know about a machine. pull up a chair π
β¨ NAME β¨
Rex::Commands::Gather β Hardware and Information gathering π
πΈ DESCRIPTION πΈ
With this module you can gather hardware and software information. it's giving "investigator era" and honestly? iconic.
literally all of these functions will not be reported. they're lowkey the chillest functions in the whole codebase β they don't modify anything. pure read-only main character energy. π«Ά
β SYNOPSIS β
operating_system_is("SuSE");
that's it. that's the whole synopsis. short and slay. π
π EXPORTED FUNCTIONS π
π§ get_operating_system
Will return the current operating system name. that's it, that's the tea.
task "get-os", "server01", sub {
say get_operating_system();
};
Aliased by operating_system(). iykyk π
π§ operating_system
Alias for get_operating_system(). literally the same thing, just a shorter name. twins fr fr π
π§ get_system_information
Will return a hash of all system information. and not me telling you that these Information will also be used by the template function β so it's not just a pretty face, she's booked and busy β¨
π§ kernelname
Will return the kernel name of the operating system. For example on a linux system it will return Linux. no notes, perfect behavior. π¦
π§ dump_system_information
This function dumps all known system information on stdout. it's giving "show me everything" and honestly we respect it π
π§ operating_system_is($string)
Will return 1 if the operating system is $string.
task "is_it_suse", "server01", sub {
if( operating_system_is("SuSE") ) {
say "This is a SuSE system.";
}
};
π§ operating_system_version()
Will return the os release number as an integer. okay so the way this works is lowkey a little math-y but it's fine β for example, it will convert 5.10 to 510, 10.04 to 1004 or 6.0.3 to 603. honestly? ate. π₯
task "prepare", "server01", sub {
if( operating_system_version() >= 510 ) {
say "OS Release is higher or equal to 510";
}
};
π§ operating_system_release()
Will return the os release number as is. no conversion, no glow-up, just the raw string. periodt. π
π§ network_interfaces
Return an HashRef of all the networkinterfaces and their configuration. ngl this one's a favorite.
task "get_network_information", "server01", sub {
my $net_info = network_interfaces();
};
You can iterate over the devices as follow π
my $net_info = network_interfaces();
for my $dev ( keys %{ $net_info } ) {
say "$dev has the ip: " . $net_info->{$dev}->{"ip"} . " and the netmask: " . $net_info->{$dev}->{"netmask"};
}
π§ memory
Return an HashRef of all memory information. so useful, so iconic. πΈ
task "get_memory_information", "server01", sub {
my $memory = memory();
say "Total: " . $memory->{"total"};
say "Free: " . $memory->{"free"};
say "Used: " . $memory->{"used"};
say "Cached: " . $memory->{"cached"};
say "Buffers: " . $memory->{"buffers"};
};
π§ is_freebsd
Returns true if the target system is a FreeBSD.
task "foo", "server1", "server2", sub {
if(is_freebsd) {
say "This is a freebsd system...";
}
else {
say "This is not a freebsd system...";
}
};
π§ is_redhat
task "foo", "server1", sub {
if(is_redhat) {
# do something on a redhat system (like RHEL, Fedora, CentOS, Scientific Linux
}
};
π§ is_fedora
task "foo", "server1", sub {
if(is_fedora) {
# do something on a fedora system
}
};
π§ is_suse
task "foo", "server1", sub {
if(is_suse) {
# do something on a suse system
}
};
π§ is_mageia
task "foo", "server1", sub {
if(is_mageia) {
# do something on a mageia system (or other Mandriva followers)
}
};
π§ is_debian
task "foo", "server1", sub {
if(is_debian) {
# do something on a debian system
}
};
π§ is_alt
task "foo", "server1", sub {
if(is_alt) {
# do something on a ALT Linux system
}
};
π§ is_netbsd
Returns true if the target system is a NetBSD.
task "foo", "server1", "server2", sub {
if(is_netbsd) {
say "This is a netbsd system...";
}
else {
say "This is not a netbsd system...";
}
};
π§ is_openbsd
Returns true if the target system is an OpenBSD.
task "foo", "server1", "server2", sub {
if(is_openbsd) {
say "This is an openbsd system...";
}
else {
say "This is not an openbsd system...";
}
};
π§ is_linux
Returns true if the target system is a Linux System.
task "prepare", "server1", "server2", sub {
if(is_linux) {
say "This is a linux system...";
}
else {
say "This is not a linux system...";
}
};
π§ is_bsd
Returns true if the target system is a BSD System.
task "prepare", "server1", "server2", sub {
if(is_bsd) {
say "This is a BSD system...";
}
else {
say "This is not a BSD system...";
}
};
π§ is_solaris
Returns true if the target system is a Solaris System.
task "prepare", "server1", "server2", sub {
if(is_solaris) {
say "This is a Solaris system...";
}
else {
say "This is not a Solaris system...";
}
};
π§ is_windows
Returns true if the target system is a Windows System. (no example, she's mysterious like that π)
π§ is_openwrt
Returns true if the target system is an OpenWrt System.
π§ is_gentoo
Returns true if the target system is a Gentoo System.
π§ is_arch
task "foo", "server1", sub {
if(is_arch) {
# do something on a arch system
}
};
π§ is_void
Returns true if the target system is a Void Linux system. and that's the whole list bestie, we made it π
ok real talk for a sec: every single one of these is read-only. no side effects, no surprises, no "oops i broke prod". they just look and report back. π«Ά
and that's a wrap, bestie! this page came straight out of the User Contributed Perl Documentation, and the footer info is: perl v5.42.3, dated 2023-08-05. go forth and gather, queen ππ
π¦ where this page comes from
- nixos 26.05: perl5.42.3-Rex 1.14.3
- nixpkgs unstable: perl5.42.3-Rex 1.14.3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms