Skip to content

Lightweight server monitoring with historical data, docker stats, and alerts.

feat(site): display NVMe data units as human-readable GB/TB (#2303)

Matthew D'Souzaad24484caabf
diff --git a/internal/site/src/components/routes/system/smart-table.tsx b/internal/site/src/components/routes/system/smart-table.tsx
index d6ec6730d..2efeb7910 100644
--- a/internal/site/src/components/routes/system/smart-table.tsx
+++ b/internal/site/src/components/routes/system/smart-table.tsx
@@ -75,7 +75,12 @@ export const smartColumns: ColumnDef<SmartAttribute>[] = [
header: "Name",
},
{
- accessorFn: (row) => row.rs || row.rv?.toString(),
+ accessorFn: (row) => {
+ if (row.n === "DataUnitsWritten" || row.n === "DataUnitsRead") {
+ return formatDataUnits(Number(row.rv ?? 0))
+ }
+ return row.rs || row.rv?.toString()
+ },
header: "Value",
},
{
@@ -103,6 +108,12 @@ function formatCapacity(bytes: number): string {
return `${toFixedFloat(value, value >= 10 ? 1 : 2)} ${unit}`
}
+// Function to format NVMe data units
+// (1 unit = 1000 * 512 bytes) as a human-readable size
+function formatDataUnits(units: number): string {
+ return formatCapacity(units * 1000 * 512)
+}
+
const SMART_DEVICE_FIELDS = "id,system,name,model,state,capacity,temp,type,hours,cycles,updated"
export const createColumns = (