|
||
---|---|---|
README.md | ||
build.sh | ||
go.mod | ||
host_check.go |
README.md
Purpose
This Go binary performs basic network diagnostics on a set of hostnames, useful for checking connectivity to dependency containers.
Usage
-
Build:
./build.sh
-
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'
).
- HOSTNAMES: Comma-separated list of hostnames to check (e.g.,
-
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 theCOMMAND
functionality.
Let me know if you'd like any other adjustments to your README!