A real-time DNS resolver and latency monitor for CDN-hosted endpoints. Continuously resolves hostnames, tracks all discovered IPs, and measures latency with live watch-style output.
- Continuous DNS Resolution: Repeatedly queries DNS to discover all A records
- IP Registry: Tracks all unique IPs discovered across queries (CDNs rotate IPs)
- Latency Monitoring: Checks all known IPs each cycle, not just current batch
- Dual Check Methods: ICMP ping or HTTP GET requests
- Watch-Style Output: Screen refreshes with real-time statistics
- Aggregate Statistics: Per-IP check count and average latency tracking
# Clone the repository
git clone https://github.com/vavdoshka/pingament.git
cd pingament
# Install dependencies
go get
# Build
go build -o pingament
# Or run directly
go run main.go --hostname <hostname># Monitor CDN endpoint with ping (default)
pingament --hostname api.service.com
# Or using go run
go run main.go --hostname api.service.com
# Monitor with HTTP GET requests
pingament --hostname api.example.com --check-type http
# Custom interval and timeout
pingament --hostname cdn.example.com --interval 10 --timeout 3
# HTTP with custom path
pingament --hostname api.example.com --check-type http --http-path /health| Flag | Type | Default | Description |
|---|---|---|---|
--hostname |
string | required | Hostname to monitor |
--check-type |
string | ping |
Check method: ping or http |
--interval |
int | 5 |
Seconds between DNS resolution cycles |
--timeout |
int | 2 |
Timeout for each latency check (seconds) |
--http-path |
string | / |
Path for HTTP GET requests |
The tool displays real-time results in a watch-style format:
[2025-10-01 22:16:31] Resolved 2 IPs
2.21.22.113 46.72ms (checks: 2, avg: 48.38ms)
2.21.22.122 45.15ms (checks: 2, avg: 47.71ms)
Each line shows:
- IP address
- Last measured latency
- Total number of checks performed
- Average latency across all checks
The screen refreshes every interval with updated statistics. New IPs are marked when first discovered:
[2025-10-01 22:16:36] Resolved 9 IPs (3 new)
23.192.45.50 1.40ms (checks: 1, avg: 1.40ms)
23.192.45.56 2.31ms (checks: 1, avg: 2.31ms)
...
CDN providers like Akamai, CloudFront, and Fastly return different IP addresses based on geographic location and load balancing. Pingament tracks all discovered IPs and their latency patterns:
pingament --hostname api.service.com --interval 10Test DNS load balancing and failover by monitoring which IPs are returned and their response times:
# Check API endpoint rotation
pingament --hostname api.service.com --check-type httpTrack latency variations across different edge nodes and identify performance issues:
# Quick interval for detailed analysis
pingament --hostname cdn.example.com --interval 2 --timeout 1- DNS Resolution: Queries DNS for the hostname every interval
- IP Registry: Maintains a list of all unique IPs ever discovered
- Latency Checks: Pings/checks ALL registered IPs (not just current batch)
- Statistics: Updates per-IP metrics (check count, average latency)
- Display: Clears screen and shows updated results
This approach reveals the full scope of CDN infrastructure and tracks performance across all edge nodes over time.
- Concurrency: Parallel latency checks for all IPs using goroutines
- Thread Safety: Mutex-protected statistics for accurate aggregation
- Ping Methods: Raw ICMP sockets (requires privileges) with fallback to system ping
- Screen Refresh: Platform-specific clear commands (Unix:
clear, Windows:cls)
- Go 1.24.0 or higher
- For ICMP ping: May require elevated privileges (root/admin) on some systems
- Alternative: Uses system
pingcommand as fallback
- Alternative: Uses system
MIT
