mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-04-25 08:45:58 +03:00
[GH-ISSUE #1231] 内存统计显示不正确 #7793
Labels
No labels
Q/A
bug
casdoor
dependencies
docker
documentation
duplicate
enhancement
help wanted
invalid
lego
platform:openwrt
platform:windows
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/nginx-ui#7793
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gang929 on GitHub (Jul 14, 2025).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/1231
在主机上用free 命令显示 为
XXXX:~# free
total used free shared buff/cache available
Mem: 8131956 919524 3721500 85052 3887004 7212432
而在Nginx UI的dashboard中显示的内存为 523M.
估计是因为 nginx所使用的used算法是 total - free - buff/cache
而 free 命令的算法是 total - available
@0xJacky commented on GitHub (Jul 15, 2025):
您好,请提供一下操作系统,部署方式(直接安装 or 容器部署),Dashboard 截图以及
free -m输出。因为这个部分是 gopsutil 直接返回的,我们没有做加减操作。@gang929 commented on GitHub (Jul 16, 2025):
操作系统 Ubuntu 22.04
部署方式 install.sh
@gang929 commented on GitHub (Jul 16, 2025):
估计是gopsutil 这个算得有问题
@0xJacky commented on GitHub (Jul 16, 2025):
-m 换算的应该是 MiB,当前版本是用的 MB,所以计算肯定是没问题的。
关于 MiB/MB 的问题已经在 PR #1222 中改为使用二进制进位换算,您可以更新到最新的开发版查看新的换算结果。
@gang929 commented on GitHub (Jul 16, 2025):
不是换算的问题,应该是 gopsutil 是用 total - free - buff/cache 计算的,而free 是用 total - available 计算的
@0xJacky commented on GitHub (Jul 16, 2025):
哦哦 看错了,我以为你说的 total
@0xJacky commented on GitHub (Jul 17, 2025):
看了代码,确实是 total - free - buff/cache
但是新版 linux manual 的定义是:used Used or unavailable memory (calculated as total - available)
github.com/shirou/gopsutil@4a774b4303/mem/mem_linux.go (L307)我看 gopsutil 有 issue 在讨论这个问题 https://github.com/shirou/gopsutil/issues/1873
对应 PR: https://github.com/shirou/gopsutil/pull/1882