Lab · DevOps: Git, Docker, Kubernetes and CI/CD
Lab: a health check for a clinic booking server
The brief
A small clinic in Nashik takes appointment bookings on a Linux server. You find the failing requests in its web log with text tools, write a bash health-check script, run it against a local web service, schedule it with cron, and prove it reports a failure when the service stops.
Why it matters
Reading logs with grep, awk, sort and uniq, and writing small bash checks that run from cron, is daily work for support engineers, Linux admins and DevOps engineers. Before a company has Prometheus, a script like this is often the only thing that tells someone the site is down.
Skills you practise
- awk, sort, uniq -c and wc
- bash variables, $( ) and if
- curl -w and df
- chmod and file modes
- background processes and ss
- crontab
You need
- A Linux machine with bash: Ubuntu 22.04 or 24.04, WSL2 on Windows, or a RHEL 9 family VM
- curl and python3 installed (both are there by default on Ubuntu and RHEL 9)
What you will have at the end
health.sh (a tested bash health check with a proper exit code), the cron line that runs it, and the one-line log query you used to find the failing booking requests.
How it is marked (rubric, 100 points)
| Checks passAll five outputs pass: log counts, mode 750, OK when up, the cron line, FAIL with exit 1 when down. | 45 |
|---|---|
| Script qualityQuoted variables, a clear OK/FAIL line, exit 1 on failure, and a usage comment at the top. | 25 |
| Safe habitsFull paths in cron, both streams logged, no world-writable files, and the test server stopped afterwards. | 15 |
| ExplainedYou can explain each part of the awk | sort | uniq -c | sort -rn chain and why the script needs an exit code. | 15 |
0/5 steps done
Step 1 of 5
Find the failing requests in the log
You count the 500 errors in access.log and list the three busiest client IPs, most requests first.
Make the folders with mkdir -p ~/clinic/{logs,scripts} and save access.log (from the file tab) as ~/clinic/logs/access.log. In this log format the 9th space-separated field is the HTTP status, so awk '$9 == 500' picks the failed requests and wc -l counts them.
To find the busiest clients, print field 1 (the IP), sort the list, count repeats with uniq -c, then sort the counts as numbers, biggest first. uniq only merges lines that are next to each other, so the first sort is not optional.
$ mkdir -p ~/clinic/{logs,scripts}
$ nano ~/clinic/logs/access.log # paste the 12 lines, save with Ctrl+O, exit with Ctrl+X
$ wc -l ~/clinic/logs/access.log
12 /home/student/clinic/logs/access.log$ awk '$9 == 500' ~/clinic/logs/access.log | wc -l; awk '{print $1}' ~/clinic/logs/access.log | sort | uniq -c | sort -rn | head -3Also check yourself
Your notes: health.sh
Write down each command you ran. It goes into your project summary.