From adafa796f1bdd48ddf00661ed9debd7fc4fe8548 Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sun, 9 Mar 2025 22:17:10 -0400 Subject: [PATCH] adjusted lxc storage --- hwmonDaemon.py | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/hwmonDaemon.py b/hwmonDaemon.py index 37dc0ca..0c55d24 100644 --- a/hwmonDaemon.py +++ b/hwmonDaemon.py @@ -1413,29 +1413,17 @@ class SystemHealthMonitor: try: if parts[0].startswith('appPool:') or '/mnt/pve/mediaf' in parts[0]: continue - + filesystem = { 'mountpoint': parts[5], - 'total_space': parts[1], # Size - 'used_space': parts[2], # Used - 'available': parts[3], # Avail - 'usage_percent': float(parts[4].rstrip('%')) # Use% + 'total_space': self._parse_size(parts[1]), # Convert size to bytes + 'used_space': self._parse_size(parts[2]), # Convert used to bytes + 'available': self._parse_size(parts[3]), # Convert available to bytes + 'usage_percent': float(parts[4].rstrip('%')) # Use percentage as is } container_info['filesystems'].append(filesystem) - logger.debug(f"Usage percent before threshold check: {usage_percent}") - logger.debug(f"LXC_WARNING threshold: {self.CONFIG['THRESHOLDS']['LXC_WARNING']}") - logger.debug(f"LXC_CRITICAL threshold: {self.CONFIG['THRESHOLDS']['LXC_CRITICAL']}") - - # Convert sizes to bytes for comparison - total_bytes = self._parse_size(filesystem['total_space']) - used_bytes = self._parse_size(filesystem['used_space']) - avail_bytes = self._parse_size(filesystem['available']) - - # Store both human readable and byte values - filesystem['total_bytes'] = self._parse_size(filesystem['total_space']) - filesystem['used_bytes'] = self._parse_size(filesystem['used_space']) - filesystem['avail_bytes'] = self._parse_size(filesystem['available']) + # Check thresholds if filesystem['usage_percent'] >= self.CONFIG['THRESHOLDS']['LXC_CRITICAL']: lxc_health['status'] = 'CRITICAL' issue = f"LXC {vmid} critical storage usage: {filesystem['usage_percent']}% on {filesystem['mountpoint']}" @@ -1445,16 +1433,12 @@ class SystemHealthMonitor: lxc_health['status'] = 'WARNING' issue = f"LXC {vmid} high storage usage: {filesystem['usage_percent']}% on {filesystem['mountpoint']}" lxc_health['issues'].append(issue) - + logger.debug(f"Filesystem details: {filesystem}") - logger.debug(f"Usage percent: {filesystem['usage_percent']}%") - logger.debug(f"LXC_WARNING threshold: {self.CONFIG['THRESHOLDS']['LXC_WARNING']}%") - logger.debug(f"LXC_CRITICAL threshold: {self.CONFIG['THRESHOLDS']['LXC_CRITICAL']}%") except Exception as e: logger.debug(f"Error processing line: {str(e)}") logger.debug(f"Full exception: {repr(e)}") continue - lxc_health['containers'].append(container_info) logger.debug(f"Added container info for VMID {vmid}")