Saturday 15 May 2010

Apache server log highest traffic using bash -


I have an Apache server log and trying to determine which IP address has generated more traffic I have already been able to format it so that its IPS and byte traffic can be made:

  xxx.xxx.xxx.xxx 915925 yyy.yyy.yyy.yyy 1193 zzz.zzz Zzz.zzz 2356   

So now I'm looking for a method to add and add the bytes of the same IP and then only the top Find the value.

Any idea

If you have IP and traffic bytes in the file, So use the following to complete the work.

  1. cat file | Pearl- '$ H {$ F [0]} + = $ F [1]; END {sort keys for% h} {printf qq [% s% d \ n], $ _, $ h {$ _}}} | Sort-2-n-r

  2. awk '{A [$ 1] + = $ 2; Next} for END {{I in A} {print i, a [i]}} 'file | Sort -k2 -n -r

No comments:

Post a Comment