Fix critical UI and data export issues #327
@@ -750,6 +750,7 @@ async function collectMetrics(host: SSHHostWithCredentials): Promise<{
|
|||||||
let diskPercent: number | null = null;
|
let diskPercent: number | null = null;
|
||||||
let usedHuman: string | null = null;
|
let usedHuman: string | null = null;
|
||||||
let totalHuman: string | null = null;
|
let totalHuman: string | null = null;
|
||||||
|
let availableHuman: string | null = null;
|
||||||
try {
|
try {
|
||||||
const [diskOutHuman, diskOutBytes] = await Promise.all([
|
const [diskOutHuman, diskOutBytes] = await Promise.all([
|
||||||
execCommand(client, "df -h -P / | tail -n +2"),
|
execCommand(client, "df -h -P / | tail -n +2"),
|
||||||
@@ -773,6 +774,7 @@ async function collectMetrics(host: SSHHostWithCredentials): Promise<{
|
|||||||
if (humanParts.length >= 6 && bytesParts.length >= 6) {
|
if (humanParts.length >= 6 && bytesParts.length >= 6) {
|
||||||
totalHuman = humanParts[1] || null;
|
totalHuman = humanParts[1] || null;
|
||||||
usedHuman = humanParts[2] || null;
|
usedHuman = humanParts[2] || null;
|
||||||
|
availableHuman = humanParts[3] || null; // Parse Available column from df output
|
||||||
|
|
||||||
const totalBytes = Number(bytesParts[1]);
|
const totalBytes = Number(bytesParts[1]);
|
||||||
const usedBytes = Number(bytesParts[2]);
|
const usedBytes = Number(bytesParts[2]);
|
||||||
@@ -796,6 +798,7 @@ async function collectMetrics(host: SSHHostWithCredentials): Promise<{
|
|||||||
diskPercent = null;
|
diskPercent = null;
|
||||||
usedHuman = null;
|
usedHuman = null;
|
||||||
totalHuman = null;
|
totalHuman = null;
|
||||||
|
availableHuman = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
@@ -805,7 +808,12 @@ async function collectMetrics(host: SSHHostWithCredentials): Promise<{
|
|||||||
usedGiB: usedGiB ? toFixedNum(usedGiB, 2) : null,
|
usedGiB: usedGiB ? toFixedNum(usedGiB, 2) : null,
|
||||||
totalGiB: totalGiB ? toFixedNum(totalGiB, 2) : null,
|
totalGiB: totalGiB ? toFixedNum(totalGiB, 2) : null,
|
||||||
},
|
},
|
||||||
disk: { percent: toFixedNum(diskPercent, 0), usedHuman, totalHuman },
|
disk: {
|
||||||
|
percent: toFixedNum(diskPercent, 0),
|
||||||
|
usedHuman,
|
||||||
|
totalHuman,
|
||||||
|
availableHuman, // Include available space in response
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
metricsCache.set(host.id, result);
|
metricsCache.set(host.id, result);
|
||||||
|
|||||||
@@ -434,10 +434,9 @@ export function Server({
|
|||||||
|
|
||||||
<div className="text-xs text-gray-500">
|
<div className="text-xs text-gray-500">
|
||||||
{(() => {
|
{(() => {
|
||||||
const used = metrics?.disk?.usedHuman;
|
const available = metrics?.disk?.availableHuman;
|
||||||
const total = metrics?.disk?.totalHuman;
|
return available
|
||||||
return used && total
|
? `Available: ${available}`
|
||||||
? `Available: ${total}`
|
|
||||||
: "Available: N/A";
|
: "Available: N/A";
|
||||||
})()}
|
})()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ interface DiskMetrics {
|
|||||||
percent: number | null;
|
percent: number | null;
|
||||||
usedHuman: string | null;
|
usedHuman: string | null;
|
||||||
totalHuman: string | null;
|
totalHuman: string | null;
|
||||||
|
availableHuman?: string | null; // Available disk space from df output
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ServerMetrics = {
|
export type ServerMetrics = {
|
||||||
|
|||||||
Reference in New Issue
Block a user