diff --git a/src/core/metrics/metrics_util.go b/src/core/metrics/metrics_util.go index fef2ecd38..02f46655e 100644 --- a/src/core/metrics/metrics_util.go +++ b/src/core/metrics/metrics_util.go @@ -242,8 +242,8 @@ func GetCalculationMap() map[string]string { "nginx.workers.cpu.system": "sum", "nginx.workers.cpu.total": "sum", "nginx.workers.fds_count": "avg", - "nginx.workers.mem.vms": "sum", - "nginx.workers.mem.rss": "sum", + "nginx.workers.mem.vms": "avg", + "nginx.workers.mem.rss": "avg", "nginx.workers.mem.rss_pct": "avg", "nginx.workers.io.kbs_r": "sum", "nginx.workers.io.kbs_w": "sum", diff --git a/src/core/metrics/sources/nginx_worker.go b/src/core/metrics/sources/nginx_worker.go index ff619e2c4..99b0d0882 100644 --- a/src/core/metrics/sources/nginx_worker.go +++ b/src/core/metrics/sources/nginx_worker.go @@ -86,16 +86,6 @@ func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- cpuSystem = stats.Workers.CPUSystem } - memRss := stats.Workers.MemRss - c.prevStats[pid].Workers.MemRss - if stats.Workers.MemRss < c.prevStats[pid].Workers.MemRss { - memRss = stats.Workers.MemRss - } - - memVms := stats.Workers.MemVms - c.prevStats[pid].Workers.MemVms - if stats.Workers.MemVms < c.prevStats[pid].Workers.MemVms { - memVms = stats.Workers.MemVms - } - KbsR := stats.Workers.KbsR - c.prevStats[pid].Workers.KbsR if stats.Workers.KbsR < c.prevStats[pid].Workers.KbsR { KbsR = stats.Workers.KbsR @@ -113,8 +103,8 @@ func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- "cpu.system": float64(cpuSystem), "cpu.total": float64(cpuSystem + cpuUser), "fds_count": float64(stats.Workers.FdsCount), - "mem.vms": float64(memVms), - "mem.rss": float64(memRss), + "mem.vms": float64(stats.Workers.MemVms), + "mem.rss": float64(stats.Workers.MemRss), "mem.rss_pct": float64(stats.Workers.MemRssPct), "io.kbs_r": float64(KbsR), "io.kbs_w": float64(KbsW), diff --git a/src/core/metrics/sources/nginx_worker_test.go b/src/core/metrics/sources/nginx_worker_test.go index 1f9959a87..119377df2 100644 --- a/src/core/metrics/sources/nginx_worker_test.go +++ b/src/core/metrics/sources/nginx_worker_test.go @@ -108,7 +108,7 @@ func TestNginxWorkerCollector(t *testing.T) { case "nginx.workers.io.kbs_r": assert.Equal(t, float64(0), metric.Value) case "nginx.workers.mem.rss": - assert.Equal(t, float64(0), metric.Value) + assert.Equal(t, float64(1), metric.Value) case "nginx.workers.mem.rss_pct": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.rlimit_nofile": @@ -116,7 +116,7 @@ func TestNginxWorkerCollector(t *testing.T) { case "nginx.workers.count": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.mem.vms": - assert.Equal(t, float64(0), metric.Value) + assert.Equal(t, float64(1), metric.Value) case "nginx.workers.fds_count": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.cpu.user": @@ -148,7 +148,7 @@ func TestNginxWorkerCollector(t *testing.T) { case "nginx.workers.io.kbs_r": assert.Equal(t, float64(0), metric.Value) case "nginx.workers.mem.rss": - assert.Equal(t, float64(0), metric.Value) + assert.Equal(t, float64(1), metric.Value) case "nginx.workers.mem.rss_pct": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.rlimit_nofile": @@ -156,7 +156,7 @@ func TestNginxWorkerCollector(t *testing.T) { case "nginx.workers.count": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.mem.vms": - assert.Equal(t, float64(0), metric.Value) + assert.Equal(t, float64(1), metric.Value) case "nginx.workers.fds_count": assert.Equal(t, float64(1), metric.Value) case "nginx.workers.cpu.user": diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go index fef2ecd38..02f46655e 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/metrics_util.go @@ -242,8 +242,8 @@ func GetCalculationMap() map[string]string { "nginx.workers.cpu.system": "sum", "nginx.workers.cpu.total": "sum", "nginx.workers.fds_count": "avg", - "nginx.workers.mem.vms": "sum", - "nginx.workers.mem.rss": "sum", + "nginx.workers.mem.vms": "avg", + "nginx.workers.mem.rss": "avg", "nginx.workers.mem.rss_pct": "avg", "nginx.workers.io.kbs_r": "sum", "nginx.workers.io.kbs_w": "sum", diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go index ff619e2c4..99b0d0882 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/nginx_worker.go @@ -86,16 +86,6 @@ func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- cpuSystem = stats.Workers.CPUSystem } - memRss := stats.Workers.MemRss - c.prevStats[pid].Workers.MemRss - if stats.Workers.MemRss < c.prevStats[pid].Workers.MemRss { - memRss = stats.Workers.MemRss - } - - memVms := stats.Workers.MemVms - c.prevStats[pid].Workers.MemVms - if stats.Workers.MemVms < c.prevStats[pid].Workers.MemVms { - memVms = stats.Workers.MemVms - } - KbsR := stats.Workers.KbsR - c.prevStats[pid].Workers.KbsR if stats.Workers.KbsR < c.prevStats[pid].Workers.KbsR { KbsR = stats.Workers.KbsR @@ -113,8 +103,8 @@ func (c *NginxWorker) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- "cpu.system": float64(cpuSystem), "cpu.total": float64(cpuSystem + cpuUser), "fds_count": float64(stats.Workers.FdsCount), - "mem.vms": float64(memVms), - "mem.rss": float64(memRss), + "mem.vms": float64(stats.Workers.MemVms), + "mem.rss": float64(stats.Workers.MemRss), "mem.rss_pct": float64(stats.Workers.MemRssPct), "io.kbs_r": float64(KbsR), "io.kbs_w": float64(KbsW),