dru145 has asked for the wisdom of the Perl Monks concerning the following question:
And here is the code I have written so far:1;30Nov2001;17:08:25;192.168.1.2;log;accept;;hme0;outbound;udp;192.168 +.86.6;20.248.36.99;domain-udp;1103;63;85;;;;;;;;;;;;;;; 2;30Nov2001;17:08:25;192.168.1.2;log;drop;;hme0;inbound;tcp;63.28.96.2 +54;192.168.11.67;netbios-ssn;18803;48;89;;;;;;;;;;;;;;; 3;30Nov2001;17:08:26;192.168.1.2;log;drop;;hme0;inbound;tcp;65.93.20.2 +23;192.168.26.139;auth;1323;60;89;;;;;;;;;;;;;;; 4;30Nov2001;17:08:26;192.168.1.2;log;drop;;hme0;inbound;tcp;65.93.22.2 +23;192.168.26.139;auth;1323;60;89;;;;;;;;;;;;;;; 5;30Nov2001;17:08:26;192.168.1.2;log;accept;;qfe2;inbound;tcp;192.168. +86.146;20.248.36.97;http;4719;44;85;;;;;;;;;;;;;;; 6;30Nov2001;17:08:26;192.168.1.2;log;accept;;hme0;outbound;tcp;192.168 +.86.146;204.48.36.97;http;4719;44;85;;;;;;;;;;;;;;; 7;30Nov2001;17:08:26;192.168.1.2;log;accept;;qfe2;inbound;tcp;192.168. +86.146;204.48.36.97;http;4721;44;85;;;;;;;;;;;;;;; 8;30Nov2001;17:08:26;192.168.1.2;log;accept;;hme0;outbound;tcp;192.168 +.86.146;24.248.36.97;http;4721;44;85;;;;;;;;;;;;;;; 8;30Nov2001;17:08:26;192.168.1.2;log;accept;;hme0;outbound;tcp;192.168 +.86.146;20.248.36.97;http;4721;44;85;;;;;;;;;;;;;;; 9;30Nov2001;17:08:26;192.168.1.2;log;accept;;qfe2;inbound;tcp;192.168. +27.154;205.18.145.185;http;4396;44;85;;;;;;;;;;;;;;; 10;30Nov2001;17:08:26;192.168.1.2;log;accept;;hme0;outbound;tcp;192.16 +8.27.154;25.188.145.185;http;4396;44;85;;;;;;;;;;;;;;; 11;30Nov2001;17:08:26;192.168.1.2;log;accept;;qfe2;inbound;tcp;192.168 +.27.154;205.88.145.185;http;4397;44;85;;;;;;;;;;;;;;; 12;30Nov2001;17:08:26;192.168.1.2;log;accept;;hme0;outbound;tcp;192.16 +8.27.154;205.188.45.185;http;4397;44;85;;;;;;;;;;;;;;;
This seems to work fine, but what I need to do now is compare the @dst and @service arrays and if the @dst array has the same ip AND the @service array has the same service for at least 50 log entries, then I want to execute a sub, but I can't think of how to do this.#!/usr/bin/perl -w use strict; my $log = './log'; my @data; # Open the firewall log file and create new array containing all of th +e data. open (LOG, $log) or die "Can't open $log: $!"; while (<LOG>){ push (@data, "$_"); } # Split the @data array into separate arrays by category. my (@dst, @service); foreach (@data) { my @lines=split "\n",$_; foreach(@lines){ my ($num,$date,$time,$fw,$type,$action,$alert,$int,$dir,$proto,$sr +c,$dst,$service,$sport,$len,$rule) = (split /;/,$_); push(@dst, $dst); push(@service, $service); } }
Edit kudra, 2001-12-22 Appended to title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Another Array Problem.
by TomK32 (Monk) on Dec 19, 2001 at 01:57 UTC | |
|
(Ovid) Re: Another Array Problem.
by Ovid (Cardinal) on Dec 19, 2001 at 02:01 UTC | |
|
Re: Another Array Problem.
by aijin (Monk) on Dec 19, 2001 at 02:03 UTC | |
by dru145 (Friar) on Dec 19, 2001 at 20:23 UTC | |
by Juerd (Abbot) on Dec 19, 2001 at 20:49 UTC |