script
This commit is contained in:
@@ -71,6 +71,9 @@ async def submit_benchmark(
|
||||
|
||||
# RAM
|
||||
ram_total_mb=hw.ram.total_mb if hw.ram else None,
|
||||
ram_used_mb=hw.ram.used_mb if hw.ram else None, # NEW
|
||||
ram_free_mb=hw.ram.free_mb if hw.ram else None, # NEW
|
||||
ram_shared_mb=hw.ram.shared_mb if hw.ram else None, # NEW
|
||||
ram_slots_total=hw.ram.slots_total if hw.ram else None,
|
||||
ram_slots_used=hw.ram.slots_used if hw.ram else None,
|
||||
ram_ecc=hw.ram.ecc if hw.ram else None,
|
||||
@@ -128,6 +131,16 @@ async def submit_benchmark(
|
||||
if results.global_score is not None:
|
||||
global_score = results.global_score
|
||||
|
||||
# Extract network results for easier frontend access
|
||||
network_results = None
|
||||
if results.network:
|
||||
network_results = {
|
||||
"upload_mbps": results.network.upload_mbps if hasattr(results.network, 'upload_mbps') else None,
|
||||
"download_mbps": results.network.download_mbps if hasattr(results.network, 'download_mbps') else None,
|
||||
"ping_ms": results.network.ping_ms if hasattr(results.network, 'ping_ms') else None,
|
||||
"score": results.network.score
|
||||
}
|
||||
|
||||
benchmark = Benchmark(
|
||||
device_id=device.id,
|
||||
hardware_snapshot_id=snapshot.id,
|
||||
@@ -141,7 +154,8 @@ async def submit_benchmark(
|
||||
network_score=results.network.score if results.network else None,
|
||||
gpu_score=results.gpu.score if results.gpu else None,
|
||||
|
||||
details_json=json.dumps(results.dict())
|
||||
details_json=json.dumps(results.dict()),
|
||||
network_results_json=json.dumps(network_results) if network_results else None
|
||||
)
|
||||
|
||||
db.add(benchmark)
|
||||
|
||||
@@ -10,5 +10,6 @@ Base = declarative_base()
|
||||
from app.models.device import Device # noqa
|
||||
from app.models.hardware_snapshot import HardwareSnapshot # noqa
|
||||
from app.models.benchmark import Benchmark # noqa
|
||||
from app.models.disk_smart import DiskSMART # noqa
|
||||
from app.models.manufacturer_link import ManufacturerLink # noqa
|
||||
from app.models.document import Document # noqa
|
||||
|
||||
@@ -30,6 +30,7 @@ class Benchmark(Base):
|
||||
|
||||
# Details
|
||||
details_json = Column(Text, nullable=False) # JSON object with all raw results
|
||||
network_results_json = Column(Text, nullable=True) # Network benchmark details (iperf3)
|
||||
notes = Column(Text, nullable=True)
|
||||
|
||||
# Relationships
|
||||
|
||||
48
backend/app/models/disk_smart.py
Normal file
48
backend/app/models/disk_smart.py
Normal file
@@ -0,0 +1,48 @@
|
||||
"""
|
||||
Linux BenchTools - Disk SMART Data Model
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, Integer, String, Float, DateTime, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from app.db.base import Base
|
||||
|
||||
|
||||
class DiskSMART(Base):
|
||||
"""
|
||||
SMART health and aging data for storage devices
|
||||
"""
|
||||
__tablename__ = "disk_smart_data"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
hardware_snapshot_id = Column(Integer, ForeignKey("hardware_snapshots.id"), nullable=False, index=True)
|
||||
captured_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
|
||||
# Disk identification
|
||||
device_name = Column(String(50), nullable=False) # e.g., "sda", "nvme0n1"
|
||||
model = Column(String(255), nullable=True)
|
||||
serial_number = Column(String(100), nullable=True)
|
||||
size_gb = Column(Float, nullable=True)
|
||||
disk_type = Column(String(20), nullable=True) # "ssd" or "hdd"
|
||||
interface = Column(String(50), nullable=True) # "sata", "nvme", "usb"
|
||||
|
||||
# SMART Health Status
|
||||
health_status = Column(String(20), nullable=True) # "PASSED", "FAILED", or null
|
||||
temperature_celsius = Column(Integer, nullable=True)
|
||||
|
||||
# Aging indicators
|
||||
power_on_hours = Column(Integer, nullable=True)
|
||||
power_cycle_count = Column(Integer, nullable=True)
|
||||
reallocated_sectors = Column(Integer, nullable=True) # Critical: bad sectors
|
||||
pending_sectors = Column(Integer, nullable=True) # Very critical: imminent failure
|
||||
udma_crc_errors = Column(Integer, nullable=True) # Cable/interface issues
|
||||
|
||||
# SSD-specific
|
||||
wear_leveling_count = Column(Integer, nullable=True) # 0-100 (higher is better)
|
||||
total_lbas_written = Column(Float, nullable=True) # Total data written
|
||||
|
||||
# Relationship
|
||||
hardware_snapshot = relationship("HardwareSnapshot", back_populates="disk_smart_data")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<DiskSMART(id={self.id}, device='{self.device_name}', health='{self.health_status}')>"
|
||||
@@ -34,6 +34,9 @@ class HardwareSnapshot(Base):
|
||||
|
||||
# RAM
|
||||
ram_total_mb = Column(Integer, nullable=True)
|
||||
ram_used_mb = Column(Integer, nullable=True) # NEW: RAM utilisée
|
||||
ram_free_mb = Column(Integer, nullable=True) # NEW: RAM libre
|
||||
ram_shared_mb = Column(Integer, nullable=True) # NEW: RAM partagée (tmpfs/vidéo)
|
||||
ram_slots_total = Column(Integer, nullable=True)
|
||||
ram_slots_used = Column(Integer, nullable=True)
|
||||
ram_ecc = Column(Boolean, nullable=True)
|
||||
@@ -74,6 +77,7 @@ class HardwareSnapshot(Base):
|
||||
# Relationships
|
||||
device = relationship("Device", back_populates="hardware_snapshots")
|
||||
benchmarks = relationship("Benchmark", back_populates="hardware_snapshot")
|
||||
disk_smart_data = relationship("DiskSMART", back_populates="hardware_snapshot", cascade="all, delete-orphan")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<HardwareSnapshot(id={self.id}, device_id={self.device_id}, captured_at='{self.captured_at}')>"
|
||||
|
||||
@@ -35,6 +35,9 @@ class RAMSlot(BaseModel):
|
||||
class RAMInfo(BaseModel):
|
||||
"""RAM information schema"""
|
||||
total_mb: int
|
||||
used_mb: Optional[int] = None # NEW
|
||||
free_mb: Optional[int] = None # NEW
|
||||
shared_mb: Optional[int] = None # NEW
|
||||
slots_total: Optional[int] = None
|
||||
slots_used: Optional[int] = None
|
||||
ecc: Optional[bool] = None
|
||||
@@ -56,7 +59,7 @@ class StorageDevice(BaseModel):
|
||||
name: str
|
||||
type: Optional[str] = None
|
||||
interface: Optional[str] = None
|
||||
capacity_gb: Optional[int] = None
|
||||
capacity_gb: Optional[float] = None # Changed from int to float
|
||||
vendor: Optional[str] = None
|
||||
model: Optional[str] = None
|
||||
smart_health: Optional[str] = None
|
||||
|
||||
Reference in New Issue
Block a user