����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/extra/ |
Upload File : |
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw(say);
use Time::Piece;
use Getopt::Long;
help() if !(@ARGV);
my ( $opt_d, @errors );
my $exitcode = 0;
# Set options
GetOptions(
"help|h" => \&help,
"d=i" => \$opt_d
);
help() unless $opt_d;
my $since = `/bin/uptime -s`;
chomp $since;
my $since_epoch = Time::Piece->strptime( $since, "%Y-%m-%d %H:%M:%S")->epoch;
my $days_epoch = $opt_d * 86400;
my $cur_epoch = time();
my $diff_epoch = $cur_epoch - $since_epoch;
if ( $diff_epoch >= $days_epoch ) {
push ( @errors, 'The uptime exceeds ' . $opt_d . ' days!' );
$exitcode = 2;
} elsif ( $diff_epoch <= '86400' ) {
push ( @errors, 'The uptime is less than 1 day!' );
$exitcode = 2;
}
@errors ? say @errors : say 'OK';
exit $exitcode;
# subs
sub help {
print "Usage : $0 -d 30 [amount of days]\n";
print "Options :\n";
print " -d Amount of days after when uptime becomes critical\n";
print " -h, --help\n\tPrint this help screen\n";
exit 3;
}