Skip to content

Simple shell script to add "pong" feature to services such as SMTP

License

Notifications You must be signed in to change notification settings

faktiva/sidecar-echo-responder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

sidecar-echo-responder

Simple shell script to add "pong" feature to services not having it, such as SMTP.

Description

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.

Requirements

  • netcat (nc)
  • socket statistics (ss)

Both should be already be installed on the majority of Linux distributions.

How it works

  • it spans a nc process, in listening and keep-alive mode, on a configurable port (defaults 6666)
  • 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 :)

Execution

nohup sidecar-echo-responder.sh > /dev/null &

Enjoy

Releases

No releases published

Packages

No packages published

Languages