Reading CPU and memory usage in Go.

3,266 views
Skip to first unread message

Josh Jonte

unread,
Oct 23, 2011, 9:24:21 PM10/23/11
to golang-nuts
I'm writing my first Go program and I want to output to the console
the CPU & memory usage every N seconds. I came across the profiling
tool in runtime/pprof (writing a stream and reading it with pprof)
with but it's way overkill for what I want. I would really just like
a syscall.GetCpuUsage() float64 and syscall.GetMemoryUsage() foat64.

Does Go expose this type of information?

Thanks!

-josh

David Symonds

unread,
Oct 23, 2011, 9:37:14 PM10/23/11
to Josh Jonte, golang-nuts

Try the getrusage syscall (http://golang.org/pkg/syscall/#Getrusage).
Try http://linux.die.net/man/2/getrusage for usage hints.


Dave.

Reply all
Reply to author
Forward
0 new messages