« blib/lib/Monitoring/Sneck/Checks/base.pm
↑ Summary
blib/lib/Monitoring/Sneck/Checks/conntrack.pm »
| 1 | package Monitoring::Sneck::Checks; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 300 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 300 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 300 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 300 | ▶ | use Time::HiRes (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | Monitoring::Sneck::Checks - nagios style checks run as Perl inside of sneck | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | Version 0.2.0 | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 300 | our $VERSION = '0.2.0'; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # Seconds a check is given if run is not told otherwise. | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 300 | our $TIMEOUT = 30; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | use Monitoring::Sneck::Checks; | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | my $return = Monitoring::Sneck::Checks->run( | ||||||||||||||||||||||||||||||||||||||||||
| 28 | check => 'http', | ||||||||||||||||||||||||||||||||||||||||||
| 29 | args => [ '-H', 'www.example.org', '-S', '-w', '1', '-c', '2' ], | ||||||||||||||||||||||||||||||||||||||||||
| 30 | timeout => 30, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 32 | print $return->{combined}; | ||||||||||||||||||||||||||||||||||||||||||
| 33 | exit( $return->{code} ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | Or from a sneck config. | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | www|perl:http -H www.example.org -S -w 1 -c 2 | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | Runs checks written as Perl modules under Monitoring::Sneck::Checks::, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | in process, so sneck does not have to start a new program for each. | ||||||||||||||||||||||||||||||||||||||||||
| 43 | They return the same exit codes as nagios plugins. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | A check is the module Monitoring::Sneck::Checks::$name, subclassing | ||||||||||||||||||||||||||||||||||||||||||
| 46 | L<Monitoring::Sneck::Checks::base>, where the shared helpers are. See | ||||||||||||||||||||||||||||||||||||||||||
| 47 | that for writing one. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | The checks that come with it are... | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | - accounts :: L<Monitoring::Sneck::Checks::accounts>, local user accounts. | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | - apparmor :: L<Monitoring::Sneck::Checks::apparmor>, AppArmor enabled with its profiles enforcing. | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | - auditd :: L<Monitoring::Sneck::Checks::auditd>, Linux auditing on with the rules it should have. | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | - bond :: L<Monitoring::Sneck::Checks::bond>, link aggregation, bonding on Linux and lagg on FreeBSD. | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | - cciss :: L<Monitoring::Sneck::Checks::cciss>, HP Smart Array controllers, through cciss_vol_status. | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | - cert_dir :: L<Monitoring::Sneck::Checks::cert_dir>, every certificate in directories. | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | - cert_file :: L<Monitoring::Sneck::Checks::cert_file>, certificate files. | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | - checksums :: L<Monitoring::Sneck::Checks::checksums>, files against stored checksums. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | - config_value :: L<Monitoring::Sneck::Checks::config_value>, values in config files. | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | - conntrack :: L<Monitoring::Sneck::Checks::conntrack>, how full the connection tracking table is. | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | - containers :: L<Monitoring::Sneck::Checks::containers>, Docker or Podman containers. | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | - debsecan :: L<Monitoring::Sneck::Checks::debsecan>, Debian security fixes, through debsecan. | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | - disk :: L<Monitoring::Sneck::Checks::disk>, how full file systems are. | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | - dns :: L<Monitoring::Sneck::Checks::dns>, DNS lookups. | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | - dns_sync :: L<Monitoring::Sneck::Checks::dns_sync>, a zone's nameservers having the same serial. | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | - edac :: L<Monitoring::Sneck::Checks::edac>, memory errors Linux's EDAC has counted. | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | - fail2ban :: L<Monitoring::Sneck::Checks::fail2ban>, fail2ban's jails up, and how many are banned. | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | - file_age :: L<Monitoring::Sneck::Checks::file_age>, file age and size. | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | - file_content :: L<Monitoring::Sneck::Checks::file_content>, a file being there and what is in it. | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | - file_handles :: L<Monitoring::Sneck::Checks::file_handles>, open files against the system limit. | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | - file_mode :: L<Monitoring::Sneck::Checks::file_mode>, the mode, owner, and group of files. | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | - hosts :: L<Monitoring::Sneck::Checks::hosts>, /etc/hosts. | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | - http :: L<Monitoring::Sneck::Checks::http>, HTTP and HTTPS. | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | - http_json :: L<Monitoring::Sneck::Checks::http_json>, values in a JSON response. | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | - https_cert :: L<Monitoring::Sneck::Checks::https_cert>, the certificate a TLS server hands out, STARTTLS included. | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | - interface :: L<Monitoring::Sneck::Checks::interface>, network interfaces being up, at speed, and not erroring. | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | - jails :: L<Monitoring::Sneck::Checks::jails>, FreeBSD jails and bhyve VMs running. | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | - kernel_modules :: L<Monitoring::Sneck::Checks::kernel_modules>, kernel modules being loaded or not. | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | - ldap :: L<Monitoring::Sneck::Checks::ldap>, a LDAP server binding and searching, needing L<Net::LDAP>. | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | - linux_ras :: L<Monitoring::Sneck::Checks::linux_ras>, hardware errors rasdaemon has logged. | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | - listening :: L<Monitoring::Sneck::Checks::listening>, what ports are listened on. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | - load :: L<Monitoring::Sneck::Checks::load>, the load averages. | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | - log :: L<Monitoring::Sneck::Checks::log>, new lines in a log for a regex. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | - mailq :: L<Monitoring::Sneck::Checks::mailq>, the mail queue of Postfix or Exim. | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | - memory :: L<Monitoring::Sneck::Checks::memory>, how much memory is used. | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | - mount :: L<Monitoring::Sneck::Checks::mount>, file systems being mounted and writable. | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | - mtime :: L<Monitoring::Sneck::Checks::mtime>, file mtimes against a time. | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | - neighbors :: L<Monitoring::Sneck::Checks::neighbors>, how full the ARP and NDP neighbor tables are. | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | - ntp :: L<Monitoring::Sneck::Checks::ntp>, the local clock against a NTP server. | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | - oom :: L<Monitoring::Sneck::Checks::oom>, processes killed for running out of memory. | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | - packages :: L<Monitoring::Sneck::Checks::packages>, packages being installed or not. | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | - pid_file :: L<Monitoring::Sneck::Checks::pid_file>, the process in a PID file running. | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | - ping :: L<Monitoring::Sneck::Checks::ping>, ICMP, TCP, or UDP ping. | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | - pkg_audit :: L<Monitoring::Sneck::Checks::pkg_audit>, FreeBSD packages with known vulnerabilities. | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | - pressure :: L<Monitoring::Sneck::Checks::pressure>, Linux pressure stall information. | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | - procs :: L<Monitoring::Sneck::Checks::procs>, how many processes are running. | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | - rbl :: L<Monitoring::Sneck::Checks::rbl>, DNS block lists. | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | - reboot_needed :: L<Monitoring::Sneck::Checks::reboot_needed>, a reboot or restarts being needed after updates. | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | - resolv :: L<Monitoring::Sneck::Checks::resolv>, /etc/resolv.conf. | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | - selinux :: L<Monitoring::Sneck::Checks::selinux>, SELinux in the mode it should be. | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | - sensors :: L<Monitoring::Sneck::Checks::sensors>, temperatures, fans, and voltages. | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | - service :: L<Monitoring::Sneck::Checks::service>, services running. | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | - smart :: L<Monitoring::Sneck::Checks::smart>, disk health through smartctl. | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | - smtp :: L<Monitoring::Sneck::Checks::smtp>, a SMTP server. | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | - sshd_config :: L<Monitoring::Sneck::Checks::sshd_config>, settings in sshd_config. | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | - swap :: L<Monitoring::Sneck::Checks::swap>, how much swap is used. | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | - swraid :: L<Monitoring::Sneck::Checks::swraid>, software RAID, md, gmirror, and graid. | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | - sysctl :: L<Monitoring::Sneck::Checks::sysctl>, sysctl values. | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | - systemd_failed :: L<Monitoring::Sneck::Checks::systemd_failed>, failed systemd units. | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | - tcp :: L<Monitoring::Sneck::Checks::tcp>, TCP services. | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | - thermal_throttle :: L<Monitoring::Sneck::Checks::thermal_throttle>, CPUs being thermally throttled. | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | - time_sync :: L<Monitoring::Sneck::Checks::time_sync>, the local time daemon being synchronised. | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | - tls_protocols :: L<Monitoring::Sneck::Checks::tls_protocols>, what TLS versions a server takes. | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | - uptime :: L<Monitoring::Sneck::Checks::uptime>, how long the host has been up. | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | - vrrp :: L<Monitoring::Sneck::Checks::vrrp>, keepalived, freevrrpd, or FreeBSD's CARP being MASTER or BACKUP as it should. | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | - wireguard :: L<Monitoring::Sneck::Checks::wireguard>, WireGuard peers having handshaken recently. | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | - zfs :: L<Monitoring::Sneck::Checks::zfs>, ZFS pools, health, capacity, scrubs, and device errors. | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | =head1 TIMEOUTS | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | Checks are not forked, so they are timed out two ways. Each check hands | ||||||||||||||||||||||||||||||||||||||||||
| 188 | its timeout, a second under the one it is run with, to whatever it | ||||||||||||||||||||||||||||||||||||||||||
| 189 | talks to the network through, such as L<LWP::UserAgent> or | ||||||||||||||||||||||||||||||||||||||||||
| 190 | L<Net::DNS::Resolver>. As a backstop, an alarm fires at the timeout it | ||||||||||||||||||||||||||||||||||||||||||
| 191 | is run with, which makes it UNKNOWN. A command the check is running | ||||||||||||||||||||||||||||||||||||||||||
| 192 | through L<Monitoring::Sneck::Checks::base/run_command> is killed when | ||||||||||||||||||||||||||||||||||||||||||
| 193 | it fires. The alarm can not break into everything, such as some name | ||||||||||||||||||||||||||||||||||||||||||
| 194 | lookups in the C library, so the first is what is relied on. | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | =head2 list | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | Lists the checks that can be found, every Monitoring::Sneck::Checks::* | ||||||||||||||||||||||||||||||||||||||||||
| 201 | module in @INC other than base, by file name, without loading them. | ||||||||||||||||||||||||||||||||||||||||||
| 202 | Where two directories have one, the first is used, as require would. | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | Returns a hash ref of check names to what each is for, the text after | ||||||||||||||||||||||||||||||||||||||||||
| 205 | the dash on the NAME line of its POD, or a empty string for one that | ||||||||||||||||||||||||||||||||||||||||||
| 206 | has no such line. | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | my $checks = Monitoring::Sneck::Checks->list; | ||||||||||||||||||||||||||||||||||||||||||
| 209 | foreach my $name ( sort( keys( %{$checks} ) ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 210 | print $name . ' :: ' . $checks->{$name} . "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | # accounts :: checks local user accounts | ||||||||||||||||||||||||||||||||||||||||||
| 213 | # ... | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 5 | ▶ | sub list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 5 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | my %checks; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 5 | foreach my $dir (@INC) { | |||||||||||||||||||||||||||||||||||||||||
| 222 | 44 | ▶ | next if ref($dir) || !-d $dir . '/Monitoring/Sneck/Checks'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $dir or not -d $dir . '/Monitoring/Sneck/Checks'
MC/DC50%1/2
ref $dir or not -d $dir . '/Monitoring/Sneck/Checks'
ref $dir
not -d $dir . '/Monitoring/Sneck/Checks'
Truth table66%2/3
A or not(B)
A= ref $dirB= not -d $dir . '/Monitoring/Sneck/Checks'
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 300 | ▶ | foreach my $file ( glob( $dir . '/Monitoring/Sneck/Checks/*.pm' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 967 | my ($name) = $file =~ m{/([a-z][a-z0-9_]*)\.pm\z}; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 967 | ▶ | next if !defined($name) || $name eq 'base' || exists( $checks{$name} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $name or $name eq "base" or exists $checks{$name}
not defined $name or $name eq "base"
MC/DC66%2/3
not defined $name or $name eq "base" or exists $checks{$name}
not defined $name
$name eq "base"
exists $checks{$name}
Truth table75%3/4
not(A) or B or C
A= not defined $nameB= $name eq "base"C= exists $checks{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 350 | $checks{$name} = _pod_name_text($file); | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 5 | return \%checks; | |||||||||||||||||||||||||||||||||||||||||
| 231 | } ## end sub list | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | # Reads what a module says it is for, from the NAME section of its POD, | ||||||||||||||||||||||||||||||||||||||||||
| 234 | # for list. The file is read, not loaded, so nothing in it runs. | ||||||||||||||||||||||||||||||||||||||||||
| 235 | # | ||||||||||||||||||||||||||||||||||||||||||
| 236 | # Args... | ||||||||||||||||||||||||||||||||||||||||||
| 237 | # | ||||||||||||||||||||||||||||||||||||||||||
| 238 | # - file :: Path to the module file. | ||||||||||||||||||||||||||||||||||||||||||
| 239 | # | ||||||||||||||||||||||||||||||||||||||||||
| 240 | # Returns the text after the " - " on the NAME line, or a empty string | ||||||||||||||||||||||||||||||||||||||||||
| 241 | # if the file can not be read or has no such line. | ||||||||||||||||||||||||||||||||||||||||||
| 242 | # | ||||||||||||||||||||||||||||||||||||||||||
| 243 | # Example... | ||||||||||||||||||||||||||||||||||||||||||
| 244 | # | ||||||||||||||||||||||||||||||||||||||||||
| 245 | # _pod_name_text('/usr/local/lib/perl5/Monitoring/Sneck/Checks/http.pm'); | ||||||||||||||||||||||||||||||||||||||||||
| 246 | # # 'checks HTTP and HTTPS' | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 350 | ▶ | sub _pod_name_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pod_name_text: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 350 | my ($file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 350 | ▶ | open( my $fh, '<', $file ) or return ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 350 | my $in_name; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 350 | ▶ | while ( my $line = <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 3900 | ▶ | if ( $line =~ /\A=head1 NAME\s*\z/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 335 | $in_name = 1; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } elsif ( $line =~ /\A=/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $in_name = 0; | |||||||||||||||||||||||||||||||||||||||||
| 257 | ▶ | } elsif ( $in_name && $line =~ /\A\S+ - (.+?)\s*\z/ ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$in_name and $line =~ /\A\S+ - (.+?)\s*\z/u
MC/DC100%2/2
$in_name and $line =~ /\A\S+ - (.+?)\s*\z/u
$in_name
$line =~ /\A\S+ - (.+?)\s*\z/u
Truth table100%3/3
A and B
A= $in_nameB= $line =~ /\A\S+ - (.+?)\s*\z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 335 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 259 | 335 | return $1; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } ## end while ( my $line = <$fh> ) | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 15 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 15 | return ''; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } ## end sub _pod_name_text | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | =head2 load | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | Loads a check, which run does for itself. For when the module is | ||||||||||||||||||||||||||||||||||||||||||
| 270 | wanted without running it, such as for its POD. Dies if it can not be | ||||||||||||||||||||||||||||||||||||||||||
| 271 | loaded, saying why. | ||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | - check :: The name of the check, as for L</run>. | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | Returns the name of the module, such as Monitoring::Sneck::Checks::http. | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | my $module = Monitoring::Sneck::Checks->load('http'); | ||||||||||||||||||||||||||||||||||||||||||
| 278 | my $pod = $INC{'Monitoring/Sneck/Checks/http.pm'}; | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 3551 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 3551 | my ( $class, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 3551 | ▶ | if ( !defined($name) || ref($name) || $name !~ /\A[a-z][a-z0-9_]*\z/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $name or ref $name or not $name =~ /\A[a-z][a-z0-9_]*\z/u
not defined $name or ref $name
MC/DC66%2/3
not defined $name or ref $name or not $name =~ /\A[a-z][a-z0-9_]*\z/u
not defined $name
ref $name
not $name =~ /\A[a-z][a-z0-9_]*\z/u
Truth table75%3/4
not(A) or B or not(C)
A= not defined $nameB= ref $nameC= not $name =~ /\A[a-z][a-z0-9_]*\z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 13 | ▶ | die( 'check name "' | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$name // ""
MC/DC100%1/1
$name // ""
$name
Truth table100%2/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | . ( $name // '' ) | ||||||||||||||||||||||||||||||||||||||||||
| 288 | . '" is not valid, it must be a-z, 0-9, and _, starting with a letter' | ||||||||||||||||||||||||||||||||||||||||||
| 289 | . "\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 3538 | ▶ | if ( $name eq 'base' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 8 | die("base is what checks are built on, not a check\n"); | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | 3530 | my $module = 'Monitoring::Sneck::Checks::' . $name; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 3530 | ▶ | if ( !eval { require( 'Monitoring/Sneck/Checks/' . $name . '.pm' ); 1 } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 7 | die( 'failed to load ' . $module . ', ' . $@ ); | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 3523 | ▶ | if ( !$module->isa('Monitoring::Sneck::Checks::base') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | die( $module . " is not a check, as it is not a Monitoring::Sneck::Checks::base\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 3520 | return $module; | |||||||||||||||||||||||||||||||||||||||||
| 304 | } ## end sub load | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | =head2 run | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | Runs a check. | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | - check :: The name of the check, such as http. Made up of a-z, 0-9, | ||||||||||||||||||||||||||||||||||||||||||
| 311 | and _, starting with a letter. | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | - args :: The args for it, as a array ref, or a string, which | ||||||||||||||||||||||||||||||||||||||||||
| 314 | L<Getopt::Long> splits like a shell would. | ||||||||||||||||||||||||||||||||||||||||||
| 315 | Default :: [] | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | - timeout :: Seconds it is given. | ||||||||||||||||||||||||||||||||||||||||||
| 318 | Default :: 30 | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | Returns a hash ref as below. | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | - code :: The nagios style return code, 0 for OK, 1 for WARNING, 2 for | ||||||||||||||||||||||||||||||||||||||||||
| 323 | CRITICAL, and 3 for UNKNOWN, or -1 if the check could not be loaded. | ||||||||||||||||||||||||||||||||||||||||||
| 324 | That includes a bad name, base, and a module that is not a check. Bad | ||||||||||||||||||||||||||||||||||||||||||
| 325 | args, unbalanced quotes included, timing out, dying, and returning | ||||||||||||||||||||||||||||||||||||||||||
| 326 | something other than 0 to 3 are UNKNOWN. | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | - stdout :: What it printed as output. | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | - stderr :: Its errors and warnings. | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | - combined :: Both, in the order they were printed. | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | my $return = Monitoring::Sneck::Checks->run( check => 'dns', args => '-H www.example.org' ); | ||||||||||||||||||||||||||||||||||||||||||
| 335 | if ( $return->{code} == -1 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 336 | warn( 'could not load it, ' . $return->{stderr} ); | ||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 3536 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 3536 | my ( $class, %opts ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 3536 | my %return = ( code => -1, stdout => '', stderr => '', combined => '' ); | |||||||||||||||||||||||||||||||||||||||||
| 345 | 3536 | my $module = eval { $class->load( $opts{check} ) }; | |||||||||||||||||||||||||||||||||||||||||
| 346 | 3536 | ▶ | if ( !defined($module) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 25 | return _not_loaded( \%return, $@ ); | |||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 3511 | ▶ | my $timeout = $opts{timeout} // $TIMEOUT; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts{"timeout"} // $Monitoring::Sneck::Checks::TIMEOUT
MC/DC0%0/2
$opts{"timeout"} // $Monitoring::Sneck::Checks::TIMEOUT
$opts{"timeout"}
$Monitoring::Sneck::Checks::TIMEOUT
Truth table66%2/3
A // B
A= $opts{"timeout"}B= $Monitoring::Sneck::Checks::TIMEOUT
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 3511 | ▶ | if ( $timeout !~ /\A[0-9]*\.?[0-9]+\z/ || $timeout <= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $timeout =~ /\A[0-9]*\.?[0-9]+\z/u or $timeout <= 0
MC/DC0%0/2
not $timeout =~ /\A[0-9]*\.?[0-9]+\z/u or $timeout <= 0
not $timeout =~ /\A[0-9]*\.?[0-9]+\z/u
$timeout <= 0
Truth table33%1/3
not(A) or B
A= not $timeout =~ /\A[0-9]*\.?[0-9]+\z/uB= $timeout <= 0
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | $timeout = $TIMEOUT; | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | # stray prints and warnings from it or the modules it uses must not reach sneck's own output | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 3511 | my ( $stray_stdout, $stray_stderr ) = ( '', '' ); | |||||||||||||||||||||||||||||||||||||||||
| 357 | 3511 | my $check; | |||||||||||||||||||||||||||||||||||||||||
| 358 | my $code; | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 3511 | my $died; | |||||||||||||||||||||||||||||||||||||||||
| 360 | { | ||||||||||||||||||||||||||||||||||||||||||
| 361 | # the handler that dies is only there inside the eval, where the die is caught. A alarm going off | ||||||||||||||||||||||||||||||||||||||||||
| 362 | # as the eval ends, as when the check died on its own just before it would have, must still have a | ||||||||||||||||||||||||||||||||||||||||||
| 363 | # handler, or it would end the process, but one that does nothing, so nothing gets out of here | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 3511 | ▶ | local $SIG{ALRM} = sub { }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 3511 | $code = eval { | |||||||||||||||||||||||||||||||||||||||||
| 366 | 3511 | ▶ | local $SIG{ALRM} = sub { die( 'timed out after ' . $timeout . " seconds\n" ) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 3511 | local *STDOUT; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 3511 | local *STDERR; | |||||||||||||||||||||||||||||||||||||||||
| 369 | 3511 | open( STDOUT, '>', \$stray_stdout ); | |||||||||||||||||||||||||||||||||||||||||
| 370 | 3511 | open( STDERR, '>', \$stray_stderr ); | |||||||||||||||||||||||||||||||||||||||||
| 371 | 3511 | Time::HiRes::alarm($timeout); | |||||||||||||||||||||||||||||||||||||||||
| 372 | 3511 | $check = $module->new( args => $opts{args}, timeout => $timeout ); | |||||||||||||||||||||||||||||||||||||||||
| 373 | 3277 | my $returned = $check->check; | |||||||||||||||||||||||||||||||||||||||||
| 374 | 2897 | Time::HiRes::alarm(0); | |||||||||||||||||||||||||||||||||||||||||
| 375 | 2897 | $returned; | |||||||||||||||||||||||||||||||||||||||||
| 376 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 3272 | $died = $@; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 3272 | Time::HiRes::alarm(0); | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 3272 | ▶ | if ( !defined($check) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 234 | $check = bless( { stdout => '', stderr => '', combined => '' }, $module ); | |||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 3272 | ▶ | if ( $died ne '' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 375 | $died =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 375 | $check->err( $check->label . ' UNKNOWN - ' . $died . "\n" ); | |||||||||||||||||||||||||||||||||||||||||
| 387 | 375 | $code = 3; | |||||||||||||||||||||||||||||||||||||||||
| 388 | ▶ | } elsif ( !defined($code) || $code !~ /\A[0-3]\z/ ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $code && $code =~ /\A[0-3]\z/u
MC/DC100%2/2
defined $code && $code =~ /\A[0-3]\z/u
defined $code
$code =~ /\A[0-3]\z/u
Truth table100%3/3
A && B
A= defined $codeB= $code =~ /\A[0-3]\z/u
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 12 | ▶ | $check->err( $check->label . ' UNKNOWN - returned "' . ( $code // 'undef' ) . '", not 0, 1, 2, or 3' . "\n" ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$code // "undef"
MC/DC100%1/1
$code // "undef"
$code
Truth table100%2/2
A
A= $code
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 12 | $code = 3; | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 3272 | $return{code} = $code + 0; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 3272 | $return{stdout} = $check->{stdout} . $stray_stdout; | |||||||||||||||||||||||||||||||||||||||||
| 395 | 3272 | $return{stderr} = $check->{stderr} . $stray_stderr; | |||||||||||||||||||||||||||||||||||||||||
| 396 | 3272 | $return{combined} = $check->{combined} . $stray_stdout . $stray_stderr; | |||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 3272 | return \%return; | |||||||||||||||||||||||||||||||||||||||||
| 399 | } ## end sub run | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | # Fills in the return hash of run for a check that could not be loaded. | ||||||||||||||||||||||||||||||||||||||||||
| 402 | # | ||||||||||||||||||||||||||||||||||||||||||
| 403 | # Args... | ||||||||||||||||||||||||||||||||||||||||||
| 404 | # | ||||||||||||||||||||||||||||||||||||||||||
| 405 | # - return :: The hash ref run returns, with code -1. | ||||||||||||||||||||||||||||||||||||||||||
| 406 | # | ||||||||||||||||||||||||||||||||||||||||||
| 407 | # - why :: Why it could not be loaded. A newline is added if missing. | ||||||||||||||||||||||||||||||||||||||||||
| 408 | # | ||||||||||||||||||||||||||||||||||||||||||
| 409 | # Returns the same hash ref, with why as stderr and combined. | ||||||||||||||||||||||||||||||||||||||||||
| 410 | # | ||||||||||||||||||||||||||||||||||||||||||
| 411 | # Example... | ||||||||||||||||||||||||||||||||||||||||||
| 412 | # | ||||||||||||||||||||||||||||||||||||||||||
| 413 | # return _not_loaded( \%return, 'base is what checks are built on, not a check' ); | ||||||||||||||||||||||||||||||||||||||||||
| 414 | # # { code => -1, stdout => '', stderr => "base is ...\n", combined => "base is ...\n" } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 25 | ▶ | sub _not_loaded { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_not_loaded: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 25 | my ( $return, $why ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 25 | $why =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 25 | $return->{stderr} = $why . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 420 | 25 | $return->{combined} = $why . "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 25 | return $return; | |||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >> | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | =head1 BUGS | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | Please report any bugs or feature requests to | ||||||||||||||||||||||||||||||||||||||||||
| 432 | L<https://github.com/VVelox/Monitoring-Sneck-Checks/issues>. | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | This software is Copyright (c) 2026 by Zane C. Bowers-Hadley. | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | This is free software, licensed under: | ||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 300 | 1; | |||||||||||||||||||||||||||||||||||||||||