Go to file
Colin 14c403ec22 Fixup 2024-04-18 10:36:57 -04:00
README.md host_check 2024-04-18 10:33:53 -04:00
build.sh Fixup 2024-04-18 10:36:57 -04:00
go.mod Fixup 2024-04-18 10:36:57 -04:00
host_check.go host_check 2024-04-18 10:33:53 -04:00

README.md

Purpose

This Go binary performs basic network diagnostics on a set of hostnames, useful for checking connectivity to dependency containers.

Usage

  1. Build:

    ./build.sh
    
  2. Set Environment Variables:

    • HOSTNAMES: Comma-separated list of hostnames to check (e.g., database,redis-server,api.example.com)
    • FAIL_ON_ERROR (optional): Set to "true" to exit the program immediately upon the first ping failure.
    • COMMAND (optional): Set to "entrypoint.sh" to execute an additional script on each host.
    • ERROR_COMMAND (optional): A command to execute if a ping failure occurs, useful for automated error reporting (e.g., go-glitch report-error <hostname> 'Ping failed').
  3. Run:

    ./host_check
    

Output

For each hostname:

  • DNS Resolution: Success or failure, with resolved IPs if successful.
  • Ping: Success or failure, with ping statistics if successful.
  • Custom Script: Output of the entrypoint.sh script, if executed.
  • Error Reporting: Output of the ERROR_COMMAND, if set and a ping failure occurs.

Example

To check connectivity to "db-container" and "webserver", execute an entrypoint.sh script, and report errors to go-glitch:

export HOSTNAMES="db-container,webserver"
export COMMAND="entrypoint.sh"
export ERROR_COMMAND="go-glitch report-error <hostname> 'Ping failed'"
./host_check 

Important:

  • Make sure you have a build.sh script in your project directory to handle the Go compilation process.
  • You'll need an entrypoint.sh script if you want to leverage the COMMAND functionality.

Let me know if you'd like any other adjustments to your README!