NetWatch is a high-performance PHP-based network proxy monitoring system designed specifically for monitoring the availability status of large numbers of SOCKS5 and HTTP proxies. It supports parallel processing and can efficiently monitor thousands of proxy servers.
- π Multi-Protocol Support: Supports SOCKS5 and HTTP proxy monitoring
- π High-Performance Parallel Processing: Supports multi-process parallel detection, up to 12 concurrent processes, 500 proxies per batch
- π Real-Time Monitoring: Real-time detection of proxy server status and response times
- π§ Email Notifications: Automatic email notifications when proxy failures occur
- π Web Interface: Clean and beautiful web management interface
- π Logging: Detailed monitoring logs and historical records
- π Automatic Scheduling: Background scheduled tasks for automatic monitoring
- π₯ Batch Import: Support for batch importing proxy configurations
- πΎ SQLite Database: Lightweight database with no additional configuration required
- β±οΈ Timezone Support: Automatic timezone conversion with Beijing time display support
- PHP 8.0+
- cURL extension
- SQLite extension
- PCNTL extension (for parallel processing)
- POSIX extension
- Configured web server (Nginx + PHP-FPM or Apache)
The system has the following default performance parameters configured, which you can adjust according to your server configuration (modify in index.php
):
define('PARALLEL_MAX_PROCESSES', 24); // Maximum number of parallel processes
define('PARALLEL_BATCH_SIZE', 200); // Number of proxies processed per batch
π‘ Performance Recommendations:
- For 4-core 8GB servers, it's recommended to keep the default configuration
- For higher-spec servers, you can appropriately increase
PARALLEL_MAX_PROCESSES
- If network latency is high, you can appropriately reduce
PARALLEL_BATCH_SIZE
# Install Composer dependencies
composer install
Edit the config.php
file and modify the following configurations:
// Email configuration
define('SMTP_HOST', 'smtp.gmail.com');
define('SMTP_USERNAME', '[email protected]');
define('SMTP_PASSWORD', 'your-password');
define('SMTP_TO_EMAIL', '[email protected]');
// Monitoring configuration
define('CHECK_INTERVAL', 300); // Check interval (seconds)
define('TIMEOUT', 10); // Timeout (seconds)
define('ALERT_THRESHOLD', 3); // Consecutive failure threshold
php test.php
Visit http://your-domain/netwatch/import.php
or use command line:
# Import from file
php import.php
Proxy format examples:
192.168.1.100:1080:socks5
192.168.1.101:8080:http:username:password
10.0.0.1:1080:socks5:user:pass
# Start background monitoring service
php scheduler.php
Or use systemd service:
# Create service file
sudo nano /etc/systemd/system/netwatch.service
Service file content:
[Unit]
Description=NetWatch Monitor Service
After=network.target
[Service]
Type=simple
User=www-data
WorkingDirectory=/path/to/netwatch
ExecStart=/usr/bin/php scheduler.php
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Start service:
sudo systemctl enable netwatch
sudo systemctl start netwatch
Visit http://your-domain/netwatch/
to view the monitoring dashboard:
- Statistics Overview: Shows total proxy count, online/offline status, average response time
- Proxy List: Shows detailed status information for all proxies
- Check Logs: Shows recent monitoring check records
- Manual Check: Allows manual triggering of individual or all proxy checks
Visit http://your-domain/netwatch/import.php
for batch import:
- Supports text paste import
- Supports file upload import
- Automatically skips incorrectly formatted lines
- Shows import result statistics
Visit http://your-domain/netwatch/import_subnets.php
for subnet batch import:
- Batch Generation: Supports multiple subnets using the same port/username/password configuration
- IP Range: Define subnet ranges through start IP and end IP
- Multi-Subnet Support: Up to 20 different subnets can be configured simultaneously
- Preview Function: Preview the number of proxies to be generated before import
- Import Modes: Supports skip duplicates, overwrite updates, and other modes
Usage examples:
- Subnet 1: 192.168.1.2 to 192.168.1.30 (29 proxies)
- Subnet 2: 10.0.0.10 to 10.0.0.50 (41 proxies)
- Unified configuration: Port 1080, SOCKS5 protocol, username/password
The system sends emails in the following situations:
- Failure Notifications: When proxies fail consecutively reaching the threshold
- Daily Reports: System status reports sent daily at 9 AM
Configuration Item | Description | Default Value |
---|---|---|
DB_PATH |
SQLite database file path | ./data/netwatch.db |
SMTP_HOST |
SMTP server address | smtp.gmail.com |
SMTP_PORT |
SMTP port | 587 |
CHECK_INTERVAL |
Check interval (seconds) | 300 |
TIMEOUT |
Connection timeout (seconds) | 10 |
ALERT_THRESHOLD |
Failure notification threshold | 3 |
TEST_URL |
Test URL | http://httpbin.org/ip |
NetWatch/
βββ config.php # Main configuration file
βββ index.php # Main entry file, Web interface
βββ auth.php # User authentication module
βββ database.php # Database operation class
βββ monitor.php # Single-process monitoring implementation
βββ parallel_monitor.php # Parallel monitoring implementation
βββ parallel_worker.php # Parallel worker process
βββ parallel_batch_manager.php # Batch task management
βββ import.php # Proxy import script
βββ import_subnets.php # Subnet batch import tool
βββ mailer.php # Email notification module
βββ logger.php # Logging module
βββ scheduler.php # Scheduled task scheduler
βββ clear_proxies.php # Proxy cleanup tool
βββ login.php # Login page
βββ config.example.php # Configuration file example
βββ composer.json # Composer dependency configuration
βββ data/ # Data directory
β βββ netwatch.db # SQLite database
βββ logs/ # Log directory
β βββ netwatch_*.log # Log files
βββ Debug/ # Debug-related files
βββ Docs/ # Documentation directory
- config.php - System configuration file containing database connections, email settings, etc.
- index.php - Main entry file providing web management interface
- monitor.php - Single-process proxy monitoring implementation
- parallel_*.php - Parallel monitoring related files supporting high-performance batch detection
- import.php* - Proxy import tools supporting individual proxy and subnet batch import
- mailer.php - Email notification module for sending alerts
- logger.php - Logging module for recording system runtime status
- scheduler.php - Scheduled task scheduler for periodic monitoring execution
The system provides simple AJAX APIs:
GET /?ajax=1&action=stats
- Get statistics informationGET /?ajax=1&action=check&proxy_id=1
- Check specified proxyGET /?ajax=1&action=logs
- Get recent logs
-
Database Connection Failed
- Check data directory permissions
- Ensure PHP has SQLite extension
-
Email Sending Failed
- Check SMTP configuration
- Confirm email password is correct
- May need to use app-specific password
-
Proxy Check Failed
- Check network connection
- Confirm curl extension is installed
- Check firewall settings
-
Permission Issues
- Ensure web server has write permissions to data and logs directories
- Check file ownership and permission settings
# View latest logs
tail -f logs/netwatch_$(date +%Y-%m-%d).log
# View error logs
grep ERROR logs/netwatch_*.log
For monitoring large numbers of proxies (5000+):
- Adjust Check Interval: Adjust
CHECK_INTERVAL
as needed - Concurrent Checking: Can modify code to implement multi-threaded checking
- Database Optimization: Regularly clean old log data
- Caching Mechanism: Can add Redis caching to improve performance
MIT License