Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-132705 / 25.04 / Adopts middleware changes to CPU and memory reporting on the dashboard widgets #11317

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
14 changes: 12 additions & 2 deletions src/app/interfaces/reporting.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ export interface ReportingRealtimeUpdate {
}

export interface AllCpusUpdate {
[cpuNumber: number]: CpuUpdate;
average: CpuUpdate;
user: number;
nice: number;
system: number;
idle: number;
iowait: number;
irq: number;
softirq: number;
steal: number;
guest: number;
guest_nice: number;
aggregated_usage: number;
[key: `core${number}_usage`]: number;
temperature_celsius: number[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ export class AppResourcesCardComponent implements OnInit {
throttleTime(2000),
untilDestroyed(this),
).subscribe((update) => {
if (update?.cpu?.average) {
this.cpuPercentage.set(parseInt(update.cpu.average.usage.toFixed(1)));
if (update?.cpu?.aggregated_usage) {
this.cpuPercentage.set(parseInt(update.cpu.aggregated_usage.toFixed(1)));
}

if (update?.virtual_memory) {
Expand Down
1 change: 0 additions & 1 deletion src/app/pages/dashboard/services/get-default-widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const defaultWidgets: WidgetGroup[] = [
layout: WidgetGroupLayout.Halves,
slots: [
{ type: WidgetType.CpuUsageBar },
{ type: WidgetType.CpuTemperatureBar },
],
},
{
Expand Down
1 change: 0 additions & 1 deletion src/app/pages/dashboard/types/widget.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export enum WidgetType {
CpuUsageGauge = 'cpu-usage-gauge',
CpuUsageRecent = 'cpu-usage-recent',
CpuUsageBar = 'cpu-usage-bar',
CpuTemperatureBar = 'cpu-temperature-bar',
Storage = 'storage',
SystemInfoActive = 'system-info-active',
SystemInfoPassive = 'system-info-passive',
Expand Down
2 changes: 0 additions & 2 deletions src/app/pages/dashboard/widgets/all-widgets.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { appNetworkWidget } from 'app/pages/dashboard/widgets/apps/widget-app-ne
import { backupTasksWidget } from 'app/pages/dashboard/widgets/backup/widget-backup/widget-backup.definition';
import { cpuWidget } from 'app/pages/dashboard/widgets/cpu/widget-cpu/widget-cpu.definition';
import { cpuModelWidget } from 'app/pages/dashboard/widgets/cpu/widget-cpu-model/widget-cpu-model.definition';
import { cpuTemperatureBarWidget } from 'app/pages/dashboard/widgets/cpu/widget-cpu-temperature-bar/widget-cpu-temperature-bar.definition';
import { cpuUsageBarWidget } from 'app/pages/dashboard/widgets/cpu/widget-cpu-usage-bar/widget-cpu-usage-bar.definition';
import { cpuUsageGaugeWidget } from 'app/pages/dashboard/widgets/cpu/widget-cpu-usage-gauge/widget-cpu-usage-gauge.definition';
import { cpuUsageRecentWidget } from 'app/pages/dashboard/widgets/cpu/widget-cpu-usage-recent/widget-cpu-usage-recent.definition';
Expand Down Expand Up @@ -59,7 +58,6 @@ export const widgetRegistry = {
[WidgetType.CpuUsageGauge]: cpuUsageGaugeWidget,
[WidgetType.CpuUsageRecent]: cpuUsageRecentWidget,
[WidgetType.CpuUsageBar]: cpuUsageBarWidget,
[WidgetType.CpuTemperatureBar]: cpuTemperatureBarWidget,
[WidgetType.Storage]: storageWidget,
[WidgetType.SystemInfoActive]: systemInfoActiveWidget,
[WidgetType.SystemInfoPassive]: systemInfoPassiveWidget,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class CpuChartGaugeComponent {
protected isLoading = computed(() => !this.cpuData());

protected cpuAvg: Signal<GaugeConfig> = computed(() => {
const data = ['Load', parseInt(this.cpuData().average.usage.toFixed(1))];
const data = ['Load', parseInt(this.cpuData().aggregated_usage.toFixed(1))];
return {
label: false,
data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export class CpuCoreBarComponent {
protected isLoading = computed(() => !this.cpuData());
protected coreCount = computed(() => {
const cpus = Object.keys(this.cpuData())
.map(Number)
.filter((key) => key.startsWith('core'))
.map((key) => {
const splitCoreTitle = key.split('_')[0];
return Number(splitCoreTitle.replace('core', ''));
})
.filter((key) => !Number.isNaN(key));

return Math.max(...cpus) + 1;
Expand Down Expand Up @@ -118,7 +122,7 @@ export class CpuCoreBarComponent {
const temperatureColumn: GaugeData = ['Temperature'];

for (let i = 0; i < this.coreCount(); i++) {
const usage = parseInt(cpuData[i]?.usage?.toFixed(1) || '0');
const usage = parseInt(cpuData[`core${i}_usage`]?.toFixed(1) || '0');
const temperature = parseInt(cpuData.temperature_celsius?.[i]?.toFixed(0) || '0');

usageColumn.push(usage);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}

h3 {
margin-bottom: 10px;
padding: 16px 0 0;
width: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class WidgetCpuUsageRecentComponent implements WidgetComponent {
});

protected cpuUsage = toSignal(this.resources.realtimeUpdates$.pipe(
map((update) => update.fields.cpu.average),
map((update) => update.fields.cpu),
tap((realtimeUpdate) => {
this.cachedCpuStats.update((cachedStats) => {
return [...cachedStats, [realtimeUpdate.user, realtimeUpdate.system]].slice(-60);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class WidgetCpuComponent {
const temperatureColumn: GaugeData = ['Temperature'];

for (let i = 0; i < this.threadCount(); i++) {
usageColumn.push(parseInt(cpuData[i].usage.toFixed(1)));
usageColumn.push(parseInt(cpuData[`core${i}_usage`].toFixed(1)));
}

if (cpuData.temperature_celsius) {
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/br.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/dsb.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/en-au.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/eo.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/es-ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,6 @@
"CPU Recent Usage": "Uso reciente de CPU",
"CPU Reports": "Informes de CPU",
"CPU Stats": "Estadísticas de CPU",
"CPU Temperature Per Core": "Temperatura de la CPU por núcleo",
"CPU Usage": "Uso de CPU",
"CPU Usage Per Core": "Uso de CPU por núcleo",
"CPU Utilization": "Utilización de CPU",
Expand Down
1 change: 0 additions & 1 deletion src/assets/i18n/es-co.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,6 @@
"CPU Recent Usage": "",
"CPU Reports": "",
"CPU Stats": "",
"CPU Temperature Per Core": "",
"CPU Usage": "",
"CPU Usage Per Core": "",
"CPU Utilization": "",
Expand Down
Loading