NAME
Monitoring::Sneck::Checks - nagios style checks run as Perl inside of sneck
VERSION
Version 0.0.2
SYNOPSIS
use Monitoring::Sneck::Checks;
my $return = Monitoring::Sneck::Checks->run(
check => 'http',
args => [ '-H', 'www.example.org', '-S', '-w', '1', '-c', '2' ],
timeout => 30,
);
print $return->{combined};
exit( $return->{code} );
Or from a sneck config.
www|perl:http -H www.example.org -S -w 1 -c 2
DESCRIPTION
Runs checks written as Perl modules under Monitoring::Sneck::Checks::, in process, so sneck does not have to start a new program for each. They return the same exit codes as nagios plugins.
A check is the module Monitoring::Sneck::Checks::$name, subclassing Monitoring::Sneck::Checks::base, where the shared helpers are. See that for writing one.
The checks that come with it are...
- accounts :: Monitoring::Sneck::Checks::accounts, local user accounts.
- cciss :: Monitoring::Sneck::Checks::cciss, HP Smart Array controllers, through cciss_vol_status.
- cert_dir :: Monitoring::Sneck::Checks::cert_dir, every certificate in directories.
- cert_file :: Monitoring::Sneck::Checks::cert_file, certificate files.
- checksums :: Monitoring::Sneck::Checks::checksums, files against stored checksums.
- config_value :: Monitoring::Sneck::Checks::config_value, values in config files.
- conntrack :: Monitoring::Sneck::Checks::conntrack, how full the connection tracking table is.
- containers :: Monitoring::Sneck::Checks::containers, Docker or Podman containers.
- debsecan :: Monitoring::Sneck::Checks::debsecan, Debian security fixes, through debsecan.
- disk :: Monitoring::Sneck::Checks::disk, how full file systems are.
- dns :: Monitoring::Sneck::Checks::dns, DNS lookups.
- dns_sync :: Monitoring::Sneck::Checks::dns_sync, a zone's nameservers having the same serial.
- file_age :: Monitoring::Sneck::Checks::file_age, file age and size.
- file_handles :: Monitoring::Sneck::Checks::file_handles, open files against the system limit.
- file_mode :: Monitoring::Sneck::Checks::file_mode, the mode, owner, and group of files.
- hosts :: Monitoring::Sneck::Checks::hosts, /etc/hosts.
- http :: Monitoring::Sneck::Checks::http, HTTP and HTTPS.
- http_json :: Monitoring::Sneck::Checks::http_json, values in a JSON response.
- https_cert :: Monitoring::Sneck::Checks::https_cert, the certificate a TLS server hands out, STARTTLS included.
- interface :: Monitoring::Sneck::Checks::interface, network interfaces being up, at speed, and not erroring.
- jails :: Monitoring::Sneck::Checks::jails, FreeBSD jails and bhyve VMs running.
- kernel_modules :: Monitoring::Sneck::Checks::kernel_modules, kernel modules being loaded or not.
- listening :: Monitoring::Sneck::Checks::listening, what ports are listened on.
- load :: Monitoring::Sneck::Checks::load, the load averages.
- log :: Monitoring::Sneck::Checks::log, new lines in a log for a regex.
- memory :: Monitoring::Sneck::Checks::memory, how much memory is used.
- mount :: Monitoring::Sneck::Checks::mount, file systems being mounted and writable.
- neighbors :: Monitoring::Sneck::Checks::neighbors, how full the ARP and NDP neighbor tables are.
- ntp :: Monitoring::Sneck::Checks::ntp, the local clock against a NTP server.
- oom :: Monitoring::Sneck::Checks::oom, processes killed for running out of memory.
- packages :: Monitoring::Sneck::Checks::packages, packages being installed or not.
- pid_file :: Monitoring::Sneck::Checks::pid_file, the process in a PID file running.
- ping :: Monitoring::Sneck::Checks::ping, ICMP, TCP, or UDP ping.
- pkg_audit :: Monitoring::Sneck::Checks::pkg_audit, FreeBSD packages with known vulnerabilities.
- pressure :: Monitoring::Sneck::Checks::pressure, Linux pressure stall information.
- procs :: Monitoring::Sneck::Checks::procs, how many processes are running.
- rbl :: Monitoring::Sneck::Checks::rbl, DNS block lists.
- reboot_needed :: Monitoring::Sneck::Checks::reboot_needed, a reboot or restarts being needed after updates.
- resolv :: Monitoring::Sneck::Checks::resolv, /etc/resolv.conf.
- sensors :: Monitoring::Sneck::Checks::sensors, temperatures, fans, and voltages.
- service :: Monitoring::Sneck::Checks::service, services running.
- smtp :: Monitoring::Sneck::Checks::smtp, a SMTP server.
- sshd_config :: Monitoring::Sneck::Checks::sshd_config, settings in sshd_config.
- swap :: Monitoring::Sneck::Checks::swap, how much swap is used.
- swraid :: Monitoring::Sneck::Checks::swraid, software RAID, md, gmirror, and graid.
- sysctl :: Monitoring::Sneck::Checks::sysctl, sysctl values.
- systemd_failed :: Monitoring::Sneck::Checks::systemd_failed, failed systemd units.
- tcp :: Monitoring::Sneck::Checks::tcp, TCP services.
- tls_protocols :: Monitoring::Sneck::Checks::tls_protocols, what TLS versions a server takes.
- uptime :: Monitoring::Sneck::Checks::uptime, how long the host has been up.
TIMEOUTS
Checks are not forked, so they are timed out two ways. Each check hands its timeout, a second under the one it is run with, to whatever it talks to the network through, such as LWP::UserAgent or Net::DNS::Resolver. As a backstop, an alarm fires at the timeout it is run with, which makes it UNKNOWN. A command the check is running through "run_command" in Monitoring::Sneck::Checks::base is killed when it fires. The alarm can not break into everything, such as some name lookups in the C library, so the first is what is relied on.
METHODS
list
Lists the checks that can be found, every Monitoring::Sneck::Checks::* module in @INC other than base, by file name, without loading them. Where two directories have one, the first is used, as require would.
Returns a hash ref of check names to what each is for, the text after the dash on the NAME line of its POD, or a empty string for one that has no such line.
my $checks = Monitoring::Sneck::Checks->list;
foreach my $name ( sort( keys( %{$checks} ) ) ) {
print $name . ' :: ' . $checks->{$name} . "\n";
}
# accounts :: checks local user accounts
# ...
load
Loads a check, which run does for itself. For when the module is wanted without running it, such as for its POD. Dies if it can not be loaded, saying why.
- check :: The name of the check, as for "run".
Returns the name of the module, such as Monitoring::Sneck::Checks::http.
my $module = Monitoring::Sneck::Checks->load('http');
my $pod = $INC{'Monitoring/Sneck/Checks/http.pm'};
run
Runs a check.
- check :: The name of the check, such as http. Made up of a-z, 0-9, and _, starting with a letter.
- args :: The args for it, as a array ref, or a string, which Getopt::Long splits like a shell would. Default :: []
- timeout :: Seconds it is given. Default :: 30
Returns a hash ref as below.
- code :: The nagios style return code, 0 for OK, 1 for WARNING, 2 for CRITICAL, and 3 for UNKNOWN, or -1 if the check could not be loaded. That includes a bad name, base, and a module that is not a check. Bad args, unbalanced quotes included, timing out, dying, and returning something other than 0 to 3 are UNKNOWN.
- stdout :: What it printed as output.
- stderr :: Its errors and warnings.
- combined :: Both, in the order they were printed.
my $return = Monitoring::Sneck::Checks->run( check => 'dns', args => '-H www.example.org' );
if ( $return->{code} == -1 ) {
warn( 'could not load it, ' . $return->{stderr} );
}
AUTHOR
Zane C. Bowers-Hadley, <vvelox at vvelox.net>
BUGS
Please report any bugs or feature requests to https://github.com/VVelox/Monitoring-Sneck-Checks/issues.
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by Zane C. Bowers-Hadley.
This is free software, licensed under:
The GNU Lesser General Public License, Version 2.1, February 1999