Skip to content

Commit c0c8e3b

Browse files
committed
Fix process statistics on macOS
Rectify incorrect memory usage and fix `cmd` field not existing.
1 parent 9cd43bd commit c0c8e3b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

system/process_unix.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ type ProcessStats struct {
1818

1919
// GetProcessStats gets the stats of a process.
2020
func GetProcessStats(pid int) (ProcessStats, error) {
21-
cmd := "pcpu,rss,cmd"
21+
cmd := "pcpu,rss,command"
2222
if runtime.GOOS == "aix" {
23-
cmd = "pcpu,rssize,cmd"
23+
cmd = "pcpu,rssize,command"
2424
}
2525
output, err := exec.Command("ps", "-p", strconv.Itoa(pid), "-o", cmd).Output()
2626
if err != nil {
@@ -52,6 +52,6 @@ func GetProcessStats(pid int) (ProcessStats, error) {
5252

5353
return ProcessStats{
5454
CPUUsage: cpuUsage,
55-
RSSMemory: rssMemory,
55+
RSSMemory: rssMemory * 1024,
5656
}, nil
5757
}

0 commit comments

Comments
 (0)