1
0
mirror of https://github.com/google/gops.git synced 2024-11-24 08:22:25 +02:00
A tool to list and diagnose Go processes currently running on your system
Go to file
Cezar Sá Espinola ad978d77e6 agent: avoid truncating stacktrace if it's bigger than 64kb (#29)
Using pprof.Lookup("goroutine") instead of runtime.Stack directly
because the former already takes care of expanding the buffer used with
runtime.Stack until it's big enough for the stack.
2017-01-13 12:27:22 -08:00
agent agent: avoid truncating stacktrace if it's bigger than 64kb (#29) 2017-01-13 12:27:22 -08:00
examples/hello agent: simplify options, allow only one listener 2016-12-20 12:23:05 -08:00
internal move config to internal 2016-11-14 23:07:31 -08:00
signal rename vitals to stats 2017-01-03 01:15:13 -08:00
.travis.yml add travis build 2016-11-11 13:46:23 -08:00
cmd.go rename vitals to stats 2017-01-03 01:15:13 -08:00
LICENSE add license 2016-11-03 16:56:19 -07:00
main.go rename vitals to stats 2017-01-03 01:15:13 -08:00
README.md rename vitals to stats 2017-01-03 01:15:13 -08:00

gops Build Status GoDoc

gops is a command to list and diagnose Go processes currently running on your system.

$ gops
983     uplink-soecks	(/usr/local/bin/uplink-soecks)
52697   gops	(/Users/jbd/bin/gops)
4132*   foops (/Users/jbd/bin/foops)
51130   gocode	(/Users/jbd/bin/gocode)

Installation

$ go get -u github.com/google/gops

Diagnostics

For processes that starts the diagnostics agent, gops can report additional information such as the current stack trace, Go version, memory stats, etc.

In order to start the diagnostics agent, see the hello example.

package main

import (
	"log"
	"time"

	"github.com/google/gops/agent"
)

func main() {
	if err := agent.Listen(nil); err != nil {
		log.Fatal(err)
	}
	time.Sleep(time.Hour)
}

Diagnostics manual

0. listing all processes

To print all go processes, run gops without arguments:

$ gops
983     uplink-soecks	(/usr/local/bin/uplink-soecks)
52697   gops	(/Users/jbd/bin/gops)
4132*   foops (/Users/jbd/bin/foops)
51130   gocode	(/Users/jbd/bin/gocode)

Note that processes running the agent are marked with * next to the PID (e.g. 4132*).

1. stack

In order to print the current stack trace from a target program, run the following command:

$ gops stack <pid>

2. memstats

To print the current memory stats, run the following command:

$ gops memstats <pid>

3. pprof

gops supports CPU and heap pprof profiles. After reading either heap or CPU profile, it shells out to the go tool pprof and let you interatively examine the profiles.

To enter the CPU profile, run:

$ gops pprof-cpu <pid>

To enter the heap profile, run:

$ gops pprof-heap <pid>

4. gc

If you want to force run garbage collection on the target program, run the following command. It will block until the GC is completed.

$ gops gc <pid>

5. version

gops reports the Go version the target program is built with, if you run the following:

$ gops version <pid>

6. stats

To print the runtime statistics such as number of goroutines and GOMAXPROCS, run the following:

$ gops stats <pid>