Simple shell script to add "pong" feature to services not having it, such as SMTP.
It is intended to monitor the availability of a given service on the provided port. It listens for connections on its own port (6666), while monitoring a given socket to the provided service port (25). If the monitored service becomes unresponsive the script exits, thus making the endpoint it provides unreachable.
The tipical use case is to act as an heath check endpoint for a SMTP cluster behind a Load Balancer, it has been used this way for long time in production environment on AWS.
The default is to check an SMTP server on port 25 of the localhost. If needed set different ports by simply exporting the variables with the required values.
- netcat (
nc
) - socket statistics (
ss
)
Both should be already be installed on the majority of Linux distributions.
- it spans a
nc
process, in listening and keep-alive mode, on a configurable port (defaults6666
) - it loops forever and checks for a live socket on the given port/protocol
- you (your Load Balancer) can ping it to check the monitored service health
- since the main loop is executed with
set -e -o pipefail
bash options it will exit if the socket is not found - your LB will receive no more pongs :)
nohup sidecar-echo-responder.sh > /dev/null &
Enjoy