This commit is contained in:
Daniel Langbein 2023-11-20 14:13:21 +01:00
parent 681a946223
commit e8e3e72a63
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
9 changed files with 40 additions and 4 deletions

View File

@ -13,12 +13,15 @@ from de.p1st.monitor.warn_data import WarnData
class CPULogger(Logger):
"""
CPU load average (base class).
"""
def __init__(self,
warn_if_above: float = None,
warn_threshold: int = 1,
warn_data_range: int = 1,
):
critical_if_above = warn_if_above * 1.5
super().__init__(warn_threshold,
warn_data_range,

View File

@ -24,6 +24,10 @@ class IDException(Exception):
class DriveLogger(Logger):
"""
Drive temperature.
"""
def __init__(self,
uuid: str = None,
id_: str = None,
@ -123,7 +127,8 @@ class DriveLogger(Logger):
"""
returncode, stdout, stderr = execute_capture(['blkid', '-s', 'UUID', '-o', 'value', f'{device}'])
if returncode != 0:
raise BlkidException(f'blkid failed for device {device} with returncode {returncode}\nstdout: {stdout}\nstderr: {stderr}')
raise BlkidException(
f'blkid failed for device {device} with returncode {returncode}\nstdout: {stdout}\nstderr: {stderr}')
uuid = stdout.strip()
if len(uuid) == 0:
@ -135,7 +140,7 @@ class DriveLogger(Logger):
@classmethod
def get_temp_from_device(cls, device: Path) -> int:
"""
Use `smartctl` to get HDD/SSD temperature.
Use `smartctl` to get HDD/SSD/NVMe temperature.
As reading SMART data wakes up standby HDD drives, we skip them.

View File

@ -13,6 +13,10 @@ from de.p1st.monitor.warn_data import WarnData
class DriveTempLogger(Logger):
"""
Minimum and maximum temperature of multiple drives of the same type (e.g. HDDs or NVMes).
"""
def __init__(self,
type_: Literal['drivetemp', 'nvme'],
warn_if_above: int = None,

View File

@ -18,6 +18,10 @@ class NotMounted(Exception):
class FilesystemLogger(Logger):
"""
Disk usage.
"""
def __init__(self, uuid: str = None,
mountpoint: Path = None,
unmounted_ok: bool = False,

View File

@ -10,6 +10,10 @@ from de.p1st.monitor.warn_data import WarnData
class MemoryLogger(Logger):
"""
Used, cached and total memory.
"""
def __init__(self,
warn_if_above: float = 1.0,
warn_threshold: int = 1,

View File

@ -14,6 +14,10 @@ from de.p1st.monitor.warn import WarnLevel, WarnMessage
class NetworkLogger(Logger):
"""
Network bytes sent and received.
"""
def __init__(self, network_interface: str):
super().__init__()
self.network_interface = network_interface

View File

@ -10,6 +10,10 @@ from de.p1st.monitor.warn_data import WarnData
class ScriptLogger(Logger):
"""
Single value returned by specified script.
"""
def __init__(self, command: list[str],
sensor_name: str,
warn_if_above: float = None,

View File

@ -11,6 +11,10 @@ from de.p1st.monitor.warn_data import WarnData
class SwapLogger(Logger):
"""
Used and total swap.
"""
def __init__(self,
warn_if_above: float = 1.0,
warn_threshold: int = 1,

View File

@ -11,6 +11,10 @@ from de.p1st.monitor.warn_data import WarnData
class TempLogger(Logger):
"""
Temperature of sensor.
"""
def __init__(self, sensor_name: str,
sensor_label: str,
warn_if_above: float = None,