fix: Fix memory usage display issue on dashboard (#9530)

Refs #9497
This commit is contained in:
ssongliu 2025-07-16 17:45:53 +08:00 committed by GitHub
parent ef2cb1b315
commit 7bf1bf61a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 55 additions and 11 deletions

View file

@ -74,8 +74,11 @@ type DashboardCurrent struct {
CPUTotal int `json:"cpuTotal"`
MemoryTotal uint64 `json:"memoryTotal"`
MemoryAvailable uint64 `json:"memoryAvailable"`
MemoryUsed uint64 `json:"memoryUsed"`
MemoryFree uint64 `json:"memoryFree"`
MemoryShard uint64 `json:"memoryShard"`
MemoryCache uint64 `json:"memoryCache"`
MemoryAvailable uint64 `json:"memoryAvailable"`
MemoryUsedPercent float64 `json:"memoryUsedPercent"`
SwapMemoryTotal uint64 `json:"swapMemoryTotal"`

View file

@ -113,7 +113,7 @@ func (u *DashboardService) LoadCurrentInfoForNode() *dto.NodeCurrent {
memoryInfo, _ := mem.VirtualMemory()
currentInfo.MemoryTotal = memoryInfo.Total
currentInfo.MemoryAvailable = memoryInfo.Available
currentInfo.MemoryUsed = memoryInfo.Used
currentInfo.MemoryUsed = memoryInfo.Used + memoryInfo.Shared
currentInfo.MemoryUsedPercent = memoryInfo.UsedPercent
swapInfo, _ := mem.SwapMemory()
@ -210,8 +210,11 @@ func (u *DashboardService) LoadCurrentInfo(ioOption string, netOption string) *d
memoryInfo, _ := mem.VirtualMemory()
currentInfo.MemoryTotal = memoryInfo.Total
currentInfo.MemoryUsed = memoryInfo.Used + memoryInfo.Shared
currentInfo.MemoryFree = memoryInfo.Free
currentInfo.MemoryCache = memoryInfo.Cached + memoryInfo.Buffers
currentInfo.MemoryShard = memoryInfo.Shared
currentInfo.MemoryAvailable = memoryInfo.Available
currentInfo.MemoryUsed = memoryInfo.Used
currentInfo.MemoryUsedPercent = memoryInfo.UsedPercent
swapInfo, _ := mem.SwapMemory()

View file

@ -77,6 +77,9 @@ export namespace Dashboard {
memoryTotal: number;
memoryAvailable: number;
memoryUsed: number;
memoryFree: number;
memoryShard: number;
memoryCache: number;
memoryUsedPercent: number;
swapMemoryTotal: number;
swapMemoryAvailable: number;

View file

@ -415,7 +415,10 @@ const message = {
fileSystem: 'File system',
total: 'Total',
used: 'Used',
cache: 'Cache',
free: 'Free',
shard: 'Sharded',
available: 'Available',
percent: 'Utilization',
goInstall: 'Go install',

View file

@ -402,7 +402,10 @@ const message = {
fileSystem: 'ファイルシステム',
total: '合計',
used: '使用済み',
free: '無料',
cache: 'キャッシュ',
free: '空き',
shard: 'シャーディング',
available: '利用可能',
percent: '利用',
goInstall: 'インストールします',

View file

@ -403,9 +403,12 @@ const message = {
load: '부하',
mount: '마운트 지점',
fileSystem: '파일 시스템',
total: '총량',
used: '사용 ',
total: '전체',
used: '사용',
cache: '<EFBFBD>',
free: '여유',
shard: '샤딩',
available: '사용 가능',
percent: '사용률',
goInstall: 'Go 설치',

View file

@ -411,7 +411,10 @@ const message = {
fileSystem: 'Sistem Fail',
total: 'Jumlah',
used: 'Digunakan',
free: 'Percuma',
cache: 'Cache',
free: 'Bebas',
shard: 'Shard',
available: 'Tersedia',
percent: 'Penggunaan',
goInstall: 'Pergi pasang',

View file

@ -409,7 +409,10 @@ const message = {
fileSystem: 'Sistema de arquivos',
total: 'Total',
used: 'Usado',
cache: 'Cache',
free: 'Livre',
shard: 'Fragmentado',
available: 'Disponível',
percent: 'Utilização',
goInstall: 'Ir para instalação',

View file

@ -406,7 +406,10 @@ const message = {
fileSystem: 'Файловая система',
total: 'Всего',
used: 'Использовано',
cache: 'Кэш',
free: 'Свободно',
shard: 'Шардированный',
available: 'Доступно',
percent: 'Утилизация',
goInstall: 'Установить',

View file

@ -420,7 +420,10 @@ const message = {
fileSystem: 'Dosya sistemi',
total: 'Toplam',
used: 'Kullanılan',
cache: 'Önbellek',
free: 'Boş',
shard: 'Parçalı',
available: 'Kullanılabilir',
percent: 'Kullanım',
goInstall: 'Yüklemeye git',

View file

@ -403,9 +403,12 @@ const message = {
load: '負載',
mount: '掛載點',
fileSystem: '文件系統',
total: '',
total: '',
used: '已用',
free: '可用',
cache: '快取',
free: '空閒',
shard: '分片',
available: '可用',
percent: '使用率',
goInstall: '去安裝',

View file

@ -403,7 +403,10 @@ const message = {
fileSystem: '文件系统',
total: '总数',
used: '已用',
free: '可用',
cache: '缓存',
free: '空闲',
shard: '共享',
available: '可用',
percent: '使用率',
goInstall: '去安装',

View file

@ -75,7 +75,12 @@
<el-tag style="font-weight: 500">{{ $t('home.mem') }}:</el-tag>
<el-tag class="tagClass">{{ $t('home.total') }}: {{ computeSize(currentInfo.memoryTotal) }}</el-tag>
<el-tag class="tagClass">{{ $t('home.used') }}: {{ computeSize(currentInfo.memoryUsed) }}</el-tag>
<el-tag class="tagClass">{{ $t('home.free') }}: {{ computeSize(currentInfo.memoryAvailable) }}</el-tag>
<el-tag class="tagClass">{{ $t('home.free') }}: {{ computeSize(currentInfo.memoryFree) }}</el-tag>
<el-tag class="tagClass">{{ $t('home.shard') }}: {{ computeSize(currentInfo.memoryShard) }}</el-tag>
<el-tag class="tagClass">{{ $t('home.cache') }}: {{ computeSize(currentInfo.memoryCache) }}</el-tag>
<el-tag class="tagClass">
{{ $t('home.available') }}: {{ computeSize(currentInfo.memoryAvailable) }}
</el-tag>
<el-tag class="tagClass">
{{ $t('home.percent') }}: {{ formatNumber(currentInfo.memoryUsedPercent) }}%
</el-tag>
@ -304,6 +309,9 @@ const currentInfo = ref<Dashboard.CurrentInfo>({
memoryTotal: 0,
memoryAvailable: 0,
memoryCache: 0,
memoryFree: 0,
memoryShard: 0,
memoryUsed: 0,
memoryUsedPercent: 0,
swapMemoryTotal: 0,