• Stars
    star
    6,375
  • Rank 5,960 (Top 0.2 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 7 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tool to list and diagnose Go processes currently running on your system

gops

GitHub Action Status GoDoc

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

$ gops
983   980    uplink-soecks  go1.9   /usr/local/bin/uplink-soecks
52697 52695  gops           go1.10  /Users/jbd/bin/gops
4132  4130   foops        * go1.9   /Users/jbd/bin/foops
51130 51128  gocode         go1.9.2 /Users/jbd/bin/gocode

Installation

To install the latest version of gops:

$ go get github.com/google/gops

or

$ go install github.com/google/gops@latest

To install a specific gops version, for example v0.3.19:

$ go install github.com/google/[email protected]

Diagnostics

For processes that start 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(agent.Options{}); err != nil {
		log.Fatal(err)
	}
	time.Sleep(time.Hour)
}

Otherwise, you could set GOPS_CONFIG_DIR environment variables to assign your config dir. Default, gops will use the current user's home directory(AppData on windows).

Manual

It is possible to use gops tool both in local and remote mode.

Local mode requires that you start the target binary as the same user that runs gops binary. To use gops in a remote mode you need to know target's agent address.

In Local mode use process's PID as a target; in Remote mode target is a host:port combination.

Listing all processes running locally

To print all go processes, run gops without arguments:

$ gops
983   980    uplink-soecks  go1.9   /usr/local/bin/uplink-soecks
52697 52695  gops           go1.10  /Users/jbd/bin/gops
4132  4130   foops        * go1.9   /Users/jbd/bin/foops
51130 51128  gocode         go1.9.2 /Users/jbd/bin/gocode

The output displays:

  • PID
  • PPID
  • Name of the program
  • Go version used to build the program
  • Location of the associated program

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

$ gops <pid> [duration]

To report more information about a process, run gops followed by a PID:

$ gops <pid>
parent PID:	5985
threads:	27
memory usage:	0.199%
cpu usage:	0.139%
username:	jbd
cmd+args:	/Applications/Splice.app/Contents/Resources/Splice Helper.app/Contents/MacOS/Splice Helper -pid 5985
local/remote:	127.0.0.1:56765 <-> :0 (LISTEN)
local/remote:	127.0.0.1:56765 <-> 127.0.0.1:50955 (ESTABLISHED)
local/remote:	100.76.175.164:52353 <-> 54.241.191.232:443 (ESTABLISHED)

If an optional duration is specified in the format as expected by time.ParseDuration, the CPU usage for the given time period is reported in addition:

$ gops <pid> 2s
parent PID:	5985
threads:	27
memory usage:	0.199%
cpu usage:	0.139%
cpu usage (2s):	0.271%
username:	jbd
cmd+args:	/Applications/Splice.app/Contents/Resources/Splice Helper.app/Contents/MacOS/Splice Helper -pid 5985
local/remote:	127.0.0.1:56765 <-> :0 (LISTEN)
local/remote:	127.0.0.1:56765 <-> 127.0.0.1:50955 (ESTABLISHED)
local/remote:	100.76.175.164:52353 <-> 54.241.191.232:443 (ESTABLISHED)

$ gops tree

To display a process tree with all the running Go processes, run the following command:

$ gops tree

...
โ”œโ”€โ”€ 1
โ”‚ย ย  โ””โ”€โ”€ 13962 [gocode] {go1.9}
โ”œโ”€โ”€ 557
โ”‚ย ย  โ””โ”€โ”€ 635 [com.docker.supervisor] {go1.9.2}
โ”‚ย ย      โ””โ”€โ”€ 638 [com.docker.driver.amd64-linux] {go1.9.2}
โ””โ”€โ”€ 13744
    โ””โ”€โ”€ 67243 [gops] {go1.10}

$ gops stack (<pid>|<addr>)

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

$ gops stack (<pid>|<addr>)
gops stack 85709
goroutine 8 [running]:
runtime/pprof.writeGoroutineStacks(0x13c7bc0, 0xc42000e008, 0xc420ec8520, 0xc420ec8520)
	/Users/jbd/go/src/runtime/pprof/pprof.go:603 +0x79
runtime/pprof.writeGoroutine(0x13c7bc0, 0xc42000e008, 0x2, 0xc428f1c048, 0xc420ec8608)
	/Users/jbd/go/src/runtime/pprof/pprof.go:592 +0x44
runtime/pprof.(*Profile).WriteTo(0x13eeda0, 0x13c7bc0, 0xc42000e008, 0x2, 0xc42000e008, 0x0)
	/Users/jbd/go/src/runtime/pprof/pprof.go:302 +0x3b5
github.com/google/gops/agent.handle(0x13cd560, 0xc42000e008, 0xc420186000, 0x1, 0x1, 0x0, 0x0)
	/Users/jbd/src/github.com/google/gops/agent/agent.go:150 +0x1b3
github.com/google/gops/agent.listen()
	/Users/jbd/src/github.com/google/gops/agent/agent.go:113 +0x2b2
created by github.com/google/gops/agent.Listen
	/Users/jbd/src/github.com/google/gops/agent/agent.go:94 +0x480
# ...

$ gops memstats (<pid>|<addr>)

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

$ gops memstats (<pid>|<addr>)

$ gops gc (<pid>|<addr>)

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

$ gops setgc (<pid>|<addr>)

Sets the garbage collection target to a certain percentage. The following command sets it to 10%:

$ gops setgc (<pid>|<addr>) 10

The following command turns off the garbage collector:

$ gops setgc (<pid>|<addr>) off

$ gops version (<pid>|<addr>)

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

$ gops version (<pid>|<addr>)
devel +6a3c6c0 Sat Jan 14 05:57:07 2017 +0000

$ gops stats (<pid>|<addr>)

To print the runtime statistics such as number of goroutines and GOMAXPROCS.

Profiling

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 interactively examine the profiles.

To enter the CPU profile, run:

$ gops pprof-cpu (<pid>|<addr>)

To enter the heap profile, run:

$ gops pprof-heap (<pid>|<addr>)
Execution trace

gops allows you to start the runtime tracer for 5 seconds and examine the results.

$ gops trace (<pid>|<addr>)

More Repositories

1

material-design-icons

Material Design icons by Google (Material Symbols)
49,826
star
2

guava

Google core libraries for Java
Java
48,313
star
3

zx

A tool for writing better scripts
JavaScript
37,928
star
4

styleguide

Style guides for Google-originated open-source projects
HTML
36,576
star
5

leveldb

LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.
C++
33,564
star
6

material-design-lite

Material Design Components in HTML/CSS/JS
HTML
32,276
star
7

googletest

GoogleTest - Google Testing and Mocking Framework
C++
32,215
star
8

jax

Composable transformations of Python+NumPy programs: differentiate, vectorize, JIT to GPU/TPU, and more
Python
28,074
star
9

comprehensive-rust

This is the Rust course used by the Android team at Google. It provides you the material to quickly teach Rust.
Rust
26,213
star
10

python-fire

Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.
Python
26,112
star
11

mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
C++
25,513
star
12

gson

A Java serialization/deserialization library to convert Java Objects into JSON and back
Java
22,945
star
13

flatbuffers

FlatBuffers: Memory Efficient Serialization Library
C++
22,064
star
14

iosched

The Google I/O Android App
Kotlin
21,790
star
15

ExoPlayer

An extensible media player for Android
Java
21,465
star
16

eng-practices

Google's Engineering Practices documentation
19,741
star
17

web-starter-kit

Web Starter Kit - a workflow for multi-device websites
HTML
18,434
star
18

flexbox-layout

Flexbox for Android
Kotlin
18,141
star
19

fonts

Font files available from Google Fonts, and a public issue tracker for all things Google Fonts
HTML
17,623
star
20

filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
C++
16,946
star
21

cadvisor

Analyzes resource usage and performance characteristics of running containers.
Go
16,335
star
22

libphonenumber

Google's common Java, C++ and JavaScript library for parsing, formatting, and validating international phone numbers.
C++
15,728
star
23

gvisor

Application Kernel for Containers
Go
15,105
star
24

WebFundamentals

Former git repo for WebFundamentals on developers.google.com
JavaScript
13,842
star
25

yapf

A formatter for Python files
Python
13,648
star
26

tink

Tink is a multi-language, cross-platform, open source library that provides cryptographic APIs that are secure, easy to use correctly, and hard(er) to misuse.
Java
13,318
star
27

deepdream

13,212
star
28

brotli

Brotli compression format
TypeScript
13,154
star
29

guetzli

Perceptual JPEG encoder
C++
12,863
star
30

guice

Guice (pronounced 'juice') is a lightweight dependency injection framework for Java 11 and above, brought to you by Google.
Java
12,342
star
31

wire

Compile-time Dependency Injection for Go
Go
12,222
star
32

blockly

The web-based visual programming editor.
TypeScript
12,067
star
33

sanitizers

AddressSanitizer, ThreadSanitizer, MemorySanitizer
C
10,754
star
34

grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Go
10,464
star
35

or-tools

Google's Operations Research tools:
C++
10,405
star
36

dopamine

Dopamine is a research framework for fast prototyping of reinforcement learning algorithms.
Jupyter Notebook
10,367
star
37

auto

A collection of source code generators for Java.
Java
10,234
star
38

go-github

Go library for accessing the GitHub v3 API
Go
10,081
star
39

oss-fuzz

OSS-Fuzz - continuous fuzzing for open source software.
Shell
9,859
star
40

go-cloud

The Go Cloud Development Kit (Go CDK): A library and tools for open cloud development in Go.
Go
9,389
star
41

sentencepiece

Unsupervised text tokenizer for Neural Network-based text generation.
C++
8,657
star
42

re2

RE2 is a fast, safe, thread-friendly alternative to backtracking regular expression engines like those used in PCRE, Perl, and Python. It is a C++ library.
C++
8,190
star
43

traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler
JavaScript
8,182
star
44

tsunami-security-scanner

Tsunami is a general purpose network security scanner with an extensible plugin system for detecting high severity vulnerabilities with high confidence.
Java
8,118
star
45

trax

Trax โ€” Deep Learning with Clear Code and Speed
Python
7,943
star
46

skia

Skia is a complete 2D graphic library for drawing Text, Geometries, and Images.
C++
7,874
star
47

benchmark

A microbenchmark support library
C++
7,812
star
48

android-classyshark

Android and Java bytecode viewer
Java
7,468
star
49

pprof

pprof is a tool for visualization and analysis of profiling data
Go
7,408
star
50

closure-compiler

A JavaScript checker and optimizer.
Java
7,253
star
51

agera

Reactive Programming for Android
Java
7,227
star
52

accompanist

A collection of extension libraries for Jetpack Compose
Kotlin
7,221
star
53

magika

Detect file content types with deep learning
Python
7,171
star
54

diff-match-patch

Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.
Python
7,132
star
55

flutter-desktop-embedding

Experimental plugins for Flutter for Desktop
C++
7,109
star
56

latexify_py

A library to generate LaTeX expression from Python code.
Python
6,953
star
57

lovefield

Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use.
JavaScript
6,847
star
58

glog

C++ implementation of the Google logging module
C++
6,797
star
59

jsonnet

Jsonnet - The data templating language
Jsonnet
6,742
star
60

error-prone

Catch common Java mistakes as compile-time errors
Java
6,690
star
61

model-viewer

Easily display interactive 3D models on the web and in AR!
TypeScript
6,473
star
62

draco

Draco is a library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics.
C++
6,188
star
63

automl

Google Brain AutoML
Jupyter Notebook
6,154
star
64

gopacket

Provides packet processing capabilities for Go
Go
6,082
star
65

physical-web

The Physical Web: walk up and use anything
Java
6,017
star
66

grafika

Grafika test app
Java
6,002
star
67

j2objc

A Java to iOS Objective-C translation tool and runtime.
Java
5,976
star
68

snappy

A fast compressor/decompressor
C++
5,940
star
69

osv-scanner

Vulnerability scanner written in Go which uses the data provided by https://osv.dev
Go
5,849
star
70

ios-webkit-debug-proxy

A DevTools proxy (Chrome Remote Debugging Protocol) for iOS devices (Safari Remote Web Inspector).
C
5,848
star
71

seesaw

Seesaw v2 is a Linux Virtual Server (LVS) based load balancing platform.
Go
5,599
star
72

EarlGrey

๐Ÿต iOS UI Automation Test Framework
Objective-C
5,580
star
73

seq2seq

A general-purpose encoder-decoder framework for Tensorflow
Python
5,577
star
74

flax

Flax is a neural network library for JAX that is designed for flexibility.
Python
5,538
star
75

gemma.cpp

lightweight, standalone C++ inference engine for Google's Gemma models.
C++
5,518
star
76

google-java-format

Reformats Java source code to comply with Google Java Style.
Java
5,366
star
77

wireit

Wireit upgrades your npm/pnpm/yarn scripts to make them smarter and more efficient.
TypeScript
5,280
star
78

battery-historian

Battery Historian is a tool to analyze battery consumers using Android "bugreport" files.
Go
5,249
star
79

clusterfuzz

Scalable fuzzing infrastructure.
Python
5,202
star
80

bbr

5,156
star
81

gumbo-parser

An HTML5 parsing library in pure C99
HTML
5,141
star
82

syzkaller

syzkaller is an unsupervised coverage-guided kernel fuzzer
Go
5,136
star
83

git-appraise

Distributed code review system for Git repos
Go
5,090
star
84

google-authenticator

Open source version of Google Authenticator (except the Android app)
Java
5,077
star
85

uuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.
Go
4,994
star
86

gts

โ˜‚๏ธ TypeScript style guide, formatter, and linter.
TypeScript
4,930
star
87

gemma_pytorch

The official PyTorch implementation of Google's Gemma models
Python
4,920
star
88

closure-library

Google's common JavaScript library
JavaScript
4,837
star
89

cameraview

[DEPRECATED] Easily integrate Camera features into your Android app
Java
4,734
star
90

grr

GRR Rapid Response: remote live forensics for incident response
Python
4,641
star
91

liquidfun

2D physics engine for games
C++
4,559
star
92

pytype

A static type analyzer for Python code
Python
4,528
star
93

gxui

An experimental Go cross platform UI library.
Go
4,450
star
94

bloaty

Bloaty: a size profiler for binaries
C++
4,386
star
95

clasp

๐Ÿ”— Command Line Apps Script Projects
TypeScript
4,336
star
96

ko

Build and deploy Go applications on Kubernetes
Go
4,329
star
97

santa

A binary authorization and monitoring system for macOS
Objective-C
4,288
star
98

google-ctf

Google CTF
Go
4,246
star
99

tamperchrome

Tamper Dev is an extension that allows you to intercept and edit HTTP/HTTPS requests and responses as they happen without the need of a proxy. Works across all operating systems (including Chrome OS).
TypeScript
4,148
star
100

end-to-end

End-To-End is a crypto library to encrypt, decrypt, digital sign, and verify signed messages (implementing OpenPGP)
JavaScript
4,126
star