Update AppImage

This commit is contained in:
MacRimi
2025-10-14 09:15:44 +02:00
parent e4da9f5afe
commit 2f700d9a4c
2 changed files with 332 additions and 8 deletions

View File

@@ -4,6 +4,8 @@ import { useState, useEffect } from "react"
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card" import { Card, CardContent, CardHeader, CardTitle } from "./ui/card"
import { Progress } from "./ui/progress" import { Progress } from "./ui/progress"
import { Badge } from "./ui/badge" import { Badge } from "./ui/badge"
import { Button } from "./ui/button"
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "./ui/dialog"
import { import {
HardDrive, HardDrive,
Database, Database,
@@ -13,6 +15,7 @@ import {
Activity, Activity,
AlertCircle, AlertCircle,
Thermometer, Thermometer,
Info,
} from "lucide-react" } from "lucide-react"
interface StorageData { interface StorageData {
@@ -33,6 +36,19 @@ interface DiskInfo {
health: string health: string
temperature: number temperature: number
disk_type?: string disk_type?: string
model?: string
serial?: string
smart_status?: string
power_on_hours?: number
power_cycles?: number
reallocated_sectors?: number
pending_sectors?: number
crc_errors?: number
percentage_used?: number // NVMe
ssd_life_left?: number // SSD
wear_leveling_count?: number // SSD
media_wearout_indicator?: number // SSD
total_lbas_written?: number // Both
} }
const TEMP_THRESHOLDS = { const TEMP_THRESHOLDS = {
@@ -74,6 +90,13 @@ const getDiskTypeBadgeColor = (diskType: string): string => {
} }
} }
const getWearStatus = (lifeLeft: number): { status: string; color: string } => {
if (lifeLeft >= 80) return { status: "Excellent", color: "text-green-500" }
if (lifeLeft >= 50) return { status: "Good", color: "text-yellow-500" }
if (lifeLeft >= 20) return { status: "Fair", color: "text-orange-500" }
return { status: "Poor", color: "text-red-500" }
}
const fetchStorageData = async (): Promise<StorageData | null> => { const fetchStorageData = async (): Promise<StorageData | null> => {
try { try {
const response = await fetch("/api/storage", { const response = await fetch("/api/storage", {
@@ -100,6 +123,9 @@ export function StorageMetrics() {
const [storageData, setStorageData] = useState<StorageData | null>(null) const [storageData, setStorageData] = useState<StorageData | null>(null)
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(null) const [error, setError] = useState<string | null>(null)
const [selectedDisk, setSelectedDisk] = useState<DiskInfo | null>(null)
const [showDiskDetails, setShowDiskDetails] = useState(false)
const [showTempInfo, setShowTempInfo] = useState(false)
useEffect(() => { useEffect(() => {
const fetchData = async () => { const fetchData = async () => {
@@ -171,7 +197,7 @@ export function StorageMetrics() {
const status = getTempStatus(avgTemp, type) const status = getTempStatus(avgTemp, type)
return { type, avgTemp: Math.round(avgTemp), status, count: disks.length } return { type, avgTemp: Math.round(avgTemp), status, count: disks.length }
}) })
.filter((item) => item.type !== "Unknown") // Filter out unknown types .filter((item) => item.type !== "Unknown")
return ( return (
<div className="space-y-6"> <div className="space-y-6">
@@ -251,9 +277,14 @@ export function StorageMetrics() {
<Thermometer className="h-5 w-5 mr-2" /> <Thermometer className="h-5 w-5 mr-2" />
Avg Temperature Avg Temperature
</div> </div>
<div className="flex items-center gap-2">
<Badge variant="outline" className={getDiskTypeBadgeColor(type)}> <Badge variant="outline" className={getDiskTypeBadgeColor(type)}>
{type} {type}
</Badge> </Badge>
<Button variant="ghost" size="icon" className="h-6 w-6" onClick={() => setShowTempInfo(true)}>
<Info className="h-4 w-4" />
</Button>
</div>
</CardTitle> </CardTitle>
</CardHeader> </CardHeader>
<CardContent> <CardContent>
@@ -295,10 +326,33 @@ export function StorageMetrics() {
const diskType = disk.disk_type || "HDD" const diskType = disk.disk_type || "HDD"
const tempStatus = getTempStatus(disk.temperature, diskType) const tempStatus = getTempStatus(disk.temperature, diskType)
let lifeLeft: number | null = null
let wearLabel = ""
if (diskType === "NVMe" && disk.percentage_used !== undefined && disk.percentage_used !== null) {
lifeLeft = 100 - disk.percentage_used
wearLabel = "Life Left"
} else if (diskType === "SSD") {
if (disk.ssd_life_left !== undefined && disk.ssd_life_left !== null) {
lifeLeft = disk.ssd_life_left
wearLabel = "Life Left"
} else if (disk.media_wearout_indicator !== undefined && disk.media_wearout_indicator !== null) {
lifeLeft = disk.media_wearout_indicator
wearLabel = "Health"
} else if (disk.wear_leveling_count !== undefined && disk.wear_leveling_count !== null) {
lifeLeft = disk.wear_leveling_count
wearLabel = "Wear Level"
}
}
return ( return (
<div <div
key={index} key={index}
className="flex items-center justify-between p-4 rounded-lg border border-border bg-card/50" className="flex items-center justify-between p-4 rounded-lg border border-border bg-card/50 cursor-pointer hover:bg-card/80 transition-colors"
onClick={() => {
setSelectedDisk(disk)
setShowDiskDetails(true)
}}
> >
<div className="flex items-center space-x-4"> <div className="flex items-center space-x-4">
<HardDrive className="h-5 w-5 text-muted-foreground" /> <HardDrive className="h-5 w-5 text-muted-foreground" />
@@ -330,6 +384,15 @@ export function StorageMetrics() {
<div className={`text-sm font-medium ${getTempColor(tempStatus)}`}>{disk.temperature}°C</div> <div className={`text-sm font-medium ${getTempColor(tempStatus)}`}>{disk.temperature}°C</div>
</div> </div>
{lifeLeft !== null && (diskType === "SSD" || diskType === "NVMe") && (
<div className="text-center">
<div className="text-sm text-muted-foreground">{wearLabel}</div>
<div className={`text-sm font-medium ${getWearStatus(lifeLeft).color}`}>
{lifeLeft.toFixed(0)}%
</div>
</div>
)}
<Badge <Badge
variant="outline" variant="outline"
className={ className={
@@ -352,6 +415,233 @@ export function StorageMetrics() {
</div> </div>
</CardContent> </CardContent>
</Card> </Card>
<Dialog open={showTempInfo} onOpenChange={setShowTempInfo}>
<DialogContent className="max-w-2xl">
<DialogHeader>
<DialogTitle>Temperature Thresholds by Disk Type</DialogTitle>
<DialogDescription>
Recommended operating temperature ranges for different storage devices
</DialogDescription>
</DialogHeader>
<div className="space-y-4">
<div className="overflow-x-auto">
<table className="w-full border-collapse">
<thead>
<tr className="border-b border-border">
<th className="text-left p-3 font-semibold">Disk Type</th>
<th className="text-left p-3 font-semibold">Safe Zone</th>
<th className="text-left p-3 font-semibold">Warning Zone</th>
<th className="text-left p-3 font-semibold">Critical Zone</th>
</tr>
</thead>
<tbody>
<tr className="border-b border-border">
<td className="p-3">
<Badge variant="outline" className={getDiskTypeBadgeColor("HDD")}>
HDD
</Badge>
</td>
<td className="p-3 text-green-500"> 45°C</td>
<td className="p-3 text-yellow-500">46 55°C</td>
<td className="p-3 text-red-500">&gt; 55°C</td>
</tr>
<tr className="border-b border-border">
<td className="p-3">
<Badge variant="outline" className={getDiskTypeBadgeColor("SSD")}>
SSD
</Badge>
</td>
<td className="p-3 text-green-500"> 55°C</td>
<td className="p-3 text-yellow-500">56 65°C</td>
<td className="p-3 text-red-500">&gt; 65°C</td>
</tr>
<tr>
<td className="p-3">
<Badge variant="outline" className={getDiskTypeBadgeColor("NVMe")}>
NVMe
</Badge>
</td>
<td className="p-3 text-green-500"> 60°C</td>
<td className="p-3 text-yellow-500">61 70°C</td>
<td className="p-3 text-red-500">&gt; 70°C</td>
</tr>
</tbody>
</table>
</div>
<p className="text-sm text-muted-foreground">
These thresholds are based on industry standards and manufacturer recommendations. Operating within the
safe zone ensures optimal performance and longevity.
</p>
</div>
</DialogContent>
</Dialog>
<Dialog open={showDiskDetails} onOpenChange={setShowDiskDetails}>
<DialogContent className="max-w-3xl">
{selectedDisk && (
<>
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
<HardDrive className="h-5 w-5" />
Disk Details: {selectedDisk.name}
</DialogTitle>
<DialogDescription>Complete SMART information and health status</DialogDescription>
</DialogHeader>
<div className="space-y-6">
{/* Basic Info */}
<div className="grid grid-cols-2 gap-4">
<div>
<div className="text-sm text-muted-foreground">Model</div>
<div className="font-medium">{selectedDisk.model || "Unknown"}</div>
</div>
<div>
<div className="text-sm text-muted-foreground">Serial Number</div>
<div className="font-medium">{selectedDisk.serial || "Unknown"}</div>
</div>
<div>
<div className="text-sm text-muted-foreground">Capacity</div>
<div className="font-medium">{selectedDisk.total.toFixed(1)}G</div>
</div>
<div>
<div className="text-sm text-muted-foreground">Health Status</div>
<Badge
variant="outline"
className={
selectedDisk.health === "healthy"
? "bg-green-500/10 text-green-500 border-green-500/20"
: "bg-yellow-500/10 text-yellow-500 border-yellow-500/20"
}
>
{selectedDisk.health === "healthy" ? "Healthy" : "Warning"}
</Badge>
</div>
</div>
{(selectedDisk.disk_type === "SSD" || selectedDisk.disk_type === "NVMe") && (
<div className="border-t border-border pt-4">
<h3 className="font-semibold mb-3">Wear & Life Indicators</h3>
<div className="grid grid-cols-2 gap-4">
{selectedDisk.disk_type === "NVMe" &&
selectedDisk.percentage_used !== undefined &&
selectedDisk.percentage_used !== null && (
<>
<div>
<div className="text-sm text-muted-foreground">Percentage Used</div>
<div
className={`text-lg font-bold ${getWearStatus(100 - selectedDisk.percentage_used).color}`}
>
{selectedDisk.percentage_used}%
</div>
</div>
<div>
<div className="text-sm text-muted-foreground">Life Remaining</div>
<div
className={`text-lg font-bold ${getWearStatus(100 - selectedDisk.percentage_used).color}`}
>
{(100 - selectedDisk.percentage_used).toFixed(0)}%
</div>
<Progress value={100 - selectedDisk.percentage_used} className="mt-2" />
</div>
</>
)}
{selectedDisk.disk_type === "SSD" && (
<>
{selectedDisk.ssd_life_left !== undefined && selectedDisk.ssd_life_left !== null && (
<div>
<div className="text-sm text-muted-foreground">SSD Life Left</div>
<div className={`text-lg font-bold ${getWearStatus(selectedDisk.ssd_life_left).color}`}>
{selectedDisk.ssd_life_left}%
</div>
<Progress value={selectedDisk.ssd_life_left} className="mt-2" />
</div>
)}
{selectedDisk.wear_leveling_count !== undefined &&
selectedDisk.wear_leveling_count !== null && (
<div>
<div className="text-sm text-muted-foreground">Wear Leveling Count</div>
<div
className={`text-lg font-bold ${getWearStatus(selectedDisk.wear_leveling_count).color}`}
>
{selectedDisk.wear_leveling_count}
</div>
</div>
)}
{selectedDisk.media_wearout_indicator !== undefined &&
selectedDisk.media_wearout_indicator !== null && (
<div>
<div className="text-sm text-muted-foreground">Media Wearout Indicator</div>
<div
className={`text-lg font-bold ${getWearStatus(selectedDisk.media_wearout_indicator).color}`}
>
{selectedDisk.media_wearout_indicator}
</div>
<Progress value={selectedDisk.media_wearout_indicator} className="mt-2" />
</div>
)}
</>
)}
{selectedDisk.total_lbas_written !== undefined && selectedDisk.total_lbas_written !== null && (
<div>
<div className="text-sm text-muted-foreground">Total Data Written</div>
<div className="font-medium">{(selectedDisk.total_lbas_written / 1000000).toFixed(2)} TB</div>
</div>
)}
</div>
</div>
)}
{/* SMART Attributes */}
<div className="border-t border-border pt-4">
<h3 className="font-semibold mb-3">SMART Attributes</h3>
<div className="grid grid-cols-2 gap-4">
<div>
<div className="text-sm text-muted-foreground">Temperature</div>
<div
className={`font-medium ${getTempColor(getTempStatus(selectedDisk.temperature, selectedDisk.disk_type || "HDD"))}`}
>
{selectedDisk.temperature}°C
</div>
</div>
<div>
<div className="text-sm text-muted-foreground">Power On Hours</div>
<div className="font-medium">
{selectedDisk.power_on_hours
? `${selectedDisk.power_on_hours}h (${Math.floor(selectedDisk.power_on_hours / 24)}d)`
: "N/A"}
</div>
</div>
<div>
<div className="text-sm text-muted-foreground">Rotation Rate</div>
<div className="font-medium">{selectedDisk.disk_type || "Unknown"}</div>
</div>
<div>
<div className="text-sm text-muted-foreground">Power Cycles</div>
<div className="font-medium">{selectedDisk.power_cycles || 0}</div>
</div>
<div>
<div className="text-sm text-muted-foreground">SMART Status</div>
<div className="font-medium">{selectedDisk.smart_status === "passed" ? "Passed" : "Unknown"}</div>
</div>
<div>
<div className="text-sm text-muted-foreground">Reallocated Sectors</div>
<div className="font-medium">{selectedDisk.reallocated_sectors || 0}</div>
</div>
<div>
<div className="text-sm text-muted-foreground">Pending Sectors</div>
<div className="font-medium">{selectedDisk.pending_sectors || 0}</div>
</div>
<div>
<div className="text-sm text-muted-foreground">CRC Errors</div>
<div className="font-medium">{selectedDisk.crc_errors || 0}</div>
</div>
</div>
</div>
</div>
</>
)}
</DialogContent>
</Dialog>
</div> </div>
) )
} }

View File

@@ -537,7 +537,13 @@ def get_storage_info():
'crc_errors': smart_data.get('crc_errors', 0), 'crc_errors': smart_data.get('crc_errors', 0),
'rotation_rate': smart_data.get('rotation_rate', 0), # Added 'rotation_rate': smart_data.get('rotation_rate', 0), # Added
'power_cycles': smart_data.get('power_cycles', 0), # Added 'power_cycles': smart_data.get('power_cycles', 0), # Added
'disk_type': smart_data.get('disk_type', 'Unknown') # Added from get_smart_data 'disk_type': smart_data.get('disk_type', 'Unknown'), # Added from get_smart_data
# Added wear indicators
'percentage_used': smart_data.get('percentage_used'),
'ssd_life_left': smart_data.get('ssd_life_left'),
'wear_leveling_count': smart_data.get('wear_leveling_count'),
'media_wearout_indicator': smart_data.get('media_wearout_indicator'),
'total_lbas_written': smart_data.get('total_lbas_written'),
} }
storage_data['disk_count'] += 1 storage_data['disk_count'] += 1
@@ -657,6 +663,11 @@ def get_smart_data(disk_name):
'rotation_rate': 0, # Added rotation rate (RPM) 'rotation_rate': 0, # Added rotation rate (RPM)
'power_cycles': 0, # Added power cycle count 'power_cycles': 0, # Added power cycle count
'disk_type': 'Unknown', # Will be 'HDD', 'SSD', or 'NVMe' 'disk_type': 'Unknown', # Will be 'HDD', 'SSD', or 'NVMe'
'percentage_used': None, # NVMe specific
'ssd_life_left': None, # SSD specific (percentage remaining)
'wear_leveling_count': None, # SSD specific
'media_wearout_indicator': None, # SSD specific
'total_lbas_written': None, # Both SSD and NVMe
} }
print(f"[v0] ===== Starting SMART data collection for /dev/{disk_name} =====") print(f"[v0] ===== Starting SMART data collection for /dev/{disk_name} =====")
@@ -753,6 +764,7 @@ def get_smart_data(disk_name):
for attr in data['ata_smart_attributes']['table']: for attr in data['ata_smart_attributes']['table']:
attr_id = attr.get('id') attr_id = attr.get('id')
raw_value = attr.get('raw', {}).get('value', 0) raw_value = attr.get('raw', {}).get('value', 0)
normalized_value = attr.get('value', 0)
if attr_id == 9: # Power_On_Hours if attr_id == 9: # Power_On_Hours
smart_data['power_on_hours'] = raw_value smart_data['power_on_hours'] = raw_value
@@ -777,6 +789,22 @@ def get_smart_data(disk_name):
elif attr_id == 199: # UDMA_CRC_Error_Count elif attr_id == 199: # UDMA_CRC_Error_Count
smart_data['crc_errors'] = raw_value smart_data['crc_errors'] = raw_value
print(f"[v0] CRC Errors (ID 199): {raw_value}") print(f"[v0] CRC Errors (ID 199): {raw_value}")
elif attr_id == 177: # Wear_Leveling_Count
smart_data['wear_leveling_count'] = normalized_value
print(f"[v0] Wear Leveling Count (ID 177): {normalized_value}")
elif attr_id == 231: # SSD_Life_Left or Temperature
if normalized_value <= 100: # Likely life left percentage
smart_data['ssd_life_left'] = normalized_value
print(f"[v0] SSD Life Left (ID 231): {normalized_value}%")
elif attr_id == 233: # Media_Wearout_Indicator
smart_data['media_wearout_indicator'] = normalized_value
print(f"[v0] Media Wearout Indicator (ID 233): {normalized_value}")
elif attr_id == 202: # Percent_Lifetime_Remain
smart_data['ssd_life_left'] = normalized_value
print(f"[v0] Percent Lifetime Remain (ID 202): {normalized_value}%")
elif attr_id == 241: # Total_LBAs_Written
smart_data['total_lbas_written'] = raw_value
print(f"[v0] Total LBAs Written (ID 241): {raw_value}")
# Parse NVMe SMART data # Parse NVMe SMART data
if 'nvme_smart_health_information_log' in data: if 'nvme_smart_health_information_log' in data:
@@ -791,6 +819,12 @@ def get_smart_data(disk_name):
if 'power_cycles' in nvme_data: if 'power_cycles' in nvme_data:
smart_data['power_cycles'] = nvme_data['power_cycles'] smart_data['power_cycles'] = nvme_data['power_cycles']
print(f"[v0] NVMe Power Cycles: {smart_data['power_cycles']}") print(f"[v0] NVMe Power Cycles: {smart_data['power_cycles']}")
if 'percentage_used' in nvme_data:
smart_data['percentage_used'] = nvme_data['percentage_used']
print(f"[v0] NVMe Percentage Used: {smart_data['percentage_used']}%")
if 'data_units_written' in nvme_data:
smart_data['total_lbas_written'] = nvme_data['data_units_written']
print(f"[v0] NVMe Data Units Written: {smart_data['total_lbas_written']}")
# If we got good data, break out of the loop # If we got good data, break out of the loop
if smart_data['model'] != 'Unknown' and smart_data['serial'] != 'Unknown': if smart_data['model'] != 'Unknown' and smart_data['serial'] != 'Unknown':
@@ -1370,7 +1404,7 @@ def get_network_info():
} }
def get_proxmox_vms(): def get_proxmox_vms():
"""Get Proxmox VM and LXC information (requires pvesh command) - only from local node""" """Get Proxmox VM and LXC information using pvesh command - only from local node"""
try: try:
all_vms = [] all_vms = []