����JFIF��x�x����'
| Server IP : 78.140.185.180 / Your IP : 216.73.216.170 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/self/root/proc/1630575/root/usr/lib64/nagios/plugins/base/ |
Upload File : |
#!/usr/bin/env perl
use extreme;
use English;
use Getopt::Long;
my ( $opt_w, $opt_c, @incidents );
# subs
sub process_arguments() {
GetOptions(
"w|warning=i" => \$opt_w, # warning if above this number
"c|critical=i" => \$opt_c, # critical if above this number
);
unless ( defined $opt_w && defined $opt_c ) {
print "Usage: $0 -w [--warning] <warn> -c [--critical] <crit>\n";
exit 3;
}
if ( $opt_w >= $opt_c ) {
print "Warning (-w) cannot be greater than Critical (-c)!\n";
exit 3;
}
return;
}
exec "sudo $0 @ARGV" if $UID > 0;
process_arguments();
my @snapshots
= `find /vz/private/*/root.hdd/ -type f -name 'root.hdd.*' 2>/dev/null`;
my $now = time;
my $exit_code = 0;
my $exit_code_c = 0;
chomp(@snapshots);
for my $snapshot (@snapshots) {
my $snapshots_mdtm = ( stat($snapshot) )[9];
my $diff = int( ( $now - $snapshots_mdtm ) / 86400 );
if ( $diff >= $opt_c ) {
push @incidents, "$snapshot created $diff days ago";
$exit_code_c = 2;
}
elsif ( $diff >= $opt_w && $diff < $opt_c ) {
push @incidents, "$snapshot created $diff days ago";
$exit_code = 1;
}
}
if ( $exit_code_c ) {
say "Found snapshot older than $opt_c days:";
say join( "\n", @incidents );
exit $exit_code_c;
}
elsif ( $exit_code ) {
say "Found snapshots older than $opt_w days:";
say join( "\n", @incidents );
exit $exit_code;
}
else {
say "OK - no overdue snapshots found";
exit $exit_code;
}