Home > OS >  For help! Awk to statistics the number of requests every 5 minutes (that is, the number of records e
For help! Awk to statistics the number of requests every 5 minutes (that is, the number of records e

Time:11-23

IP log format is a separator is a space - time xx xx xx url status code...

61.150.114.19 x - [09/Sep/2015:10:30:00 + 0800] "GET HTXP://wg43 HTTP/1.1" 206 4194767 "-" "MOBILE" 7194 21 x. 145.171.23 TCP_HIT NONE
219.1 x5.171.23 TCP_HIT NONE
60.161.186.12 x - [09/Sep/2015:10:30:00 + 0800] "GET HXTP://WGDCDN intid=HTTP/1.1 3859992-44" 200 20277911 "-" "-" 21122 219.1 x5.171.23 TCP_HIT NONE

Now need statistics on the number of records every five minutes, as the above two records, that is, when the 10:30 points have two such records, the log file is very big, write an instruction to statistics how many such records every five minutes (that is, the access requests)
Ps: I'm a train of thought is the number of minutes in every hour except at five, but also didn't want to know to write out
The segmentation method of time I wrote the split ($4, a,///:/) is a [4] hours, [5] is the number of minutes, a
Access number per minute statement: awk '{split ($4, a,///:/); B [[5]] + +} END {for (I) in b print I, b} [I] 'test6. TXT
Every five minutes I am really don't want to clear answer!

CodePudding user response:

Help ah,, someone

CodePudding user response:

Every minute, every five minutes is not very simple, in addition to the 5 minute field directly

CodePudding user response:

refer to the second floor ipqtjmqj response:
every minute, every five minutes is not a simple, direct, minute field in addition to the five



Seems not so simple, every hour to reset the time, the writing should be quite complicated T T

CodePudding user response:


Visits per minute
The cat aa | awk '{if ($2! ~/^ work/) {split ($2, a, ":"); STR=a [1] ":" a, [2]. B (STR) + +}} END {for (I) in b print I, b} [I] '

Every five minutes to access number
The cat aa | awk '{if ($2! ~/^ work/) {split ($2, a, ":"); A [2]=int ([2]/5 a) * 5; STR=a [1] ":" a, [2]. B (STR) + +}} END {for (I) in b print I, b} [I] '

CodePudding user response:

The cat aa | awk '{if ($2! ~/^ work/) {split ($2, a, ":"); A [2]=int ([2]/5 a) * 5; STR=a [1] ":" a, [2]. B (STR) + +}} END {for (I) in b print I, b} [I] '
  • Related