Skip to content

BlacksBart/ispmon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ISP Monitor (ispmon) A Python script designed to monitor internet connectivity and speed by performing regular pings to an ISP gateway and a general internet target, as well as running speed tests. Results are logged to daily CSV files.

Features Pings a local ISP target (e.g., router gateway) to check local network/ISP health.

Pings a general internet target (e.g., 8.8.8.8) to check broader internet connectivity.

Performs download and upload speed tests using speedtest-cli.

Logs results (timestamps, ping success/latency for both targets, download/upload speeds, server info, errors) to daily CSV files (e.g., isp_log_YYYY-MM-DD.csv).

Configuration is managed via an external config.ini file.

If config.ini is not found, the script can create a default one, prompting for a location if run interactively.

Designed to be run as a background script or service.

Prerequisites Before you begin, ensure you have the following installed on your system:

Git: For cloning the repository. (Download from git-scm.com)

Python: Version 3.7+ recommended. (Download from python.org or install via a package manager like Chocolatey).

Important: During Python installation (if using the installer from python.org), make sure to check the box that says "Add Python to PATH" or "Add python.exe to PATH".

Setup Instructions Follow these steps to set up and run the ISP Monitor on a new machine:

  1. Install System Dependencies (if not already present):

If using Chocolatey on Windows (recommended for easy setup): Open PowerShell as Administrator and run:

choco install git -y choco install python -y

Close and reopen PowerShell after these installations to ensure commands are available in your PATH.

  1. Clone the Repository:

Open PowerShell (or your preferred terminal) and navigate to the directory where you want to store the project (e.g., C:\projects). Then clone the repository:

git clone https://github.com/BlacksBart/ispmon.git cd ispmon

  1. Install Python Libraries:

Navigate into the cloned ispmon directory if you're not already there. Then, install the required Python libraries using pip:

pip install speedtest-cli ping3

Note: configparser is built into Python 3.2+ and does not need separate installation.

  1. Configure config.ini:

The script uses a config.ini file (located in the same directory as ispmon.py) for its settings.

If config.ini is missing: When you run python ispmon.py for the first time and config.ini is not found:

If running interactively, the script will prompt you to specify a path where it can create a default config.ini. You can press Enter to create it in the ispmon script directory.

If running non-interactively (e.g., as a service might initially), it will attempt to create a default config.ini in the script's directory.

Review and Edit config.ini: Open the created or existing config.ini file and adjust the settings as needed:

[Settings] IspPingTarget = 192.168.1.1 ; Your router's IP or ISP's first-hop DNS/gateway PingTarget = 8.8.8.8 ; General internet ping target (e.g., Google DNS) TestIntervalMinutes = 15 ; How often to run checks (in minutes) ProjectDir = c:\projects\ispmon\logs ; ABSOLUTE path where daily log files will be saved LogFilePrefix = isp_log_ ; Prefix for log files (date and .csv will be appended) RetryOnSpeedtestFailureSeconds = 60 ; Wait time before retrying a failed speed test

IspPingTarget: Crucial for checking connectivity to your immediate ISP equipment.

PingTarget: For checking general internet reachability.

ProjectDir: Important! Ensure this is an absolute path (e.g., C:\ispmon_logs or C:\projects\ispmon\logs). The script will create this directory if it doesn't exist. This is where your isp_log_YYYY-MM-DD.csv files will be stored.

LogFilePrefix: The script will append the date (YYYY-MM-DD) and .csv to this prefix.

  1. Run the Script:

Once configured, you can run the script manually from PowerShell (or terminal) from within the ispmon directory:

python ispmon.py

The script will start monitoring and logging. Press Ctrl+C to stop it.

Log Files Log files are created daily in the directory specified by ProjectDir in config.ini.

The naming convention is [LogFilePrefix]YYYY-MM-DD.csv (e.g., isp_log_2025-06-04.csv).

If the script is run multiple times on the same day, new entries will be appended to that day's log file.

Running as a Service (Windows - Optional) For continuous monitoring, you can set up the script to run as a Windows service. See separate instructions or documentation for using tools like:

Windows Task Scheduler

NSSM (Non-Sucking Service Manager) - choco install nssm

When running as a service, ensure the ProjectDir in config.ini is an absolute path, and the user account the service runs under has necessary permissions to read the script, write to the log directory, and perform network operations.

Troubleshooting ImportError for speedtest or ping3: Ensure you ran pip install speedtest-cli ping3 in the environment/Python interpreter that python ispmon.py is using.

Log files not appearing or in wrong location: Double-check the ProjectDir in config.ini is an absolute path and the script has write permissions to it.

Speedtest "403 Forbidden" errors: The script attempts to use secure=True for speedtest configuration, which often helps. If issues persist, it might be a temporary block from speedtest.net or ISP interference.

Ping failures:

Check your IspPingTarget and PingTarget IP addresses.

Ensure your firewall isn't blocking outbound ICMP requests from Python or ping3.

About

Capture data on my PC to confice my ISP they are introducing service limitations and outages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages