#!/usr/bin/perl -w # # rblstat # John Simpson 2007-02-08 # # counts queries and responses for various RBL zones. # # expects dnscache log lines as input. # ############################################################################### # # Copyright (C) 2007 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # or visit http://www.gnu.org/licenses/gpl.txt # ############################################################################### require 5.003 ; use strict ; ############################################################################### # # configuration my @rbls = qw ( zen.spamhaus.org dnsbl.njabl.org dnsbl.sorbs.net bl.spamcop.net nx.domain.xyz ) ; ############################################################################### # # globals my ( %count , $tq , $tn ) ; ############################################################################### ############################################################################### ############################################################################### # # let's do it while ( my $line = <> ) { my $zone = "" ; for my $r ( @rbls ) { if ( $line =~ /$r/ ) { $zone = $r ; last ; } } next unless ( $zone ) ; if ( $line =~ / query / ) { $count{"$zone:q"} ++ ; } elsif ( ( $line =~ / nxdomain / ) || ( $line =~ / nodata / ) ) { $count{"$zone:n"} ++ ; } } for my $z ( @rbls ) { $tq += ( $count{"$z:q"} || 0 ) ; $tn += ( $count{"$z:n"} || 0 ) ; } print <