From c66e798b9747108851db2cb03f932a67c6ebd5ee Mon Sep 17 00:00:00 2001 From: peter wang <wangbo.red@gmail.com> Date: Mon, 18 Jul 2022 00:22:07 +0800 Subject: [PATCH] add processor field for /proc/[pid]/stat Signed-off-by: peter wang <wangbo.red@gmail.com> --- proc_stat.go | 4 +++- proc_stat_test.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/proc_stat.go b/proc_stat.go index 06c556ef9..b278eb2c2 100644 --- a/proc_stat.go +++ b/proc_stat.go @@ -102,6 +102,8 @@ type ProcStat struct { RSS int // Soft limit in bytes on the rss of the process. RSSLimit uint64 + // CPU number last executed on. + Processor uint // Real-time scheduling priority, a number in the range 1 to 99 for processes // scheduled under a real-time policy, or 0, for non-real-time processes. RTPriority uint @@ -184,7 +186,7 @@ func (p Proc) Stat() (ProcStat, error) { &ignoreUint64, &ignoreUint64, &ignoreInt64, - &ignoreInt64, + &s.Processor, &s.RTPriority, &s.Policy, &s.DelayAcctBlkIOTicks, diff --git a/proc_stat_test.go b/proc_stat_test.go index 8be1e1318..8abd67f60 100644 --- a/proc_stat_test.go +++ b/proc_stat_test.go @@ -68,6 +68,7 @@ func TestProcStat(t *testing.T) { want uint have uint }{ + {name: "processor", want: 0, have: s.Processor}, {name: "rt_priority", want: 0, have: s.RTPriority}, {name: "policy", want: 0, have: s.Policy}, } {