MostlyChris

Thoughts that are my own.

Apache Server Hits

Use this little one liner to grab the number of hits from the apache access logs.

DATE=`date +%d.%b.%Y`':';for i in `lsof -p $(ps faxwwwu|awk '$1 ~ /^root$/ && $11 ~ /httpd$/ {print $2|"head -1"}' )| awk '$9 ~ /access_log$/ {print $9| "sort -u"}'`; do echo "-------"$i"------"$DATE;awk '$4 ~ /^.'$DATE'/ {hit[substr($4,2,2)"\t"substr($4,14,2)"."substr($4,17,1)]++;ip[$1]++} END { for (i in hit) { print hit[i]"\t"i|"sort -k 3 -g"}; print ""}' $i;done

You can also grab a sorted list of IP addresses accessing sites by doing using this one liner.

DATE=`date +%d.%b.%Y`;for i in `lsof -p $(ps faxwwwu|awk '$1 ~ /^root$/ && $11 ~ /httpd$/ {print $2|"head -1"}' )| awk '$9 ~ /access_log$/ {print $9| "sort -u"}'`; do echo "-------"$i"------"$DATE;awk '$4 ~ /^.'$DATE'/ {hit[substr($4,2,2)"\t"substr($4,14,2)"."substr($4,17,1)]++;ip[$1]++} END { for (i in hit) { print hit[i]"\t"i|"sort -k 3 -n"}; print "";  for (i in ip) {print ip[i]"\t"i|"sort -n"}}' $i;done

Comments