mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-04-18 01:52:20 +00:00
Update notification service
This commit is contained in:
@@ -749,6 +749,7 @@ class JournalWatcher:
|
||||
"""Extract device info from a smartd system-mail and record as disk observation."""
|
||||
try:
|
||||
import re as _re
|
||||
import subprocess
|
||||
from health_persistence import health_persistence
|
||||
|
||||
# Extract device path: "Device: /dev/sdh [SAT]" or "Device: /dev/sda"
|
||||
@@ -769,6 +770,21 @@ class JournalWatcher:
|
||||
if model_match:
|
||||
model = model_match.group(1).strip()
|
||||
|
||||
# If no serial from message, try to get it from smartctl (important for USB disks)
|
||||
if not serial or len(serial) < 3:
|
||||
try:
|
||||
result = subprocess.run(
|
||||
['smartctl', '-i', '-j', f'/dev/{base_dev}'],
|
||||
capture_output=True, text=True, timeout=5
|
||||
)
|
||||
import json as _json
|
||||
data = _json.loads(result.stdout)
|
||||
serial = data.get('serial_number', '') or serial
|
||||
if not model:
|
||||
model = data.get('model_name', '') or data.get('model_family', '')
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Extract error signature from title: "SMART error (FailedReadSmartSelfTestLog)"
|
||||
sig_match = _re.search(r'SMART error\s*\((\w+)\)', title)
|
||||
if sig_match:
|
||||
|
||||
Reference in New Issue
Block a user