#!/usr/bin/perl # Script to take the stat output from rbldnsd and put it into a format # that mrtg can take. # Can take the url of the dnsbl as the argument # If no argument is given, it will give the total aggregate numbers use strict; #Put the location your RBLDNSD stats file next my $statfile = "/path/to/rbldnsd.stat"; # Get the list name my $list; if(!@ARGV[0]) { # Get the total stats $list="\*"; } else { # Get the stats for one dnsbl $list=@ARGV[0]; } open(STATS,"< $statfile") or die "Could not open $statfile for reading\n"; my $line=""; # Get the last line $line=$_ while ; chomp $line; close(STATS); if($line eq "") { die "\"$statfile\" seems to be empty\n"; } # Split up the line by space my @dnsbls=split(/ /,$line); foreach my $dnsbl (@dnsbls) { # Finding the details for the dnsbl my @dnsblDetails=split(/:/,$dnsbl); if(@dnsblDetails[0] eq $list) { print "@dnsblDetails[2]\n"; print "@dnsblDetails[1]\n"; exit(0); } } print STDERR "Unable to find stats for $list\n"; exit(1);