From b9ca4c07d8fe2b198bdc41e4ea34d617f5f7a056 Mon Sep 17 00:00:00 2001 From: Kyle Nusbaum Date: Fri, 27 Nov 2020 15:58:28 -0500 Subject: [PATCH] add constant --- pkg/trace/watchdog/cpu_aix.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/trace/watchdog/cpu_aix.go b/pkg/trace/watchdog/cpu_aix.go index 298b5da78e796..090739aa3923a 100644 --- a/pkg/trace/watchdog/cpu_aix.go +++ b/pkg/trace/watchdog/cpu_aix.go @@ -89,6 +89,7 @@ import ( // As explained above, we will skip 120 bytes into the status file to locate the user CPU time. const skip = 120 +const nsecs_per_sec = 1000000000 func cpuTimeUser(pid int32) (float64, error) { f, err := os.Open(fmt.Sprintf("/proc/%d/status", pid)) @@ -101,6 +102,6 @@ func cpuTimeUser(pid int32) (float64, error) { var userNsecs int32 binary.Read(f, binary.BigEndian, &userSecs) binary.Read(f, binary.BigEndian, &userNsecs) - time := float64(userSecs) + (float64(userNsecs) / 1000000000) + time := float64(userSecs) + (float64(userNsecs) / nsecs_per_sec) return time, nil }