A comprehensive Python-based network diagnosis and troubleshooting tool that helps identify and analyze network connectivity issues, latency problems, DNS resolution failures, and packet loss.
- Network Connectivity Probes: TCP/UDP connectivity testing, ping, traceroute
- DNS Analysis: DNS resolution testing, lookup times, record validation
- Performance Metrics: Latency measurement, packet loss detection, throughput testing
- Automated Analysis: Intelligent issue detection with configurable thresholds
- Rich Reporting: Detailed reports with visualizations and recommendations
- Async Operations: High-performance concurrent network testing
- CLI Interface: Easy-to-use command-line interface with rich output
- Docker Support: Containerized deployment and testing
git clone https://github.com/yourusername/netdiag.git
cd netdiag
pip install -r requirements.txtdocker-compose up --buildpython -m src.netdiag.cli ping google.compython -m src.netdiag.cli diagnose --target google.com --config config.yamlpython -m src.netdiag.cli dns-test --domain example.com --record-type Apython -m src.netdiag.cli diagnose --target 8.8.8.8 --timeout 5 --retries 3# Test basic connectivity to a host
python -m src.netdiag.cli ping 8.8.8.8# Test specific port connectivity
python -m src.netdiag.cli port-test --host google.com --port 443# Comprehensive DNS testing
python -m src.netdiag.cli dns-test --domain github.com --nameserver 8.8.8.8# Traceroute with analysis
python -m src.netdiag.cli traceroute --target cloudflare.com --max-hops 30# Test multiple targets from file
python -m src.netdiag.cli bulk-test --targets-file hosts.txt --output report.json# Continuous monitoring with thresholds
python -m src.netdiag.cli monitor --target 1.1.1.1 --interval 30 --duration 300Create a config.yaml file to customize thresholds and behavior:
# See config.yaml for full configuration options
thresholds:
latency_warning: 100 # ms
latency_critical: 500 # ms
packet_loss_warning: 5 # %
packet_loss_critical: 15 # %import asyncio
from src.netdiag.engine import DiagnosisEngine
from src.netdiag.probes import PingProbe, DNSProbe
async def main():
engine = DiagnosisEngine()
# Run ping test
ping_result = await engine.run_probe(PingProbe("8.8.8.8"))
# Run DNS test
dns_result = await engine.run_probe(DNSProbe("google.com"))
# Generate report
report = engine.generate_report([ping_result, dns_result])
print(report.to_json())
asyncio.run(main())python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtpytest tests/docker-compose up --build netdiag- Python 3.10+
- See
requirements.txtfor dependencies
MIT License - see LICENSE file for details.
See CONTRIBUTING.md for guidelines on contributing to this project.
For issues and feature requests, please use the GitHub issue tracker.