Move procspy out of vendor into probe/endpoint.

This commit is contained in:
Tom Wilkie
2015-12-09 10:59:27 +00:00
parent 8db21fbb2d
commit b94751ac10
20 changed files with 13 additions and 121 deletions

View File

@@ -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",
},

View File

@@ -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"
)

View File

@@ -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"
)

View File

@@ -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 .

View File

@@ -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)
}
}
```

View File

@@ -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
View File

@@ -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"
}
]
}
}