Skip to content

Commit b2abaa2

Browse files
committed
fix: update memory metrics calculation and improve health settings page translations
- Adjusted the calculation of native memory metrics in the health snapshot service to reflect that array buffers are included in external memory usage. - Improved French translations for health settings page, ensuring clarity in user interface messages. - Added new computed properties for total system memory and CPU cores to enhance health metrics reporting.
1 parent c332f9e commit b2abaa2

File tree

2 files changed

+65
-10
lines changed

2 files changed

+65
-10
lines changed

apps/api/src/core/health/health-snapshot.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export class HealthSnapshotService {
9696
const rssIndicator = this.checkMemoryRss().memory_rss
9797
const externalMb = Number((memoryUsage.external / MEMORY_MULTIPLIER).toFixed(2))
9898
const arrayBuffersMb = Number((memoryUsage.arrayBuffers / MEMORY_MULTIPLIER).toFixed(2))
99-
const nativeMb = Number((externalMb + arrayBuffersMb).toFixed(2))
99+
// `arrayBuffers` is already included in `external` in Node.js memoryUsage.
100+
const nativeMb = externalMb
100101
const memoryNativeIndicator = this.buildMemoryNativeIndicator(nativeMb, externalMb, arrayBuffersMb)
101102

102103
const details = {

apps/web/src/pages/settings/health.vue

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
autoresize
4646
style='height: 260px; width: 100%;'
4747
)
48-
.text-caption.text-grey-7.q-pa-sm(v-else) Donnees insuffisantes pour tracer une tendance (attente de nouveaux echantillons SSE).
48+
.text-caption.text-grey-7.q-pa-sm(v-else) Données insuffisantes pour tracer une tendance.
4949

5050
q-card.q-mb-md(flat bordered)
5151
q-card-section.row.items-center.justify-between
@@ -141,7 +141,7 @@
141141
autoresize
142142
style='height: 30px; width: 90px;'
143143
)
144-
span.text-caption.text-grey-6(v-else) Donnees insuffisantes
144+
span.text-caption.text-grey-6(v-else) Données insuffisantes
145145

146146
.row.q-col-gutter-md.q-mt-sm(v-if='systemCards.length')
147147
.col-12.col-md-6(v-for='card in systemCards' :key='card.key')
@@ -159,7 +159,7 @@
159159
row-key='id'
160160
hide-pagination
161161
:rows-per-page-options='[0]'
162-
no-data-label='Aucune métrique systeme disponible.'
162+
no-data-label='Aucune métrique système disponible.'
163163
)
164164
template(v-slot:body-cell-metric='props')
165165
q-td(:props='props')
@@ -191,7 +191,7 @@
191191
autoresize
192192
style='height: 30px; width: 90px;'
193193
)
194-
span.text-caption.text-grey-6(v-else) Donnees insuffisantes
194+
span.text-caption.text-grey-6(v-else) Données insuffisantes
195195

196196
//- q-card.q-mt-md(v-if='futureCheckCards.length' flat bordered)
197197
//- q-card-section
@@ -516,6 +516,22 @@ export default defineNuxtComponent({
516516
}
517517
return `${Math.round(rssMb)} Mb`
518518
})
519+
const currentTotalSystemMemoryMb = computed(() => {
520+
const memoryMetrics = (healthPayload.value?.system?.memory || {}) as Record<string, unknown>
521+
const totalSystemMemoryMb = memoryMetrics['totalSystemMemoryMb']
522+
if (typeof totalSystemMemoryMb !== 'number' || Number.isNaN(totalSystemMemoryMb)) {
523+
return '-'
524+
}
525+
return `${totalSystemMemoryMb.toFixed(2)} Mb`
526+
})
527+
const currentCpuCores = computed(() => {
528+
const cpuMetrics = (healthPayload.value?.system?.cpu || {}) as Record<string, unknown>
529+
const cores = cpuMetrics['cores']
530+
if (typeof cores !== 'number' || Number.isNaN(cores)) {
531+
return '-'
532+
}
533+
return `${Math.round(cores)}`
534+
})
519535
520536
const statsCards = computed(() => {
521537
const cards = [
@@ -559,6 +575,26 @@ export default defineNuxtComponent({
559575
tooltipMeaning: 'RSS (Resident Set Size) = memoire physique actuellement occupee par le processus Node.js.',
560576
tooltipHow: 'Si RSS monte en continu sans redescendre, cela peut signaler une fuite memoire.',
561577
},
578+
{
579+
key: 'total-memory',
580+
label: 'Memoire système totale',
581+
value: currentTotalSystemMemoryMb.value,
582+
icon: 'mdi-memory-arrow-down',
583+
color: 'indigo',
584+
tooltipTag: 'Capacite',
585+
tooltipMeaning: 'Memoire totale visible par le runtime applicatif (conteneur/VM).',
586+
tooltipHow: 'Metrique plutot statique, utile comme reference de capacite.',
587+
},
588+
{
589+
key: 'cpu-cores',
590+
label: 'Nombre de cores',
591+
value: currentCpuCores.value,
592+
icon: 'mdi-chip',
593+
color: 'deep-orange',
594+
tooltipTag: 'Capacite CPU',
595+
tooltipMeaning: 'Nombre de cores CPU visibles par le runtime applicatif.',
596+
tooltipHow: 'Metrique plutot statique, utile pour interpreter la charge CPU par core.',
597+
},
562598
]
563599
564600
if (unknownIndicators.value > 0) {
@@ -629,6 +665,7 @@ export default defineNuxtComponent({
629665
load15mPerCore: 'Charge CPU (15 min / core)',
630666
usedPercent: 'Utilisation',
631667
thresholdPercent: 'Seuil',
668+
threshold: 'Seuil CPU',
632669
thresholdMb: 'Seuil mémoire',
633670
usedMb: 'Mémoire utilisée',
634671
pingMs: 'Latence',
@@ -647,6 +684,18 @@ export default defineNuxtComponent({
647684
648685
const metricHelpText = (metricLabel: string): string => {
649686
const normalizedLabel = metricLabel.toLowerCase()
687+
if (normalizedLabel === 'threshold') {
688+
return 'Seuil CPU exprime en ratio (0.85 = 85%).'
689+
}
690+
if (normalizedLabel === 'nativeMb'.toLowerCase()) {
691+
return 'Memoire native (external) vue par Node.js; inclut deja les Array buffers.'
692+
}
693+
if (normalizedLabel === 'arraybuffersmb') {
694+
return 'Part memoire des ArrayBuffer/Buffer, deja comprise dans la memoire externe.'
695+
}
696+
if (normalizedLabel === 'externalmb') {
697+
return 'Memoire externe V8 (objets natifs lies au JavaScript).'
698+
}
650699
if (normalizedLabel.includes('rss')) {
651700
return 'Memoire résidente du processus Node.js (RAM réellement occupée).'
652701
}
@@ -667,6 +716,12 @@ export default defineNuxtComponent({
667716
668717
const metricUnit = (label: string): string => {
669718
const normalizedLabel = label.toLowerCase()
719+
if (normalizedLabel === 'threshold') {
720+
return '%'
721+
}
722+
if (normalizedLabel.endsWith('mb')) {
723+
return 'Mb'
724+
}
670725
if (normalizedLabel.includes('percent') || normalizedLabel.includes('usage') || normalizedLabel.includes('ratio') || normalizedLabel.includes('cpu')) {
671726
return '%'
672727
}
@@ -690,9 +745,6 @@ export default defineNuxtComponent({
690745
if (unit === '%' && value <= 1) {
691746
return Math.round(value * 10000) / 100
692747
}
693-
if (unit === 'Mb' && value > 1024) {
694-
return Math.round((value / (1024 * 1024)) * 100) / 100
695-
}
696748
return value
697749
}
698750
@@ -862,7 +914,9 @@ export default defineNuxtComponent({
862914
}
863915
864916
const systemMetricRows = (card: { key: string; metrics: Array<{ label: string; value: unknown }> }): MetricRow[] => {
865-
return card.metrics.map((metric) => {
917+
return card.metrics
918+
.filter((metric) => !['totalSystemMemoryMb', 'cores'].includes(metric.label))
919+
.map((metric) => {
866920
const normalized = formatMetricWithUnit(metric.label, metric.value)
867921
const unitAwareProgress = normalized.unit === '%' && normalized.numericValue !== null ? Math.max(0, Math.min(100, normalized.numericValue)) : null
868922
return {
@@ -873,7 +927,7 @@ export default defineNuxtComponent({
873927
trendKey: `${card.key}.${metric.label}`,
874928
progressValue: unitAwareProgress,
875929
}
876-
})
930+
})
877931
}
878932
879933
const metricSeries = (trendKey: string): number[] => metricHistory.value[trendKey] || []

0 commit comments

Comments
 (0)