Skip to content

Instantly share code, notes, and snippets.

@eqhmcow
Created November 27, 2012 15:22
Show Gist options
  • Save eqhmcow/4154770 to your computer and use it in GitHub Desktop.
Save eqhmcow/4154770 to your computer and use it in GitHub Desktop.
parse combined access logs for IPs that are making requests that timeout
ls /usr/local/arcos/logs/proxy_access_log.* -t1 | head -1 | (read i; cat $i | egrep '" 40[08] ') | grep -v ' 10\.0\.30\.2 ' | perl -p -e '($vhost, $ip, $date, $method, $url, $protocol, $alt_url, $code, $bytes, $referrer, $ua) = (m/^(\S+)\s(\S+)\s\S+\s+(?:\S+\s+)+\[([^]]+)\]\s"(\S*)\s?(?:((?:[^"]*(?:\\")?)*)\s([^"]*)"\s|((?:[^"]*(?:\\")?)*)"\s)(\S+)\s(\S+)\s"((?:[^"]*(?:\\")?)*)"\s"(.*)"$/x); die "Could not match $_" unless $ip; $alt_url ||= ""; $url ||= $alt_url; $_="$ip $vhost\n"' | sort | uniq -c | sort -n
@triangletodd
Copy link

more hard returns!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment