mirror of
https://github.com/unixtensor/proxmox-ntfy.git
synced 2025-06-28 13:08:05 +00:00
Remove CPU critical tempature warning
This commit is contained in:
18
src/cpu.py
18
src/cpu.py
@ -1,22 +1,20 @@
|
||||
import subprocess
|
||||
import time
|
||||
import math
|
||||
import re
|
||||
|
||||
from typing import Optional
|
||||
from ntfy import Ntfy
|
||||
|
||||
_time_now = time.time()
|
||||
last_cpu_check_critical: float = _time_now
|
||||
last_cpu_check_warning: float = _time_now
|
||||
|
||||
last_cpu_check: int = 60 # Seconds
|
||||
last_check_debounce: int = 120 # Seconds
|
||||
|
||||
class Tempature:
|
||||
cpu_temp_crtitical_message: str = "🔥 CPU tempature is at critical tempatures!"
|
||||
cpu_temp_warning_message: str = "🌡️ CPU tempature is at a high tempature."
|
||||
cpu_temp_warning_message: str = "🌡️ CPU is at a high tempature."
|
||||
|
||||
def __init__(self, ntfy_instance: Ntfy, cpu_critical_temp: int, cpu_warning_temp: int):
|
||||
self.cpu_critical_temp = cpu_critical_temp
|
||||
def __init__(self, ntfy_instance: Ntfy, cpu_warning_temp: int):
|
||||
self.cpu_warning_temp = cpu_warning_temp
|
||||
self.ntfy = ntfy_instance
|
||||
|
||||
@ -30,13 +28,11 @@ class Tempature:
|
||||
return None
|
||||
|
||||
def __check_time(self, last_check: float) -> bool:
|
||||
return (time.time() - last_check) > last_cpu_check * 1000
|
||||
return (time.time() - last_check) > last_check_debounce * 1000
|
||||
|
||||
def ntfy_check(self):
|
||||
cpu_temp = self.get()
|
||||
if cpu_temp:
|
||||
print(f"{cpu_temp}")
|
||||
if cpu_temp >= self.cpu_critical_temp and self.__check_time(last_cpu_check_critical):
|
||||
self.ntfy.send(f"{Tempature.cpu_temp_crtitical_message} {cpu_temp}")
|
||||
cpu_temp = math.floor(cpu_temp)
|
||||
if cpu_temp >= self.cpu_warning_temp and self.__check_time(last_cpu_check_warning):
|
||||
self.ntfy.send(f"{Tempature.cpu_temp_warning_message} {cpu_temp}")
|
||||
self.ntfy.send(f"{Tempature.cpu_temp_warning_message} {cpu_temp} C")
|
||||
|
Reference in New Issue
Block a user