Skip to content

vavdoshka/pingament

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pingament

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.

img

Features

  • 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

Installation

# 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>

Usage

Basic Examples

# 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

Options

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

Output Format

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)
  ...

Use Cases

CDN Monitoring

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 10

DNS Round-Robin Testing

Test 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 http

Network Performance Analysis

Track latency variations across different edge nodes and identify performance issues:

# Quick interval for detailed analysis
pingament --hostname cdn.example.com --interval 2 --timeout 1

How It Works

  1. DNS Resolution: Queries DNS for the hostname every interval
  2. IP Registry: Maintains a list of all unique IPs ever discovered
  3. Latency Checks: Pings/checks ALL registered IPs (not just current batch)
  4. Statistics: Updates per-IP metrics (check count, average latency)
  5. 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.

Technical Details

  • 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)

Requirements

  • Go 1.24.0 or higher
  • For ICMP ping: May require elevated privileges (root/admin) on some systems
    • Alternative: Uses system ping command as fallback

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages