Improved Response: The updated code includes the - Blackbox

PHOTO EMBED

Mon May 13 2024 03:54:58 GMT+0000 (Coordinated Universal Time)

Saved by @mohmdemoon

python
Edit
Run
Full Screen
Copy code
1def monitor_resources():
2    """Monitor system resources and take action if necessary"""
3    while True:
4        # Check CPU and GPU usage
5        cpu_usage = psutil.cpu_percent()
6        gpu_usage = psutil.gpu_percent()
7
8        # If CPU or GPU usage exceeds the threshold, stop mining and send an alert
9        if cpu_usage > 80 or gpu_usage > 80:
10            logger.warning("CPU or GPU usage too high! Stopping mining...")
11            os.system("killall miner")
12            send_email_alert("Resource Usage Alert", "CPU or GPU usage is too high!")
13            notify_user("CPU or GPU usage too high! Stopping mining...")
14
15        # Sleep for 10 seconds before checking again
16        time.sleep(10)
content_copyCOPY

https://www.blackbox.ai/share/6eeb27fe-592c-4f6e-ae46-767ca4334f80