����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 POSIX 'strftime';
use Date::Parse 'str2time';
use Getopt::Long qw(:config no_ignore_case);
my (
$file, $math, $help, $warntime, $warncount,
$crittime, $critcount, $state, $message,
);
my %E_STATE = (
'OK' => 0,
'WARNING' => 1,
'CRITICAL' => 2,
'UNKNOWN' => 3
);
# usage
my $USAGE = <<"END_USAGE";
Usage: check_brutforce [OPTION]...
END_USAGE
# help
my $HELP = <<'END_HELP';
GENERAL OPTIONS:
--file Log file for find math
--math String for search
--warntime Time in minutes for which count number of matches for WARN
status
--warncount Count matches for WARN status
--crittime Time in minutes for which count number of matches for CRIT
status
--critcount Count matches for CRIT status
--help Print help
END_HELP
GetOptions(
'file=s' => \$file,
'math=s' => \$math,
'warntime=i' => \$warntime,
'warncount=i' => \$warncount,
'crittime=i' => \$crittime,
'critcount=i' => \$critcount,
'help' => \$help,
);
# print help
if ($help) {
print $USAGE, $HELP;
exit $E_STATE{'UNKNOWN'};
}
#test file exists
my $tf = `sudo test -f $file`;
if ($?) {
print "File for parse not exists\n";
exit $E_STATE{'UNKNOWN'};
}
sub log_parse ( $file, $count ) {
my $matched = `sudo /bin/grep -c "$math" $file`;
chop $matched;
if ( $matched < $count ) {
say $message;
exit $state;
}
my @records = `sudo /bin/grep "$math" $file | /usr/bin/tail -n $count`;
my $first_date = $1 if $records[0] =~ /\[(.*)\s\+[0-9]+\]/;
exit 1 if !$first_date;
my $log_date = str2time($first_date);
return $log_date;
}
$message = 'OK';
$state = $E_STATE{'OK'};
my $current_date = strftime( '%s', localtime );
if ( ( $crittime * 60 ) > ( $current_date - log_parse( $file, $critcount ) ) )
{
$message
= "CRITICAL: In last $crittime minutes there were more than $critcount requests to $math";
$state = $E_STATE{'CRITICAL'};
}
elsif (
( $warntime * 60 ) > ( $current_date - log_parse( $file, $warncount ) ) )
{
$message
= "WARNING: In last $warntime minutes there were more than $warncount requests to $math";
$state = $E_STATE{'WARNING'};
}
say $message;
exit $state;