You're an SRE at esc bash. Every morning someone opens the web server's access log and reads it by hand to see who is hitting the service and what is breaking. That does not scale. Write a small, reusable script that turns the log into a short summary report.
Run this first. It prepares the machine for the task:
curl -fsSL https://raw.githubusercontent.com/Esc-Bash/project-init-scripts/main/shell-scripting/project-1/init.sh | bash
This creates /root/mission/access.log. Every line has four
space-separated fields: client IP, HTTP method, request path, and
response status code. For example:
10.0.0.5 GET /api/users 200
Write /root/scripts/logreport.sh that takes two arguments: the path
of the log to read, and the path of the report to write.
logreport.sh <input-log> <output-report>
Start the script with set -euo pipefail. Then:
2.1.total requests: followed by the number of log lines.top IP: followed by the busiest client IP and its count, like
top IP: 10.0.0.5 (8).error responses: followed by how many requests had a status
code of 400 or higher.<path>: <count>, for every path in
the log.Run your script against the sample log, writing the report to
/root/answers/report.txt:
logreport.sh /root/mission/access.log /root/answers/report.txt
When the checks pass, press Submit.
Start the lab on the right to run checks.