Accumulate cpu and memory usage of child processes

This commit is contained in:
Ingo Oppermann
2025-06-12 14:52:58 +02:00
parent 22745e497c
commit f241f3f531
3 changed files with 79 additions and 6 deletions

View File

@@ -27,13 +27,13 @@ func init() {
}
}
func (p *process) cpuTimes() (*cpuTimesStat, error) {
func cpuTimes(pid int32) (*cpuTimesStat, error) {
value := os.Getenv("HOST_PROC")
if value == "" {
value = "/proc"
}
path := filepath.Join(value, strconv.FormatInt(int64(p.pid), 10), "stat")
path := filepath.Join(value, strconv.FormatInt(int64(pid), 10), "stat")
contents, err := os.ReadFile(path)
if err != nil {