5 years ago
Automated RBL Check
I know this is out there :)/emoticons/smile@2x.png 2x" title=":)" width="20">
I would love Logicmonitor to have the ability to check IPs for inclusion in the most popular RBL list.
Sometimes...
I am looking at the DNSLookup- DS as a starting point. The code we used to run for Nagios was basically this Perl fragment, need to rework a bit :)/emoticons/smile@2x.png 2x" title=":)" width="20">
my $res = Net::DNS::Resolver->new;
my $lookupip = $host;
$lookupip =~
s/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/$4.$3.$2.$1/;
for my $bl (@bls) {
$socket{$bl} = $res->bgsend("$lookupip.$bl", 'A');
}
# watch for results to come in up to $TIMEOUT-2 seconds
my $start_time = time;
while (keys(%socket) and time - $start_time < ($TIMEOUT-2)) {
for my $bl (keys(%socket)) {
if ($res->bgisready($socket{$bl})) {
my $packet = $res->bgread($socket{$bl});
delete $socket{$bl};
for my $rr ($packet->answer) {
if ($rr->type eq "A" && $rr->address) {
$listed{$bl}++;
}
}
}
}
if (keys(%socket)) {
sleep(1);
}
}
if (keys(%listed) == 0) {
$state = 'OK'
}
elsif (scalar(keys(%listed)) < $critcount) {
$state = 'WARNING'
}
else {
$state = 'CRITICAL'
}