der Anfang Regex um Daten zu extrahieren
This commit is contained in:
26
ban2mysql.pl
Normal file
26
ban2mysql.pl
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use DBI;
|
||||
|
||||
use Data::Printer;
|
||||
use File::Slurp;
|
||||
|
||||
# Connect to the database.
|
||||
my $dbh = DBI->connect("DBI:MariaDB:database=kram;host=edna",
|
||||
"steffen", "66WXRlvF0UUV",
|
||||
{'RaiseError' => 1});
|
||||
|
||||
my @file = read_file('sys.log');
|
||||
|
||||
for my $l ( @file ) {
|
||||
my ( $month, $day, $h, $m, $s, $kat, $src, $dst, $port ) = $l =~ /(.*?) (.*?) (..):(..):(..) 192.*banIP\/...-wan\/drop\/(.*?):.*SRC=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) DST=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*DPT=(\d+)/;
|
||||
if ( $month ) {
|
||||
p $month;
|
||||
p $src;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# $dbh->selectall_arrayref($statement);
|
||||
Reference in New Issue
Block a user