DEV Community

pretjeuh
pretjeuh

Posted on

ping-multiple.sh — a live terminal dashboard for monitoring multiple hosts

After a migration or a firewall swap, you need to verify that a dozen endpoints are reachable — on the right protocols. Is SSH still up? Did HTTP come back? Is that database port open? Firing ping or nc one host at a time is slow and you lose the overview the moment you move to the next check.

ping-multiple.sh is a single bash script that watches all of them at once, live, in your terminal.

What it looks like

Dashboard filling up after ~26 seconds

Each row shows:

Column Meaning
Status UP / SLOW / DOWN / ...
RTT Latest round-trip time (TO = timeout)
Host IP or hostname
Probe [ICMP], [SSH], [HTTP], etc.
Bar 60 most-recent results, newest on the right
Sparkline RTT trend ▁▂▃▄▅▆▇█ (ICMP only)

Green = up/fast. Yellow = slow (above your threshold). Red = down. Gray = waiting for first sample.

Features

  • ICMP and TCP probes per target — mix and match on the same dashboard
  • Dual probe cadence for ICMP: a fast 1-second probe drives the bar, a slower 5-second probe drives the RTT column
  • TCP connect latency for SSH, HTTP, HTTPS, RDP, or any port
  • State-change alerts — terminal bell + optional --log FILE for every UP↔DOWN transition
  • RTT sparkline per host using 8-level block characters
  • CSV export on exit — per-host samples, loss %, min/avg/max RTT
  • Interactive wizard (--guide) or CSV import (--csv targets.csv)

Quick start

# ICMP ping to two hosts
./ping-multiple.sh 8.8.8.8,1.1.1.1

# Interactive setup — choose probe type per host
./ping-multiple.sh --guide

# Load from a CSV file, log state changes
./ping-multiple.sh --csv targets.csv --log events.log
Enter fullscreen mode Exit fullscreen mode

CSV format:

ip,label,probe
8.8.8.8,Google DNS,icmp
10.0.0.1,Web server,tcp:80
10.0.0.2,Database,tcp:5432
mail.example.com,Mail server,tcp:25
Enter fullscreen mode Exit fullscreen mode

How it works

Every host gets its own set of background subshells. For ICMP targets there are two workers: a fast one (1s interval, 1s deadline) writing G/Y/R chars to a ring-buffer file, and a slow one (5s interval, 5s deadline) updating the RTT column. TCP targets get a single worker that connects with nc every 10 seconds and records connect latency.

The display loop reads all the ring buffers once per second, calculates BAR_WIDTH from the current terminal width, and redraws every row in place. TCP samples are each expanded to fill 10 display blocks so the bar fills at the same visual rate as ICMP — without that, a TCP bar would be 90% gray for the first minute and a half.

State changes (UP→DOWN, DOWN→UP, UP→SLOW) fire a terminal bell and optionally append a timestamped line to a log file.

Requirements

  • bash 4+ (macOS ships bash 3 — brew install bash)
  • ping, nc, awk, date, mktemp on PATH
  • GNU timeout / gtimeout on macOS (brew install coreutils) — prevents nc from hanging on unreachable targets

No external dependencies, no compiled components, no containers.

Get it

github.com/pretjeuh/ping-multiple

MIT licensed. Ctrl-C to quit; temp files and cursor state are cleaned up automatically.

Top comments (0)