specified sata and nvme as the only devices to be monitored
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os, sys, json, requests, psutil, socket, subprocess, logging, argparse, urllib.request
|
import os, sys, json, requests, psutil, socket, subprocess, logging, argparse, urllib.request, re
|
||||||
from typing import Dict, Any, List
|
from typing import Dict, Any, List
|
||||||
|
|
||||||
# Create a logger
|
# Create a logger
|
||||||
@ -236,15 +236,24 @@ class SystemHealthMonitor:
|
|||||||
|
|
||||||
return issues
|
return issues
|
||||||
|
|
||||||
|
def _is_physical_disk(self, device_path):
|
||||||
|
"""
|
||||||
|
Check if the device is a physical SATA or NVMe disk.
|
||||||
|
|
||||||
|
:param device_path: Path to the device
|
||||||
|
:return: Boolean indicating if it's a physical disk
|
||||||
|
"""
|
||||||
|
return bool(re.match(r'/dev/(sd[a-z]|nvme\d+n\d+)', device_path))
|
||||||
|
|
||||||
def _check_drives_health(self) -> Dict[str, Any]:
|
def _check_drives_health(self) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Check overall health of drives including disk usage and SMART status.
|
Check overall health of physical SATA and NVMe drives including disk usage and SMART status.
|
||||||
|
|
||||||
:return: Combined health report of all drives and their status.
|
:return: Combined health report of all drives and their status.
|
||||||
"""
|
"""
|
||||||
drives_health = {'overall_status': 'NORMAL', 'drives': []}
|
drives_health = {'overall_status': 'NORMAL', 'drives': []}
|
||||||
try:
|
try:
|
||||||
partitions = psutil.disk_partitions()
|
partitions = [p for p in psutil.disk_partitions() if self._is_physical_disk(p.device)]
|
||||||
overall_status = 'NORMAL'
|
overall_status = 'NORMAL'
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
drive_report = {
|
drive_report = {
|
||||||
|
|||||||
Reference in New Issue
Block a user