mirror of
https://codeberg.org/privacy1st/de-p1st-monitor
synced 2024-11-21 19:33:18 +01:00
docs
This commit is contained in:
parent
681a946223
commit
e8e3e72a63
@ -13,12 +13,15 @@ from de.p1st.monitor.warn_data import WarnData
|
|||||||
|
|
||||||
|
|
||||||
class CPULogger(Logger):
|
class CPULogger(Logger):
|
||||||
|
"""
|
||||||
|
CPU load average (base class).
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
warn_if_above: float = None,
|
warn_if_above: float = None,
|
||||||
warn_threshold: int = 1,
|
warn_threshold: int = 1,
|
||||||
warn_data_range: int = 1,
|
warn_data_range: int = 1,
|
||||||
):
|
):
|
||||||
|
|
||||||
critical_if_above = warn_if_above * 1.5
|
critical_if_above = warn_if_above * 1.5
|
||||||
super().__init__(warn_threshold,
|
super().__init__(warn_threshold,
|
||||||
warn_data_range,
|
warn_data_range,
|
||||||
|
@ -24,6 +24,10 @@ class IDException(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class DriveLogger(Logger):
|
class DriveLogger(Logger):
|
||||||
|
"""
|
||||||
|
Drive temperature.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
uuid: str = None,
|
uuid: str = None,
|
||||||
id_: str = None,
|
id_: str = None,
|
||||||
@ -123,7 +127,8 @@ class DriveLogger(Logger):
|
|||||||
"""
|
"""
|
||||||
returncode, stdout, stderr = execute_capture(['blkid', '-s', 'UUID', '-o', 'value', f'{device}'])
|
returncode, stdout, stderr = execute_capture(['blkid', '-s', 'UUID', '-o', 'value', f'{device}'])
|
||||||
if returncode != 0:
|
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()
|
uuid = stdout.strip()
|
||||||
if len(uuid) == 0:
|
if len(uuid) == 0:
|
||||||
@ -135,7 +140,7 @@ class DriveLogger(Logger):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_temp_from_device(cls, device: Path) -> int:
|
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.
|
As reading SMART data wakes up standby HDD drives, we skip them.
|
||||||
|
|
||||||
|
@ -13,6 +13,10 @@ from de.p1st.monitor.warn_data import WarnData
|
|||||||
|
|
||||||
|
|
||||||
class DriveTempLogger(Logger):
|
class DriveTempLogger(Logger):
|
||||||
|
"""
|
||||||
|
Minimum and maximum temperature of multiple drives of the same type (e.g. HDDs or NVMes).
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
type_: Literal['drivetemp', 'nvme'],
|
type_: Literal['drivetemp', 'nvme'],
|
||||||
warn_if_above: int = None,
|
warn_if_above: int = None,
|
||||||
|
@ -18,6 +18,10 @@ class NotMounted(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class FilesystemLogger(Logger):
|
class FilesystemLogger(Logger):
|
||||||
|
"""
|
||||||
|
Disk usage.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, uuid: str = None,
|
def __init__(self, uuid: str = None,
|
||||||
mountpoint: Path = None,
|
mountpoint: Path = None,
|
||||||
unmounted_ok: bool = False,
|
unmounted_ok: bool = False,
|
||||||
|
@ -10,6 +10,10 @@ from de.p1st.monitor.warn_data import WarnData
|
|||||||
|
|
||||||
|
|
||||||
class MemoryLogger(Logger):
|
class MemoryLogger(Logger):
|
||||||
|
"""
|
||||||
|
Used, cached and total memory.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
warn_if_above: float = 1.0,
|
warn_if_above: float = 1.0,
|
||||||
warn_threshold: int = 1,
|
warn_threshold: int = 1,
|
||||||
@ -28,7 +32,7 @@ class MemoryLogger(Logger):
|
|||||||
used_mb = data[1]
|
used_mb = data[1]
|
||||||
total_available_mb = data[3]
|
total_available_mb = data[3]
|
||||||
used = used_mb / total_available_mb
|
used = used_mb / total_available_mb
|
||||||
message = f'Memory usage ist at {used_mb} MB of {total_available_mb} MB ({round(used*100,2)}%)'
|
message = f'Memory usage ist at {used_mb} MB of {total_available_mb} MB ({round(used * 100, 2)}%)'
|
||||||
return WarnData(data[0], used, message)
|
return WarnData(data[0], used, message)
|
||||||
|
|
||||||
def read_data(self) -> list[any]:
|
def read_data(self) -> list[any]:
|
||||||
|
@ -14,6 +14,10 @@ from de.p1st.monitor.warn import WarnLevel, WarnMessage
|
|||||||
|
|
||||||
|
|
||||||
class NetworkLogger(Logger):
|
class NetworkLogger(Logger):
|
||||||
|
"""
|
||||||
|
Network bytes sent and received.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, network_interface: str):
|
def __init__(self, network_interface: str):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.network_interface = network_interface
|
self.network_interface = network_interface
|
||||||
|
@ -10,6 +10,10 @@ from de.p1st.monitor.warn_data import WarnData
|
|||||||
|
|
||||||
|
|
||||||
class ScriptLogger(Logger):
|
class ScriptLogger(Logger):
|
||||||
|
"""
|
||||||
|
Single value returned by specified script.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, command: list[str],
|
def __init__(self, command: list[str],
|
||||||
sensor_name: str,
|
sensor_name: str,
|
||||||
warn_if_above: float = None,
|
warn_if_above: float = None,
|
||||||
|
@ -11,6 +11,10 @@ from de.p1st.monitor.warn_data import WarnData
|
|||||||
|
|
||||||
|
|
||||||
class SwapLogger(Logger):
|
class SwapLogger(Logger):
|
||||||
|
"""
|
||||||
|
Used and total swap.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
warn_if_above: float = 1.0,
|
warn_if_above: float = 1.0,
|
||||||
warn_threshold: int = 1,
|
warn_threshold: int = 1,
|
||||||
|
@ -11,6 +11,10 @@ from de.p1st.monitor.warn_data import WarnData
|
|||||||
|
|
||||||
|
|
||||||
class TempLogger(Logger):
|
class TempLogger(Logger):
|
||||||
|
"""
|
||||||
|
Temperature of sensor.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, sensor_name: str,
|
def __init__(self, sensor_name: str,
|
||||||
sensor_label: str,
|
sensor_label: str,
|
||||||
warn_if_above: float = None,
|
warn_if_above: float = None,
|
||||||
|
Loading…
Reference in New Issue
Block a user