Skip to content

Commit

Permalink
Added batch processing of a log file in pdns2db
Browse files Browse the repository at this point in the history
  • Loading branch information
gamelinux committed Jan 4, 2012
1 parent 57eb053 commit ea66595
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/INSTALL
Expand Up @@ -15,6 +15,7 @@ Ubuntu

RedHat (RHEL 6u2 x86_64)
$ yum groupinstall "Development tools"
# EPEL : http://fedora.uib.no/epel/6/x86_64/
$ rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/x86_64/ldns-devel-1.6.11-2.el6.x86_64.rpm
$ rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/x86_64/ldns-1.6.11-2.el6.x86_64.rpm
$ wget http://www.tcpdump.org/release/libpcap-1.2.1.tar.gz
Expand Down
9 changes: 8 additions & 1 deletion tools/pdns2db.pl
Expand Up @@ -32,7 +32,7 @@ =head1 NAME
=head1 VERSION
0.1
0.2
=head1 SYNOPSIS
Expand All @@ -41,6 +41,7 @@ =head1 SYNOPSIS
OPTIONS:
--file : set the file to monitor for passivedns entries
--batch : process a file and exit when done
--daemon : enables daemon mode
--debug : enable debug messages (default: 0 (disabled))
--help : this help message
Expand All @@ -63,9 +64,11 @@ =head1 SYNOPSIS
our $DBI = "DBI:mysql:$DB_NAME:$DB_HOST:$DB_PORT";
our $TABLE_NAME = "pdns";
our $AUTOCOMMIT = 0;
our $BATCH = 0;

GetOptions(
'file=s' => \$PDNSFILE,
'batch' => \$BATCH,
'debug=s' => \$DEBUG,
'daemon' => \$DAEMON,
);
Expand Down Expand Up @@ -157,6 +160,10 @@ sub file_watch {
parseLogfile ($logfile, $pos, $startsize);
$pos = $startsize;

if ($BATCH == 1) {
print "[*] Processing of $logfile is done, exiting!\n";
exit 0;
}
sleep $TIMEOUT;
}
}
Expand Down

0 comments on commit ea66595

Please sign in to comment.