49 lines
1.7 KiB
Markdown
49 lines
1.7 KiB
Markdown
# Purpose
|
|
|
|
This Go binary performs basic network diagnostics on a set of hostnames, useful for checking connectivity to dependency containers.
|
|
|
|
## Usage
|
|
|
|
1. **Build:**
|
|
```bash
|
|
./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:**
|
|
```bash
|
|
./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:
|
|
|
|
```bash
|
|
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!
|
|
|