B
B
Boniface2014-11-11 23:05:22
go
Boniface, 2014-11-11 23:05:22

How to get information about a process in golang?

Hello!
Does anyone know how to get information about a running process in golang ? Interested in monitoring memory consumption.
There is a process search function. But how then to get information on it: memory consumption, processor time, etc.?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tyranron, 2014-11-12
@Boniface

Go's standard library will not work, because this is not a platform-independent thing at all.
The usual suggestion is to either parse the output of top/ps or knock on /proc/stat .
Details with examples on SO.
UPD: But if you need to monitor the memory consumption of a program written in Go, and not any process in general, then in order to reduce overhead and more accurate information, it is better to organize this matter internally in Go through the add. interface or logging.
Example: How to get statistics about memory in Golang

E
Elena, 2014-11-11
@Nidora

If I'm not mistaken:
func FindProcess(pid int) (p *Process, err error)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question