/usr/sbin/bld-mrtg is in bld-tools 0.3.4.1-4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #!/usr/bin/perl
#
# This script reads BLD dump files and prints statistics about the number
# of currently blacklisted IPs and the number of IPs added in the last 5
# minutes. The default output is MRTG-friendly.
#
# Olivier Beyssac <obld@r14.freenix.org>
#
use strict;
# If you don't use BLD default value for blacklist expiration (-e option
# or blacklist_expiration parameter in bld.conf(5)), change this
my $expiration = 900;
# If you don't run MRTG every 5 minutes, change this
my $rate = 300;
my $dump = "/var/run/bld/bld_blacklist.dump";
my $state = "/var/run/bld-mrtg.state";
my $current_time = time();
my $count = 0;
my $total = 0;
open(BLD, "bldread $dump |");
while (<BLD>) {
if (/^(\d+\.\d+\.\d+\.\d+;\d+;(\d+);/) {
my $ip = $1;
my $time = $2;
$total++ if ($time > $current_time - $expiration);
if ($time > $current_time - $rate) {
$count++;
}
}
}
close(BLD);
print "$count\n$total\n\n\n";
|