Network monitoring and diagnostics toolkit for discovering ping problems, analyzing disconnects, and logging network status.
This repository provides three complementary tools for comprehensive network monitoring, plus a simple GUI for easy control:
- NetWatch.ps1 - Windows PowerShell script for continuous network monitoring (ping, DNS, adapter status)
- fritzlog_pull.py - Python script for logging FRITZ!Box router status via TR-064 API
- fritzbox_restart.py - Python script for sending restart commands to FRITZ!Box router via TR-064 API
- FritzBoxRestart/ - Android app for restarting FRITZ!Box router from your phone
- analyze_netlogs.py - Python script for analyzing collected logs and detecting network incidents
- visualize_incidents.py - Python script for generating graphical visualizations and HTML reports from incident data
- NetWatchUI.ps1 - Windows Forms GUI for configuring, starting, stopping, analyzing, and visualizing network monitoring
- Windows PowerShell 5+ or PowerShell Core 7+
- Windows OS (uses Windows-specific networking cmdlets)
- Administrator privileges recommended for full network adapter access
- Python 3.10 or higher
- Required Python packages:
fritzconnection(for fritzlog_pull.py and fritzbox_restart.py)pandas(optional, for analyze_netlogs.py - improves performance)matplotlib(optional, for analyze_netlogs.py plotting features)
- Android 7.0 (API 24) or higher
- FRITZ!Box router accessible on your local network
- TR-064 API enabled on FRITZ!Box (usually enabled by default)
# Required for fritzlog_pull.py
pip install fritzconnection
# Optional for analyze_netlogs.py (recommended)
pip install pandas matplotlibThe PowerShell script can be run directly without installation.
The easiest way to use the network monitoring tools is through the graphical user interface.
Launch the UI:
.\NetWatchUI.ps1Features:
- Configuration Tab: Set all parameters for NetWatch, FRITZ!Box logging, and analysis
- Configure monitoring interval, output paths, and ping targets
- Set FRITZ!Box credentials and connection settings
- Define analysis thresholds for latency and packet loss
- Control Tab: Start, stop, and analyze monitoring
- Start/Stop tracking with a single button click
- Restart FRITZ!Box router with one click (with confirmation dialog)
- View real-time activity log
- Run log analysis and generate incident reports
- Generate graphical visualizations of incidents
- Quick access to log folder
Quick Start:
- Launch
NetWatchUI.ps1 - Go to the Configuration tab and adjust settings (or use defaults)
- Switch to the Control tab
- Click "Start Tracking" to begin monitoring
- Let it run for a while to collect data
- Click "Stop Tracking" when done
- Click "Analyze Logs" to generate incident reports
The UI runs both NetWatch.ps1 and fritzlog_pull.py in the background and provides a convenient way to control them without using the command line.
Continuously monitors network status by checking adapter state, pinging multiple targets, testing DNS resolution, and logging all data to CSV.
Basic usage:
.\NetWatch.ps1With custom parameters:
.\NetWatch.ps1 -IntervalSeconds 60 -OutCsv "C:\Logs\network.csv" -PingTargets @("8.8.8.8", "1.1.1.1")Parameters:
-IntervalSeconds- Monitoring interval in seconds (default: 30)-OutCsv- Output CSV file path (default:~/Documents/Ping/Log/netwatch_log.csv)-PingTargets- Array of targets to ping (default:@("8.8.8.8","1.1.1.1","192.168.178.1","www.riotgames.com"))
What it monitors:
- Active network adapter status and media connection state
- IPv4/IPv6 configuration
- Default gateway
- DNS resolution (tests www.google.com)
- Ping latency and packet loss to multiple targets
Output format: CSV file with columns: timestamp, adapter, media_status, ipv4, ipv6_enabled, gateway, dns_ok, dns_ms, and ping statistics (avg_ms and loss_pct) for each target.
The script runs indefinitely until stopped with Ctrl+C. Output directory is created automatically if it doesn't exist.
Logs FRITZ!Box router status including WAN connection state, uptime, external IP, traffic counters, and DSL link status.
Basic usage:
python3 fritzlog_pull.py --password YOUR_PASSWORDWith custom parameters:
python3 fritzlog_pull.py --host 192.168.178.1 --password YOUR_PASSWORD --interval 60 --out ~/logs/fritz.csvParameters:
--host- FRITZ!Box IP address (default: 192.168.178.1)--user- FRITZ!Box username (default: None, often not needed for older setups)--password- FRITZ!Box password (required)--interval- Logging interval in seconds (default: 30)--out- Output CSV file path (default:~/Documents/Ping/Log/fritz_status_log.csv)
What it logs:
- WAN connection status
- Connection uptime in seconds
- External IP address
- Last connection error
- Total bytes sent/received
- DSL link status (if available)
Output format: CSV file with columns: timestamp, wan_connection_status, wan_uptime_s, wan_external_ip, wan_last_error, common_bytes_sent, common_bytes_recv, dsl_link_status.
The script runs indefinitely until stopped with Ctrl+C. Output directory is created automatically if it doesn't exist.
Sends a restart command to FRITZ!Box router via TR-064 API. This is useful for automating router reboots or resetting the connection when troubleshooting network issues.
Basic usage:
python3 fritzbox_restart.py --password YOUR_PASSWORDWith custom parameters:
python3 fritzbox_restart.py --host 192.168.178.1 --user admin --password YOUR_PASSWORD --timeout 10Skip confirmation prompt:
python3 fritzbox_restart.py --password YOUR_PASSWORD --yesParameters:
--host- FRITZ!Box IP address (default: 192.168.178.1)--user- FRITZ!Box username (optional)--password- FRITZ!Box password (required)--timeout- Connection timeout in seconds (default: 10)--yes- Skip confirmation prompt
What it does:
- Connects to FRITZ!Box using TR-064 API
- Sends DeviceConfig:1 Reboot command
- Confirms success or reports errors
- The router will reboot and be unavailable for 1-2 minutes
GUI Integration: The restart functionality is integrated into NetWatchUI.ps1 in the Control tab as "Restart FRITZ!Box" button. The GUI automatically uses the credentials from the Configuration tab and displays a confirmation dialog before restarting.
Safety:
The script requires explicit confirmation (unless --yes flag is used) to prevent accidental reboots. When used via the GUI, a warning dialog is always shown.
A simple Android application to restart your FRITZ!Box router directly from your phone.
Features:
- Simple, clean user interface
- Password input with show/hide toggle
- Autofill support for password managers (Google/Samsung)
- Fingerprint unlock support via password managers
- Confirmation dialog before restart
- Real-time status updates
- No Play Store required - can be sideloaded
Installation:
- Build the APK using Android Studio
- Transfer to your phone and install
- See
FritzBoxRestart/README.mdfor detailed instructions
Usage:
- Open the app
- Enter FRITZ!Box IP address (default: 192.168.178.1)
- Enter password (supports autofill from password managers)
- Tap "Restart FRITZ!Box"
- Confirm in the dialog
- Wait 1-2 minutes for reboot
Requirements:
- Android 7.0 (API 24) or higher
- FRITZ!Box accessible on local network
- TR-064 API enabled on FRITZ!Box
For complete documentation, see FritzBoxRestart/README.md.
Analyzes NetWatch and FRITZ!Box logs to detect and report network incidents such as latency spikes, packet loss, disconnects, and configuration changes.
Basic usage:
python3 analyze_netlogs.py --netwatch netwatch_log.csv --fritz fritz_status_log.csvWith custom parameters:
python3 analyze_netlogs.py --netwatch netwatch_log.csv --fritz fritz_status_log.csv --out incidents.csv --latency 50 --loss 5.0 --plotsParameters:
--netwatch- Path to NetWatch CSV log (required)--fritz- Path to FRITZ!Box CSV log (required)--out- Output incidents CSV file (default: incidents.csv)--latency- Latency spike threshold in ms (default: 20)--loss- Packet loss spike threshold in percent (default: 1.0)--plots- Generate latency plots (requires matplotlib and pandas)
What it detects:
- DNS resolution failures
- Network adapter status changes
- Media connection state changes
- Latency spikes above threshold
- Packet loss above threshold
- WAN reconnects (uptime resets)
- WAN status changes
- External IP changes
- DSL link abnormalities
Output format: CSV file with columns: source (PC/FRITZ), type (incident type), start, end, duration, details.
The script also prints a summary of detected incidents to the console and optionally generates latency plots for each ping target.
Creates graphical visualizations and interactive HTML reports from incident CSV files generated by analyze_netlogs.py.
Basic usage:
python3 visualize_incidents.py --input incidents.csvWith HTML report:
python3 visualize_incidents.py --input incidents.csv --output-dir ~/Reports --htmlParameters:
--input,-i- Path to incidents CSV file (required)--output-dir,-o- Output directory for visualizations (default: current directory)--html- Generate interactive HTML report with embedded charts--no-timeline- Skip timeline plot generation--no-summary- Skip summary charts generation
What it generates:
- incidents_timeline.png - Timeline visualization showing all incidents over time
- incidents_summary.png - Pie chart of incident types and bar chart of sources
- incidents_report.html - Interactive HTML report with statistics, charts, and detailed incident table
The timeline plot shows when incidents occurred, their duration, and type. The summary charts provide quick overview statistics. The HTML report combines everything into an easy-to-navigate web page that opens in your browser.
Note: This tool is automatically integrated into NetWatchUI.ps1. Click the "View Visualizations" button in the Control tab after analyzing logs.
-
Launch the UI:
.\NetWatchUI.ps1
-
Configure settings in the Configuration tab (or use defaults)
-
Click "Start Tracking" in the Control tab
-
Let it run for a period of time (hours or days) to collect data
-
Click "Stop Tracking" when done
-
Click "Analyze Logs" to generate incident reports
-
Click "View Visualizations" to see graphical charts and HTML report
-
Review the generated incidents.csv, visualizations, and HTML report
-
Start network monitoring on your PC:
.\NetWatch.ps1 -IntervalSeconds 30
-
Start FRITZ!Box logging (in a separate terminal):
python3 fritzlog_pull.py --password YOUR_PASSWORD --interval 30
-
Let both scripts run for a period of time (hours or days) to collect data
-
Analyze the collected logs:
python3 analyze_netlogs.py --netwatch ~/Documents/Ping/Log/netwatch_log.csv --fritz ~/Documents/Ping/Log/fritz_status_log.csv --out incidents.csv --plots
-
Generate visualizations:
python3 visualize_incidents.py --input incidents.csv --output-dir ~/Reports --html -
Review the generated incidents.csv, plots, and open the HTML report in your browser
Run the PowerShell tests:
# Install Pester if needed
Install-Module -Name Pester -Force -SkipPublisherCheck
# Run tests
Invoke-Pester .\NetWatch.Tests.ps1- NetWatchUI.ps1 - Windows Forms GUI for controlling all monitoring tools and viewing visualizations
- NetWatch.ps1 - PowerShell network monitoring script with CSV logging
- NetWatch.Tests.ps1 - Pester unit tests for NetWatch.ps1 functions
- fritzlog_pull.py - FRITZ!Box TR-064 API logger
- fritzbox_restart.py - FRITZ!Box restart command sender via TR-064 API
- FritzBoxRestart/ - Android app for restarting FRITZ!Box from your phone
- test_fritzlog_pull.py - Unit tests for fritzlog_pull.py
- test_fritzbox_restart.py - Unit tests for fritzbox_restart.py
- analyze_netlogs.py - Log analysis and incident detection tool
- visualize_incidents.py - Incident visualization and HTML report generator
- .gitignore - Excludes log files, cache, and build artifacts
- Use the GUI (NetWatchUI.ps1) for the easiest experience - no need to remember command-line parameters
- Run NetWatch.ps1 continuously in the background to build a historical network quality baseline
- Use Task Scheduler (Windows) to run NetWatchUI.ps1 or the individual scripts automatically at system startup
- Adjust thresholds in the GUI's Configuration tab or in analyze_netlogs.py based on your network quality expectations
- Default ping targets include Google DNS (8.8.8.8), Cloudflare DNS (1.1.1.1), your router (192.168.178.1), and a game server (www.riotgames.com) - customize as needed
- CSV logs can be imported into Excel or other analysis tools for custom visualizations
- If you don't have a FRITZ!Box, simply uncheck "Enable FRITZ!Box logging" in the UI
NetWatchUI.ps1:
- If the UI doesn't start, ensure you're running on Windows with PowerShell 5+ or PowerShell Core 7+
- If you get execution policy errors, run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - The UI will automatically detect a working Python installation using
python,py, orpython3commands - If Python is not found, you'll see a warning on startup - install Python from python.org and ensure it's in your PATH
- Windows Note: If you see "Python was not found" errors, the Windows Store app alias may be interfering. Install Python from python.org instead.
- Check the Activity Log in the Control tab for detailed error messages
NetWatch.ps1:
- If you get permission errors, run PowerShell as Administrator
- On non-Windows systems, the script will not work as it uses Windows-specific cmdlets
fritzlog_pull.py:
- Ensure TR-064 API is enabled in your FRITZ!Box settings (Home Network > Network > Network Settings)
- Verify correct password and network connectivity to FRITZ!Box
- Some older FRITZ!Box models may not support all queried services
analyze_netlogs.py:
- Install pandas for better performance and plotting support
- Ensure timestamp formats in CSV files are consistent
- If no incidents are detected, try lowering the threshold values
This repository includes a comprehensive GitHub Actions pipeline for continuous integration, deployment, and releases:
-
Continuous Integration: Automated testing on every push and pull request
- PowerShell validation with PSScriptAnalyzer and Pester tests
- Python 3.12 validation and testing
- Windows-only testing (optimized for target platform)
- Security scanning with CodeQL and Trivy
-
Automated Deployment: Package scripts automatically on every push to main
- Downloads available as workflow artifacts
- 90-day retention for latest builds
-
Release Management: Create versioned releases with git tags
- Automatic package creation (ZIP and tarball)
- SHA256 checksums for verification
- Release notes generation
For detailed information about the CI/CD pipeline, see .github/WORKFLOWS.md.
This project is provided as-is for network monitoring and diagnostics purposes.