docs(agent): 统一中文注释并补充部署文档

将代码与测试注释改为中文以符合仓库规范;新增中文部署指南、
示例配置,并完善构建脚本对 VERSION 注入的说明。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
codex
2026-05-19 02:30:49 +00:00
parent 89d5e27874
commit 877e4cf41d
28 changed files with 608 additions and 226 deletions

View File

@@ -14,7 +14,7 @@ import (
"mfd-monitor-agent/internal/status"
)
// TestParseAddressIPv4 verifies Linux IPv4 socket addresses are decoded.
// TestParseAddressIPv4 验证 Linux IPv4 套接字地址解码。
func TestParseAddressIPv4(t *testing.T) {
ip, port, err := parseAddress("0100007F:1F90", "ipv4")
if err != nil {
@@ -25,7 +25,7 @@ func TestParseAddressIPv4(t *testing.T) {
}
}
// TestParseAddressIPv6 verifies Linux IPv6 socket addresses are decoded.
// TestParseAddressIPv6 验证 Linux IPv6 套接字地址解码。
func TestParseAddressIPv6(t *testing.T) {
ip, port, err := parseAddress("00000000000000000000000001000000:1F90", "ipv6")
if err != nil {
@@ -36,7 +36,7 @@ func TestParseAddressIPv6(t *testing.T) {
}
}
// TestParseProcessStatStartTime verifies field 22 parsing from /proc/<pid>/stat.
// TestParseProcessStatStartTime 验证从 /proc/<pid>/stat 解析第 22 字段。
func TestParseProcessStatStartTime(t *testing.T) {
raw := "1234 (agent worker) S 1 2 3 4 5 0 0 0 0 0 11 22 0 0 20 0 1 0 987654 0 0"
@@ -49,7 +49,7 @@ func TestParseProcessStatStartTime(t *testing.T) {
}
}
// TestCPUUsageFromProcStatSamples verifies CPU usage from two /proc/stat samples.
// TestCPUUsageFromProcStatSamples 验证由两次 /proc/stat 采样计算 CPU 使用率。
func TestCPUUsageFromProcStatSamples(t *testing.T) {
prevIdle, prevTotal, err := parseCPUTimes("cpu 100 0 100 800 0 0 0 0 0 0\n")
if err != nil {
@@ -66,7 +66,7 @@ func TestCPUUsageFromProcStatSamples(t *testing.T) {
}
}
// TestReadProcessStatReturnsStartTime verifies process start time is exposed.
// TestReadProcessStatReturnsStartTime 验证进程启动时间被暴露。
func TestReadProcessStatReturnsStartTime(t *testing.T) {
path := filepath.Join(t.TempDir(), "stat")
raw := "1234 (agent worker) S 1 2 3 4 5 0 0 0 0 0 11 22 0 0 20 0 1 0 987654 0 0"
@@ -83,7 +83,7 @@ func TestReadProcessStatReturnsStartTime(t *testing.T) {
}
}
// TestReadMemoryReturnsBytesWithUnit verifies memory capacity fields are exposed in bytes.
// TestReadMemoryReturnsBytesWithUnit 验证内存容量字段以字节暴露。
func TestReadMemoryReturnsBytesWithUnit(t *testing.T) {
meminfo, err := os.ReadFile("/proc/meminfo")
if err != nil {
@@ -114,7 +114,7 @@ func TestReadMemoryReturnsBytesWithUnit(t *testing.T) {
}
}
// TestShouldIncludeDiskMount keeps physical and network disks while dropping pseudo mounts.
// TestShouldIncludeDiskMount 保留物理盘与网络盘并排除伪挂载。
func TestShouldIncludeDiskMount(t *testing.T) {
tests := []struct {
name string
@@ -140,7 +140,7 @@ func TestShouldIncludeDiskMount(t *testing.T) {
}
}
// TestCollectSocketsMarksPartialWhenProcessFDsUnreadable verifies socket mapping degradation.
// TestCollectSocketsMarksPartialWhenProcessFDsUnreadable 验证进程 fd 不可读时套接字映射降级。
func TestCollectSocketsMarksPartialWhenProcessFDsUnreadable(t *testing.T) {
oldSocketInodes := socketInodesFunc
oldReadTCPListeners := readTCPListenersFunc