Skip to content

dandiest/cpu-shield-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CPU-Shield ๐Ÿ›ก๏ธ

CPU-Shield is a powerful, lightweight Python utility designed to monitor system resources, alert the user about CPU spikes, and provide an automated defense mechanism against runaway processes.

๐Ÿš€ Key Features

  • Real-time Monitoring: Analyzes CPU usage at randomized intervals to detect anomalies.
  • Active Defense: Automatically terminates non-whitelisted processes that exceed 90% CPU usage.
  • Detailed Logging: Records all alerts, including timestamps and the top 3 offending processes (PID, Name, CPU%).
  • Cross-Platform Notifications: Native desktop alerts for Windows, macOS, and Linux.
  • Safety Whitelist: Built-in protection for critical system processes.

๐Ÿ› ๏ธ Installation

  1. Clone the repository:
    git clone [https://github.com/leumascripts/cpu-shield-py.git](https://github.com/leumascripts/cpu-shield-py.git)
    cd cpu-shield.py
    
    Install dependencies: pip install -r requirements.txt
    

๐Ÿ’ป Usage

  1. Since the script needs to manage system processes, it must be run with administrative privileges:

    Windows: Run PowerShell or Command Prompt as Administrator.

    Linux/macOS: sudo python cpu_shield.py

โš™๏ธ Configuration

  1. You can customize the behavior directly in the script:

    CPU_THRESHOLD: Percentage to trigger logs (default: 80%).

    PROCESS_WHITELIST: List of processes that the script will never terminate.

    MAX_CONSECUTIVE: Number of high-CPU checks before the safety shutdown/hibernation sequence.

โš ๏ธ Disclaimer

This tool is powerful. The Active Defense feature will terminate processes. Ensure you have added your critical work applications to the PROCESS_WHITELIST to avoid data loss. The author is not responsible for any system instability or data loss.

๐Ÿ“„ License

Distributed under the MIT License. See LICENSE for more information.

About

A proactive Python system monitor designed to track CPU usage and protect system stability by terminating high-load processes, featuring a customizable safety whitelist.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages