Repository navigation
Enhanced CPU Monitor & App Restarter
A Windows python application for monitoring CPU usage of specific applications and automatically restarting them when CPU usage exceeds thresholds or when they crash.
π Features
- Real-time CPU Monitoring: Monitor multiple applications simultaneously with accurate CPU percentage readings
- Smart Process Detection: Automatically detects processes by name, executable path, and running instances
- Automatic App Restart: Restart applications when CPU usage exceeds configurable thresholds
- Auto-recovery: Automatically restart crashed or terminated applications
- Configurable Delays:
- Startup Delay: Wait time before restarting apps (default: 3 seconds)
- Monitoring Startup Delay: Wait time before starting monitoring to allow CPU normalization (default: 10 seconds)
- Process Discovery: Automatically find executable paths for monitored applications
- Pause/Resume: Pause monitoring without losing configuration
- Comprehensive Logging: Detailed activity log with timestamps
- Modern UI: Clean, dark-themed interface with intuitive controls
π Requirements
- Windows 10/11
- Python 3.7+
- Required Python packages (see
requirements.txt)
π οΈ Installation
Option 1: Quick Install (Recommended)
-
Download the repository:
git clone https://github.com/yourusername/cpu_monitor1.git cd cpu_monitor1 -
Run the installer:
install.bat
-
Launch the application:
run_cpu_monitor.bat
Option 2: Manual Installation
-
Install Python dependencies:
pip install -r requirements.txt
-
Run the application:
python cpu_monitor_enhanced.py
π― Usage
Basic Setup
- Launch the application
- Configure settings:
- Set CPU threshold percentage (default: 15%)
- Set check interval in seconds (default: 5 seconds)
- Set startup delays as needed
- Add applications to monitor:
- Enter application name (e.g., "reolink")
- Click "Add App"
- Start monitoring:
- Click "Start Monitoring"
- The app will wait for the monitoring startup delay, then begin monitoring
Advanced Features
Discover Executables
- Click "Discover Executables" to automatically find and set executable paths
- Useful for applications that aren't in the system PATH
Debug CPU Monitoring
- Click "Debug CPU" to test CPU monitoring in real-time
- Shows detailed process information and CPU usage
Right-click Context Menu
- Right-click on any monitored app for additional options:
- Set Executable Path manually
- Remove application from monitoring
Pause/Resume Monitoring
- Use "Pause Monitoring" to temporarily stop monitoring
- Click "Resume Monitoring" to continue
βοΈ Configuration
Settings File (settings.json)
{
"cpu_threshold": 15.0,
"check_interval": 5.0,
"startup_delay": 3.0,
"monitoring_startup_delay": 10.0,
"auto_restart_enabled": true
}Monitored Apps File (monitored_apps.json)
[
{
"name": "reolink",
"process_name": "Reolink.exe",
"status": "Active",
"enabled": true,
"last_cpu": 0.0,
"restart_count": 0,
"executable_path": "C:\\Program Files\\Reolink\\Reolink.exe"
}
]π§ Troubleshooting
Common Issues
-
CPU always shows 0%:
- Use "Debug CPU" button to test monitoring
- Check if process names match exactly
- Verify applications are running
-
Buttons not working:
- Check console output for error messages
- Ensure window is properly sized (1000x800 minimum)
- Verify Python dependencies are installed
-
Process not found:
- Use "Discover Executables" button
- Check process name spelling
- Verify application is actually running
Debug Mode
The application includes comprehensive debugging:
- Console output for all operations
- Detailed process detection logging
- Error handling with fallback mechanisms
π File Structure
cpu_monitor1/
βββ cpu_monitor_enhanced.py # Main application
βββ requirements.txt # Python dependencies
βββ install.bat # Windows installer
βββ run_cpu_monitor.bat # Windows launcher
βββ run_cpu_monitor.ps1 # PowerShell launcher
βββ settings.json # Application settings
βββ monitored_apps.json # Monitored applications
βββ cpu_monitor.log # Application log file
βββ README.md # This file
π Version History
v2.0 (Enhanced)
- Fixed: NoneType errors in process detection
- Added: Monitoring startup delay for CPU normalization
- Enhanced: Process detection with multiple fallback strategies
- Improved: UI layout and visibility
- Added: Comprehensive debugging and logging
- Enhanced: Error handling and recovery
v1.0 (Original)
- Basic CPU monitoring
- Simple app restart functionality
- Basic UI
π€ 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.
π Acknowledgments
- Built with Python and tkinter
- Uses psutil for process monitoring
- Enhanced with modern UI design principles
- Comprehensive error handling and debugging
π Support
If you encounter any issues or have questions:
- Check the troubleshooting section above
- Review the console output for error messages
- Open an issue on GitHub with detailed information