mirror of
https://github.com/unixtensor/proxmox-ntfy.git
synced 2025-06-28 13:28:05 +00:00
Implament sys.argv
with argparse
This commit is contained in:
17
src/cpu.py
17
src/cpu.py
@ -5,8 +5,11 @@ import re
|
||||
from typing import Optional
|
||||
from ntfy import Ntfy
|
||||
|
||||
last_cpu_check_unix: float = time.time()
|
||||
last_cpu_check: int = 60 # Seconds
|
||||
_time_now = time.time()
|
||||
last_cpu_check_critical: float = _time_now
|
||||
last_cpu_check_warning: float = _time_now
|
||||
|
||||
last_cpu_check: int = 60 # Seconds
|
||||
|
||||
class Tempature:
|
||||
cpu_temp_crtitical_message: str = "🔥 CPU tempature is at critical tempatures!"
|
||||
@ -26,10 +29,14 @@ class Tempature:
|
||||
return float(match.group(1))
|
||||
return None
|
||||
|
||||
def __check_time(self, last_check: float) -> bool:
|
||||
return (time.time() - last_check) > last_cpu_check * 1000
|
||||
|
||||
def ntfy_check(self):
|
||||
cpu_temp = self.get()
|
||||
if cpu_temp and (time.time() - last_cpu_check_unix) > last_cpu_check * 1000:
|
||||
if cpu_temp >= self.cpu_critical_temp:
|
||||
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}")
|
||||
elif cpu_temp >= self.cpu_warning_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}")
|
||||
|
Reference in New Issue
Block a user