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.
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.
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