How to Instantly Monitor Socket Health with the Lightweight 'dish' CLI Tool
This article introduces the lightweight command‑line tool dish, explains its core features such as one‑time socket health checks, remote configuration, concurrent testing, zero dependencies, multiple notification methods, caching, and provides installation steps, usage examples, and a comprehensive flag reference for efficient operations monitoring.
What is dish?
dish is a lightweight command‑line monitoring service that checks socket (HTTP/TCP) connections, detecting successful establishment, abnormal disconnections, or dead states.
Key Features
Lightweight one‑time monitoring: Simple tool focused on one‑off health checks of HTTP and TCP sockets.
Remote configuration: Load socket lists from a local JSON file or a remote RESTful JSON API.
Fast concurrent testing: Supports concurrent checks with a default timeout of 10 seconds per socket.
Zero dependencies: No external libraries required.
Multiple notification methods:
Upload results to a remote JSON API
Send messages via Telegram
Push to Prometheus Pushgateway
Webhook URL
Cache mechanism: When fetching socket lists from a remote API, dish can cache them locally to avoid repeated requests and continue operating if the API becomes unavailable.
Typical Use Cases
Lightweight health checks: Verify HTTP/TCP socket health.
Distributed monitoring: Deploy independent dish instances on multiple hosts, fetching configuration from a common API for decentralized monitoring.
Periodic checks: Run via cron for scheduled one‑off checks without a long‑running agent.
Installation & Usage
Install with
go install go.vxn.dev/dish/cmd/dish@latestor via Homebrew.
Provide a socket list via a local JSON file or a remote JSON API endpoint, and configure notifications and options with flags.
Examples
Local JSON file:
<code>dish /opt/dish/sockets.json</code>Remote JSON API:
<code>dish http://restapi.example.com/dish/sockets/:instance</code>Notification Configuration
Telegram:
<code>dish -telegramChatID "-123456789" -telegramBotToken "123:AAAbcD_ef" sockets.json</code>Pushgateway:
<code>dish -target https://pushgw.example.com/ https://api.example.com/dish/sockets</code>Flags
<code>-cache bool specifies whether to cache the socket list fetched from the remote API source
-cacheDir string directory used to cache the socket list (default ".cache")
-cacheTTL uint cache TTL in minutes (default 10)
-hname string custom header name for remote API authentication
-hvalue string custom header value for remote API authentication
-machineNotifySuccess bool specifies whether successful checks with no failures should be reported to machine channels
-name string dish instance name (default "generic-dish")
-target string result update path/URL to pushgateway, plaintext/byte output
-telegramBotToken string Telegram bot private token
-telegramChatID string Telegram chat/channel ID
-textNotifySuccess bool whether successful checks should be reported to text channels
-timeout uint timeout in seconds for http and tcp calls (default 10)
-updateURL string API endpoint URL for pushing results
-verbose bool console stdout logging toggle
-webhookURL string URL of webhook endpoint</code>Conclusion
dish is a simple, efficient, and flexible monitoring tool suitable for quickly checking socket health, especially in distributed environments and automated monitoring tasks.
Efficient Ops
This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.