Show available RAM and measured CPU usage for devices
Rust development slice / linux (push) Failing after 8s
Rust development slice / linux (push) Failing after 8s
This commit is contained in:
+17
-4
@@ -43,6 +43,15 @@ function capacity(free: unknown, total: unknown) {
|
||||
t = gib(total);
|
||||
return f === null && t === null ? unknown : `${f ?? '–'} / ${t ?? '–'} GiB`;
|
||||
}
|
||||
function cpuUsage(value: unknown) {
|
||||
return typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 100
|
||||
? `${number.format(value)} %`
|
||||
: unknown;
|
||||
}
|
||||
function measuredAt(value: unknown) {
|
||||
const observed = time(value);
|
||||
return observed === unknown ? undefined : `Gemessen am ${observed}`;
|
||||
}
|
||||
function cpu(d: RecordValue) {
|
||||
const model = label(d.cpu_model),
|
||||
count = d.cpu_logical_count;
|
||||
@@ -171,8 +180,9 @@ function DeviceDetail({
|
||||
['Kunde', label(d.customer_name)],
|
||||
['Type', label(d.device_type)],
|
||||
['Betriebssystem', label(d.os)],
|
||||
['RAM', gib(d.ram_total_bytes) === null ? unknown : gib(d.ram_total_bytes) + ' GiB'],
|
||||
['RAM frei / gesamt', capacity(d.ram_available_bytes, d.ram_total_bytes)],
|
||||
['CPU', [cpu(d).primary, cpu(d).secondary].filter(Boolean).join(' · ')],
|
||||
['CPU-Auslastung', [cpuUsage(d.cpu_usage_percent), measuredAt(d.cpu_usage_observed_at)].filter(Boolean).join(' · ')],
|
||||
['Speicher frei / gesamt', capacity(d.disk_free_bytes, d.disk_total_bytes)],
|
||||
['Letzter Kontakt', time(d.last_contact_at)],
|
||||
['Inventar erhoben', time(d.observed_at)],
|
||||
@@ -534,7 +544,7 @@ export function Devices({
|
||||
<span className="sr-only">Ziel auswählen</span>
|
||||
</th>
|
||||
)}
|
||||
{['Hostname', 'Type', 'OS', 'Status', 'Speicher frei / gesamt', 'RAM', 'CPU', 'Kunde'].map(
|
||||
{['Hostname', 'Type', 'OS', 'Status', 'Speicher frei / gesamt', 'RAM frei / gesamt', 'CPU', 'Kunde'].map(
|
||||
(h) => (
|
||||
<th scope="col" key={h}>
|
||||
{h}
|
||||
@@ -594,12 +604,15 @@ export function Devices({
|
||||
<td data-label="Speicher frei / gesamt" className="storage">
|
||||
<Storage d={d} />
|
||||
</td>
|
||||
<td data-label="RAM">
|
||||
{gib(d.ram_total_bytes) === null ? unknown : gib(d.ram_total_bytes) + ' GiB'}
|
||||
<td data-label="RAM frei / gesamt" title={measuredAt(d.ram_observed_at)}>
|
||||
{capacity(d.ram_available_bytes, d.ram_total_bytes)}
|
||||
</td>
|
||||
<td data-label="CPU">
|
||||
{model.primary}
|
||||
{model.secondary && <small>{model.secondary}</small>}
|
||||
<small title={measuredAt(d.cpu_usage_observed_at)}>
|
||||
Auslastung {cpuUsage(d.cpu_usage_percent)}
|
||||
</small>
|
||||
</td>
|
||||
<td data-label="Kunde">{label(d.customer_name)}</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user