A network monitoring tool with ping tracking and dashboard visualization
Project description
Network Checker
A comprehensive network monitoring tool that performs periodic ping tests to monitor host availability and response times, with a web-based dashboard for visualization.
Features
<� Core Functionality
- Periodic Ping Monitoring: Automated ping tests at configurable intervals
- SQLite Database: Persistent storage of ping results with timestamps
- Web Dashboard: Interactive visualization using Plotly charts
- CLI Interface: Comprehensive command-line tools for management
- RESTful API: JSON endpoints for data access and integration
=� Dashboard Features
- Real-time response time charts
- Packet loss visualization
- Success rate statistics
- Multiple host monitoring
- Time range filtering (1 hour to 1 week)
- Auto-refresh every 30 seconds
=' Advanced Features
- Background scheduling with APScheduler
- Configurable ping timeouts and intervals
- Database indexing for performance
- Error handling and logging
- Development and production configurations
Quick Start
Installation
# Clone the repository
git clone https://github.com/mikawa-bushi/network-checker.git
cd network-checker
# Install dependencies with Poetry
poetry install
# Initialize the database
poetry run network-checker init
Basic Usage
# Test a single host
poetry run network-checker ping google.com --count 5
# Start continuous monitoring
poetry run network-checker start-monitoring google.com cloudflare.com --interval 30
# Launch web dashboard
poetry run network-checker run-server
# Check recent results
poetry run network-checker status --host google.com
CLI Commands
network-checker ping <host>
Send ping tests to a specific host
poetry run network-checker ping example.com --count 4
network-checker start-monitoring <hosts>
Start continuous monitoring of one or more hosts
poetry run network-checker start-monitoring google.com cloudflare.com --interval 60
network-checker run-server
Start the web dashboard server
poetry run network-checker run-server --host 0.0.0.0 --port 9991
network-checker status
Display recent ping results
poetry run network-checker status --host google.com --limit 10
network-checker init
Initialize the database
poetry run network-checker init
network-checker clear
Clear all ping data (with confirmation)
poetry run network-checker clear
Web Dashboard
Access the web dashboard at http://localhost:9991 after running:
poetry run network-checker run-server
Dashboard Features
- Host Selection: Choose from monitored hosts
- Time Range: View data from 1 hour to 1 week
- Statistics Cards: Total pings, success rate, average response time, packet loss rate
- Interactive Charts: Response time trends with packet loss indicators
- Auto-refresh: Updates every 30 seconds
API Endpoints
GET /api/hosts
Get list of monitored hosts
["google.com", "cloudflare.com"]
GET /api/stats?host=<host>&hours=<hours>
Get statistics for a specific host
{
"total_pings": 100,
"successful_pings": 98,
"failed_pings": 2,
"packet_loss_rate": 2.0,
"avg_response_time": 15.5,
"min_response_time": 10.2,
"max_response_time": 25.8
}
GET /api/ping_data?host=<host>&hours=<hours>
Get raw ping data for visualization
{
"host": "google.com",
"timestamps": ["2023-01-01T12:00:00", "2023-01-01T12:01:00"],
"response_times": [15.2, 16.8],
"packet_losses": [0, 0],
"total_pings": 2,
"successful_pings": 2,
"packet_loss_rate": 0.0
}
GET /api/ping_chart?host=<host>&hours=<hours>
Get Plotly chart data for dashboard visualization
Configuration
Environment Variables
# Database configuration
DATABASE_URL=sqlite:///network_checker.db
# Ping settings
PING_TIMEOUT=4.0
DEFAULT_PING_INTERVAL=60
# Default hosts to monitor
DEFAULT_HOSTS=google.com,cloudflare.com
# Flask configuration
FLASK_ENV=development
SECRET_KEY=your-secret-key
Configuration File
The application uses network_checker/config/config.py for settings:
- Development: Debug mode enabled, SQL logging
- Production: Optimized for production deployment
Architecture
network_checker/
\x00\x00 __init__.py # Package initialization
\x00\x00 app.py # Flask application factory
\x00\x00 cli.py # Command-line interface
\x00\x00 models/
\x00\x00 __init__.py
\x00\x00 ping_result.py # SQLAlchemy model
\x00\x00 services/
\x00\x00 __init__.py
\x00\x00 ping_service.py # Ping execution service
\x00\x00 scheduler_service.py # Background scheduling
\x00\x00 views/
\x00\x00 __init__.py
\x00\x00 dashboard.py # Web API endpoints
\x00\x00 templates/
\x00\x00 dashboard.html # Web dashboard UI
\x00\x00 config/
\x00\x00 __init__.py
\x00\x00 config.py # Application configuration
Database Schema
ping_results table
id: Primary key (INTEGER)target_host: Target hostname (VARCHAR(255), indexed)timestamp: Ping timestamp (DATETIME, indexed)response_time: Response time in milliseconds (FLOAT, nullable)packet_loss: Boolean indicating packet loss (BOOLEAN)error_message: Error details if ping failed (TEXT, nullable)
Dependencies
Core Dependencies:
flask ^3.1.0- Web frameworkflask-sqlalchemy ^3.1.1- Database ORMping3 ^4.0.4- Ping functionalityapscheduler ^3.10.4- Background schedulingplotly ^5.17.0- Data visualizationpandas ^2.2.3- Data manipulationflask-cors ^4.0.0- CORS supportclick ^8.1.3- CLI framework
Development Dependencies:
pytest ^8.3.4- Testing frameworkblack ^24.0.0- Code formatting
Development
Running Tests
poetry run pytest
Code Formatting
poetry run black network_checker/
Development Server
poetry run network-checker run-server --debug
Production Deployment
Docker (Coming Soon)
# Build and run with Docker
docker build -t network-checker .
docker run -p 9991:9991 network-checker
Manual Deployment
# Set production environment
export FLASK_ENV=production
# Run with a production WSGI server
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:9991 "network_checker.app:create_app('production')"
Examples
Monitor Multiple Hosts
# Start monitoring with custom intervals
poetry run network-checker start-monitoring \
google.com cloudflare.com github.com \
--interval 30
View Statistics
# Check overall status
poetry run network-checker status
# Filter by host
poetry run network-checker status --host google.com --limit 20
API Usage
# Get hosts via curl
curl http://localhost:9991/api/hosts
# Get statistics
curl "http://localhost:9991/api/stats?host=google.com&hours=24"
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- =� Documentation
- = Issue Tracker
- =� Discussions
Network Checker - Keep your network monitoring simple and effective! =�
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file network_check_tool-0.0.1.tar.gz.
File metadata
- Download URL: network_check_tool-0.0.1.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74c05deae80249f09c653a37772d795fd7e02d244e7f1ebdce0b974b9d9a8d1a
|
|
| MD5 |
7c0c0781ffd486e1b13bee385a91d0af
|
|
| BLAKE2b-256 |
b41514126d4a68daed1699f33cdcaf6fc716b077cf4a7b6d55cdfd3cf0f073ac
|
File details
Details for the file network_check_tool-0.0.1-py3-none-any.whl.
File metadata
- Download URL: network_check_tool-0.0.1-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65f70f891eded72bcc39f114b2abef60f2f2abdd36fe7c0bf85d3588634efe08
|
|
| MD5 |
7ebd017ff98774a958b4ce03b32a76e2
|
|
| BLAKE2b-256 |
ff238bb4a4c654a39ec6e1deb7dfae28d44caf0f85ae78bb42fc99f6a013bf56
|