Skip to main content

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.

Network Checker Dashboard Python Version License

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 framework
  • flask-sqlalchemy ^3.1.1 - Database ORM
  • ping3 ^4.0.4 - Ping functionality
  • apscheduler ^3.10.4 - Background scheduling
  • plotly ^5.17.0 - Data visualization
  • pandas ^2.2.3 - Data manipulation
  • flask-cors ^4.0.0 - CORS support
  • click ^8.1.3 - CLI framework

Development Dependencies:

  • pytest ^8.3.4 - Testing framework
  • black ^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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support


Network Checker - Keep your network monitoring simple and effective! =�

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

network_check_tool-0.0.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

network_check_tool-0.0.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

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

Hashes for network_check_tool-0.0.1.tar.gz
Algorithm Hash digest
SHA256 74c05deae80249f09c653a37772d795fd7e02d244e7f1ebdce0b974b9d9a8d1a
MD5 7c0c0781ffd486e1b13bee385a91d0af
BLAKE2b-256 b41514126d4a68daed1699f33cdcaf6fc716b077cf4a7b6d55cdfd3cf0f073ac

See more details on using hashes here.

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

Hashes for network_check_tool-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 65f70f891eded72bcc39f114b2abef60f2f2abdd36fe7c0bf85d3588634efe08
MD5 7ebd017ff98774a958b4ce03b32a76e2
BLAKE2b-256 ff238bb4a4c654a39ec6e1deb7dfae28d44caf0f85ae78bb42fc99f6a013bf56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page