mirror of
https://github.com/librenms/librenms-agent.git
synced 2024-05-09 09:54:52 +00:00
now requires cron usage
This commit is contained in:
@ -2,15 +2,40 @@
|
||||
|
||||
# Add this to your snmpd.conf as below.
|
||||
# extend fail2ban /etc/snmp/fail2ban
|
||||
#
|
||||
# Then add to your cron tab...
|
||||
# */3 * * * * /root/snmp-extends/fail2ban.pl -u
|
||||
|
||||
#make sure this path is correct
|
||||
my $f2bc="/usr/local/bin/fail2ban-client";
|
||||
|
||||
# The cache file to use.
|
||||
my $cache='/var/cache/fail2ban';
|
||||
|
||||
|
||||
##
|
||||
## you should not have to touch anything below this
|
||||
##
|
||||
use strict;
|
||||
use warnings;
|
||||
use Getopt::Std;
|
||||
|
||||
$Getopt::Std::STANDARD_HELP_VERSION = 1;
|
||||
sub main::VERSION_MESSAGE {
|
||||
print "fail2ban-client SNMP extend 0.0.0\n";
|
||||
};
|
||||
|
||||
|
||||
sub main::HELP_MESSAGE {
|
||||
print "\n".
|
||||
"-u Update '".$cache."'\n";
|
||||
}
|
||||
|
||||
#gets the options
|
||||
my %opts=();
|
||||
getopts('u', \%opts);
|
||||
|
||||
if (defined( $opts{u} )){
|
||||
|
||||
#gets a list of jails
|
||||
my $jailsOutput=`$f2bc status`;
|
||||
@ -40,4 +65,19 @@ while(defined($jails[$int])){
|
||||
$int++;
|
||||
}
|
||||
|
||||
print $total."\n".$toReturn;
|
||||
open(my $writefh, ">", $cache) or die "Can't open '".$cache."'";
|
||||
print $writefh $total."\n".$toReturn;
|
||||
close($writefh);
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
my $old='';
|
||||
open(my $readfh, "<", $cache) or die "Can't open '".$cache."'";
|
||||
# if this is over 2048, something is most likely wrong
|
||||
read($readfh , $old , 10240);
|
||||
close($readfh);
|
||||
print $old;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user