A structured lesson workspace with readable content, hands-on examples, and a clean path to completion.
Monitoring is a timing problem disguised as a command problem. A one-time `systemctl is-active` result is only a snapshot. Processes restart, ports appear after startup delays, and a service can be active while an application dependency is failing. Bash can provide a useful guardrail, but the script needs an explicit definition of what “healthy” means.
Keep checks small: service state, expected process presence, listening port, and a lightweight application probe are four different signals. When possible, collect them independently so a failure message can say which layer broke. This also makes the script easier to adapt when a service changes architecture.
Checks service state quietly and exposes the exit status for later logic. The useful habit here is to treat the command output as evidence about one system fact, not as a magical diagnosis.
For repeated polling, add a delay and a bounded timeout. An infinite loop is fine for a foreground diagnostic shell, but poor for a cron job or automated pipeline. A monitor should terminate predictably and return a useful exit status so another system can decide what to do next.
Checks whether TCP port 22 is listening on the local host. Read the result in context: the same command can be correct yet insufficient if a permission boundary, alternate configuration, or different backend changes what it reports.
Implements a bounded retry loop instead of an unbounded poll. In a production workflow, save the raw result when the observation contributes to a finding. That keeps later analysis honest and makes troubleshooting reproducible.
A practitioner’s checkpoint: compare the observed behavior with the assumption your script is about to make. If the assumption is broader than the evidence, narrow the rule. If the evidence is incomplete, report the uncertainty instead of converting it into a confident finding.
Lab discipline: stay inside the declared course environment, prefer read-only checks for learning exercises, and preserve the original output of security tools before transforming it.
Finish the lesson once you have worked through the material. This awards ★ 35 XP.