mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-22 14:56:56 +00:00
Move procspy out of vendor into probe/endpoint.
This commit is contained in:
@@ -12,8 +12,8 @@ func TestLSOFParsing(t *testing.T) {
|
||||
"p25196\n" +
|
||||
"ccello-app\n" +
|
||||
"n127.0.0.1:48094->127.0.0.1:4039\n" +
|
||||
"n*:4040\n": map[string]Proc{
|
||||
"127.0.0.1:48094": Proc{
|
||||
"n*:4040\n": {
|
||||
"127.0.0.1:48094": {
|
||||
PID: 25196,
|
||||
Name: "cello-app",
|
||||
},
|
||||
@@ -23,7 +23,7 @@ func TestLSOFParsing(t *testing.T) {
|
||||
"cdhclient\n" +
|
||||
"n*:68\n" +
|
||||
"n*:38282\n" +
|
||||
"n*:40625\n": map[string]Proc{},
|
||||
"n*:40625\n": {},
|
||||
|
||||
// A bunch
|
||||
"p13100\n" +
|
||||
@@ -39,28 +39,28 @@ func TestLSOFParsing(t *testing.T) {
|
||||
"n192.168.2.111:56385->74.201.105.31:443\n" +
|
||||
"p21356\n" +
|
||||
"cssh\n" +
|
||||
"n192.168.2.111:33963->192.168.2.71:22\n": map[string]Proc{
|
||||
"[::1]:6600": Proc{
|
||||
"n192.168.2.111:33963->192.168.2.71:22\n": {
|
||||
"[::1]:6600": {
|
||||
PID: 13100,
|
||||
Name: "mpd",
|
||||
},
|
||||
"[2003:45:2b57:8900:1869:2947:f942:aba7]:55711": Proc{
|
||||
"[2003:45:2b57:8900:1869:2947:f942:aba7]:55711": {
|
||||
PID: 14612,
|
||||
Name: "chromium",
|
||||
},
|
||||
"192.168.2.111:37158": Proc{
|
||||
"192.168.2.111:37158": {
|
||||
PID: 14612,
|
||||
Name: "chromium",
|
||||
},
|
||||
"192.168.2.111:44013": Proc{
|
||||
"192.168.2.111:44013": {
|
||||
PID: 14612,
|
||||
Name: "chromium",
|
||||
},
|
||||
"192.168.2.111:56385": Proc{
|
||||
"192.168.2.111:56385": {
|
||||
PID: 14612,
|
||||
Name: "chromium",
|
||||
},
|
||||
"192.168.2.111:33963": Proc{
|
||||
"192.168.2.111:33963": {
|
||||
PID: 21356,
|
||||
Name: "ssh",
|
||||
},
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
"github.com/weaveworks/procspy"
|
||||
"github.com/weaveworks/scope/probe/endpoint/procspy"
|
||||
"github.com/weaveworks/scope/probe/process"
|
||||
"github.com/weaveworks/scope/report"
|
||||
)
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/weaveworks/procspy"
|
||||
"github.com/weaveworks/scope/probe/docker"
|
||||
"github.com/weaveworks/scope/probe/endpoint"
|
||||
"github.com/weaveworks/scope/probe/endpoint/procspy"
|
||||
"github.com/weaveworks/scope/report"
|
||||
)
|
||||
|
||||
|
||||
20
vendor/github.com/weaveworks/procspy/Makefile
generated
vendored
20
vendor/github.com/weaveworks/procspy/Makefile
generated
vendored
@@ -1,20 +0,0 @@
|
||||
.PHONY: all build buildall test install bench
|
||||
all: test build buildall install
|
||||
|
||||
build:
|
||||
go build
|
||||
go vet
|
||||
golint .
|
||||
|
||||
buildall:
|
||||
GOOS=darwin go build
|
||||
GOOS=linux go build
|
||||
|
||||
test:
|
||||
go test
|
||||
|
||||
install:
|
||||
go install
|
||||
|
||||
bench:
|
||||
go test -bench .
|
||||
64
vendor/github.com/weaveworks/procspy/README.md
generated
vendored
64
vendor/github.com/weaveworks/procspy/README.md
generated
vendored
@@ -1,64 +0,0 @@
|
||||
Go module to list all TCP connections, with an option to try to find the owning PID and processname.
|
||||
|
||||
Works by reading /proc directly on Linux, and by executing `netstat` and `lsof -i` on Darwin.
|
||||
|
||||
Works for IPv4 and IPv6 TCP connections. Only established connections are listed; ports where something is only listening or TIME_WAITs are skipped.
|
||||
|
||||
If you want to find all processes you'll need to run this as root.
|
||||
|
||||
Status:
|
||||
-------
|
||||
|
||||
Tested on Linux and Darwin (10.9).
|
||||
|
||||
Install:
|
||||
--------
|
||||
|
||||
`go install`
|
||||
|
||||
Usage:
|
||||
------
|
||||
|
||||
Only list the connections:
|
||||
|
||||
```
|
||||
cs, err := procspy.Connections(false)
|
||||
for c := cs.Next(); c != nil; c = cs.Next() {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
List the connections and try to find the owning process:
|
||||
|
||||
```
|
||||
cs, err := procspy.Connections(true)
|
||||
for c := cs.Next(); c != nil; c = cs.Next() {
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
(See ./example\_test.go)
|
||||
|
||||
``` go
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/weaveworks/procspy"
|
||||
)
|
||||
|
||||
func main() {
|
||||
lookupProcesses := true
|
||||
cs, err := procspy.Connections(lookupProcesses)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf("TCP Connections:\n")
|
||||
for c := cs.Next(); c != nil; c = cs.Next() {
|
||||
fmt.Printf(" - %v\n", c)
|
||||
}
|
||||
}
|
||||
```
|
||||
18
vendor/github.com/weaveworks/procspy/lsproc/lsproc.go
generated
vendored
18
vendor/github.com/weaveworks/procspy/lsproc/lsproc.go
generated
vendored
@@ -1,18 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/weaveworks/procspy"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cs, err := procspy.Connections(true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("TCP Connections:\n")
|
||||
for c := cs.Next(); c != nil; c = cs.Next() {
|
||||
fmt.Printf(" - %+v\n", c)
|
||||
}
|
||||
}
|
||||
8
vendor/manifest
vendored
8
vendor/manifest
vendored
@@ -723,12 +723,6 @@
|
||||
"branch": "master",
|
||||
"path": "/odp"
|
||||
},
|
||||
{
|
||||
"importpath": "github.com/weaveworks/procspy",
|
||||
"repository": "https://github.com/weaveworks/procspy",
|
||||
"revision": "cb970aa190c374d1e47711dbffb3c2c6e9ef0dd1",
|
||||
"branch": "master"
|
||||
},
|
||||
{
|
||||
"importpath": "github.com/weaveworks/weave/common",
|
||||
"repository": "https://github.com/weaveworks/weave",
|
||||
@@ -931,4 +925,4 @@
|
||||
"branch": "master"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user