Yesterday, checkout failed at lunch. Ana has to tell the owners what happened, and wants the same report after every bad day. The web server's log for the day is ~/logs/access.log, about 1,500 lines, in the same format as in "Errors and Totals".
Write ~/incident.sh LOG and make it runnable. It writes report.txt, in the directory you run it from, with two sections:
== Top clients ==
31 192.0.2.10
…
== 5xx per hour ==
3 09
…| Section | Lines |
|---|---|
== Top clients == | The 5 client IPs with the most requests: count, IP, most first |
== 5xx per hour == | Each hour with a status of 500 or more: count, hour, earliest first |
The headers are exactly as above. The numbers here are only examples.
You have 15 minutes. The clock starts when you start the challenge. If the time runs out, you can still finish.
The tests also run your script on a log it never saw, so make it work for any log.
Objectives
- Run
./incident.sh ~/logs/access.logfrom your home directory.report.txthas the top 5 clients. - It has the 5xx errors per hour.
- It writes the right report for a log it never saw.