Last active
August 29, 2015 14:05
-
-
Save joelabair/8ca3a74229709d1847d2 to your computer and use it in GitHub Desktop.
HTTP log file Summary Reporting (awk)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
BEGIN { | |
start = strftime("%s"); | |
print ""; | |
print "HTTP Requests Report"; | |
printf "start - %s\n", strftime("%a, %d %b %Y %I:%M:%S %p %Z"); | |
} | |
{ | |
match($10, /http:\/\/([^\/]+)/, arr); | |
hn = arr[1]; | |
if (hn) { | |
data[hn][$8]++; | |
} | |
} | |
END { | |
OFS="\t"; | |
for(h in data) { | |
print ""; | |
print "----------------------------"; | |
print h; | |
print ""; | |
print " ", "status", "count"; | |
print " ", "----", "---------"; | |
for(s in data[h]) { | |
printf "\t%s\t%'d\n", s, data[h][s]; | |
totals[s] += data[h][s]; | |
sumtotal += data[h][s]; | |
} | |
print ""; | |
} | |
printf "\n\n"; | |
print "-----------------------------------------"; | |
printf "|\tTotal Requests: %'d\t\t|\n", sumtotal; | |
print "-----------------------------------------"; | |
print ""; | |
print " ", "status", "count"; | |
print " ", "----", "---------"; | |
for(s in totals) { | |
printf "\t%s\t%'d\n", s, totals[s]; | |
} | |
print ""; | |
end = strftime("%s"); | |
printf "end - %s\n", strftime("%a, %d %b %Y %I:%M:%S %p %Z"); | |
printf "processing time: %'d seconds\n\n", (end - start); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment