jrhmpt01:/tmp# cat sum.pl
open (LOG ,"<","tmp.out");
while (<LOG>) {
chomp;
##10.171.246.184 - - [05/Feb/2016:20:32:50 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 180.120.21.62
#10.171.246.184 - - [05/Feb/2016:20:46:24 +0800] "GET /web/noauth?method=%2Fnotice%2Fpage&type=1&pageNum=1&pageSize=5&_=1454676377831 HTTP/1.1" 200 1134 0.032 122.234.182.28
if ($_ =~ /.*s+"(POST|GET)s*(.*?)s*HTTP.*?(d{1,3}.d{1,3}.d{1,3}.d{1,3})$/){
print "$1 is $1
";
$url=$2;
print "$url is $url
";
$ip=$3;
print "$ip is $ip
";
$var=$url.$ip;
$hash{$var}++;
}}
while(my($ip, $times) = each %hash) {
print "$ip access count(*) == $times
";
};
jrhmpt01:/tmp# cp tmp.out tmp.out.bak
jrhmpt01:/tmp# vim tmp.out
jrhmpt01:/tmp# perl sum.pl
$1 is POST
$url is /web/sendregistersmscode
$ip is 117.149.104.182
$1 is GET
$url is /web/sendregistersmscode
$ip is 117.149.104.182
$1 is POST
$url is /web/sendregistersmscode
$ip is 117.149.104.182
$1 is POST
$url is /web/sendregistersmscode
$ip is 117.149.104.182
$1 is POST
$url is /web/sendregistersmscode
$ip is 117.149.104.182
$1 is POST
$url is /web/sendregistersmscode
$ip is 117.149.104.182
$1 is POST
$url is /web/sendregistersmscode
$ip is 117.149.104.182
$1 is POST
$url is /web/sendregistersmscode
$ip is 117.149.104.182
$1 is POST
$url is /web/sendregistersmscode
$ip is 117.149.104.182
$1 is POST
$url is /web/sendregistersmscode
$ip is 117.149.104.182
/web/sendregistersmscode117.149.104.182 access count(*) == 10
jrhmpt01:/tmp# cat tmp.out
10.252.142.174 - - [06/Feb/2016:08:05:13 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.000 117.149.104.182
10.252.142.174 - - [06/Feb/2016:08:05:13 +0800] "GET /web/sendregistersmscode HTTP/1.1" 200 49 0.000 117.149.104.182
10.171.246.184 - - [06/Feb/2016:08:05:19 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.252.142.174 - - [06/Feb/2016:08:05:23 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.171.246.184 - - [06/Feb/2016:08:05:24 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.252.142.174 - - [06/Feb/2016:08:05:29 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.252.142.174 - - [06/Feb/2016:08:05:34 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.171.246.184 - - [06/Feb/2016:08:05:35 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.171.246.184 - - [06/Feb/2016:08:05:37 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.002 117.149.104.182
10.171.246.184 - - [06/Feb/2016:08:05:51 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
jrhmpt01:/tmp# grep 117.149.104.182 tmp.out
10.252.142.174 - - [06/Feb/2016:08:05:13 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.000 117.149.104.182
10.252.142.174 - - [06/Feb/2016:08:05:13 +0800] "GET /web/sendregistersmscode HTTP/1.1" 200 49 0.000 117.149.104.182
10.171.246.184 - - [06/Feb/2016:08:05:19 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.252.142.174 - - [06/Feb/2016:08:05:23 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.171.246.184 - - [06/Feb/2016:08:05:24 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.252.142.174 - - [06/Feb/2016:08:05:29 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.252.142.174 - - [06/Feb/2016:08:05:34 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.171.246.184 - - [06/Feb/2016:08:05:35 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182
10.171.246.184 - - [06/Feb/2016:08:05:37 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.002 117.149.104.182
10.171.246.184 - - [06/Feb/2016:08:05:51 +0800] "POST /web/sendregistersmscode HTTP/1.1" 200 49 0.001 117.149.104.182