Files
2026-01-06 10:20:34 -08:00

138 lines
3.5 KiB
Markdown

# rtnetmon
Real-time network monitoring dashboard for Linux systems with dual-interface support.
## Overview
rtnetmon is a terminal-based network monitoring tool that provides real-time
visibility into network health, packet loss, and latency across two network
interfaces simultaneously. It's designed for Linux systems and uses ncurses
for a clean, real-time dashboard interface.
## Features
- **Dual Interface Monitoring**: Monitor two network interfaces simultaneously
- **Real-time Updates**: Live dashboard with sub-second updates
- **Comprehensive Metrics**:
- ICMP reachability tests
- Packet loss percentage
- TCP connection latency
- Interface health status
- **Visual Indicators**: Color-coded status, spinners, and meters for quick status assessment
- Packet loss meter uses reverse coloring (empty/green = good, full/red = bad)
- **Detailed Logging**: Optional logging to file for debugging and analysis
## Requirements
- Linux operating system
- Go 1.21 or later
- Root/sudo access (for raw ICMP packets)
- `ping` command available in PATH
## Installation
```bash
git clone https://git.eeqj.de/sneak/rtnetmon.git
cd rtnetmon
make build
```
## Usage
```bash
sudo ./rtnetmon --ifaceA eth0 --labelA "Primary WAN" --ifaceB wlan0 --labelB "Backup WiFi"
```
### Command Line Options
- `--ifaceA`: Primary network interface (default: "gu0")
- `--labelA`: Label for primary interface (default: "gu LAN - VPN outbound")
- `--ifaceB`: Secondary network interface (default: "backhaul0")
- `--labelB`: Label for secondary interface (default: "Cox cable direct")
- `--hosts`: Comma-separated list of hosts to monitor
- `--logfile`: Path to log file (default: "/tmp/rtnetmon.log")
### Keyboard Controls
- `q` or `Ctrl+C`: Quit the application
## Project Structure
```
rtnetmon/
├── cmd/rtnetmon/ # Main entry point
│ └── main.go
├── internal/
│ ├── cli/ # Command-line interface using Cobra
│ │ └── root.go
│ └── monitor/ # Core monitoring functionality
│ ├── monitor.go # Main monitoring types and functions
│ ├── loops.go # Monitoring loops (reachability, loss, TCP)
│ ├── styles.go # Terminal color styles
│ └── ui.go # User interface rendering
├── go.mod
├── go.sum
├── Makefile
└── README.md
```
## Development
### Building
```bash
make build # Build the binary
make test # Run tests
make lint # Run linter
make fmt # Format code
make all # Format, lint, test, and build
```
### Testing
The project includes unit tests for core functionality. Run tests with:
```bash
make test
```
### Using the Monitor API
The monitor package provides an object-oriented API for programmatic use:
```go
import "git.eeqj.de/sneak/rtnetmon/internal/monitor"
// Create a new monitor
mon := monitor.NewMonitor("eth0", "Primary", "wlan0", "Backup", "/tmp/monitor.log")
// Configure timing parameters (optional - defaults are sensible)
mon.ICMPTimeout = 1 * time.Second
mon.PacketLossPings = 10
mon.PacketLossPeriod = 10 * time.Second
// Add hosts to monitor
mon.AddReachabilityHost("8.8.8.8")
mon.AddReachabilityHost("google.com")
mon.AddPacketLossHost("github.com")
mon.AddPacketLossHost("8.8.8.8")
mon.AddTCPHost("google.com:443")
mon.AddTCPHost("github.com:443")
// Run the monitor
ctx := context.Background()
if err := mon.Run(ctx); err != nil {
log.Fatal(err)
}
```
## License
WTFPL - Do What The Fuck You Want To Public License
## Author
sneak@sneak.berlin