Skip to content

mthorning/network-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

network_monitor/README.md

Network Monitor

Network Monitor is a Go-based tool for monitoring network connectivity and latency to a configurable list of IP addresses. It periodically pings each IP and exposes detailed metrics about response times via a Prometheus-compatible /metrics endpoint.

Features

  • IP Address Monitoring: Periodically pings a list of IP addresses.
  • Prometheus Metrics: Exposes ping duration metrics for scraping.
  • Configurable Logging: Structured logs with adjustable log levels.
  • Docker Support: Includes a Dockerfile for containerized deployment.

How It Works

  • Reads a comma-separated list of IPs to monitor.
  • Pings each IP using ICMP at a configurable interval.
  • Records response times in a Prometheus histogram.
  • Runs an HTTP server exposing /metrics for Prometheus scraping.

Getting Started

Prerequisites

  • Go 1.20+
  • (Optional) Docker

Build & Run

go build -o network_monitor ./cmd/network_monitor.go
./network_monitor

Or with Docker:

docker build -t network_monitor .
docker run -p 8080:8080 network_monitor

Configuration

Configuration options are currently set in internal/config/config.go:

  • PingIps: Comma-separated IPs to ping (default: 192.168.68.1, 192.168.1.1, 1.1.1.1, 8.8.8.8, 198.41.0.4)
  • PingInterval: Ping interval in seconds (default: not set, add as needed)
  • LogLevel: Logging level (default: Info)
  • ServerPort: HTTP server port (default: 8080)

Metrics

Prometheus scrapes metrics from /metrics. Example metric:

  • ping_request_duration_seconds{ip="1.1.1.1"}

Check in Prometheus

Use this query in Prometheus:

histogram_quantile(0.99, sum by(le, ip) (rate(ping_request_duration_seconds_bucket{}[5m]))) * 1000

Or view here if you're me.

About

Generates metrics about network for Prometheus

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors