Linux Labs

Networking / Stage 6 of 14

From connection to application response

Not running Starting usually ~20 s
Leave the lesson

Step 6 of 7 · on a machine · 4 min

A check for monitoring

Monitoring runs a script and looks only at its exit code. Make sure the script does not lie.

Every minute monitoring runs /opt/ports-lab/check.sh on the client with a page address. Code 0 means the service is healthy; anything else raises an alarm. Right now the script reports "healthy" when the service answers with an error, and hangs on a service that accepted the connection and stays silent.

Exercise · do it

A script that does not lie

Fix /opt/ports-lab/check.sh: code 0 only when the page answered without an HTTP error; an error answer and more than 3 seconds of silence give another code. Monitoring runs it like this: sudo ip netns exec lab-client sh /opt/ports-lab/check.sh ADDRESS. Test it on http://192.0.2.10:8080/health, http://192.0.2.10:8080/broken and http://192.0.2.10:8082/, where a service accepts the connection and stays silent.

Sign in and start The machine is available after signing in

Goals · 0 of 2

  • Tell a working answer from an HTTP error not done yet
  • Wait no longer than 3 seconds for a silent service not done yet

Step goals

0 of 2
  • Tell a working answer from an HTTP error — not done yet
  • Wait no longer than 3 seconds for a silent service — not done yet
Ubuntu 24.04

Step goals

0 of 2
  • Tell a working answer from an HTTP error — not done yet
  • Wait no longer than 3 seconds for a silent service — not done yet
Loading…