mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Send all the container pids to the client.
This commit is contained in:
@@ -3,7 +3,9 @@ Run tracer:
|
||||
- ./tracer.sh start
|
||||
|
||||
TODO:
|
||||
- need to stich traces together
|
||||
- <s>need to stich traces together</s>
|
||||
- deal with persistant connections
|
||||
- make it work for goroutines
|
||||
- test with jvm based app
|
||||
- find way to get local ip address for an incoming connection
|
||||
- make the container/process trace start/stop more reliable
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"mime"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
dockerClient "github.com/fsouza/go-dockerclient"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/weaveworks/scope/probe/docker"
|
||||
@@ -45,13 +45,31 @@ func (t *tracer) pidsForContainer(id string) ([]int, error) {
|
||||
return pidTree.GetChildren(container.PID())
|
||||
}
|
||||
|
||||
type Container struct {
|
||||
Id string
|
||||
Name string
|
||||
PIDs []int
|
||||
}
|
||||
|
||||
func (t *tracer) http(port int) {
|
||||
router := mux.NewRouter()
|
||||
|
||||
router.Methods("GET").Path("/container").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
containers := []*dockerClient.Container{}
|
||||
pidTree, err := process.NewTree(process.NewWalker("/proc"))
|
||||
if err != nil {
|
||||
respondWith(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
containers := []Container{}
|
||||
t.docker.WalkContainers(func(container docker.Container) {
|
||||
containers = append(containers, container.Container())
|
||||
children, _ := pidTree.GetChildren(container.PID())
|
||||
out := Container{
|
||||
Name: strings.TrimPrefix(container.Container().Name, "/"),
|
||||
Id: container.ID(),
|
||||
PIDs: children,
|
||||
}
|
||||
containers = append(containers, out)
|
||||
})
|
||||
|
||||
respondWith(w, http.StatusOK, containers)
|
||||
|
||||
@@ -95,7 +95,6 @@ func (t *trace) addChild(child *trace) {
|
||||
|
||||
// Fix up some fields
|
||||
child.ClientDetails = candidate.ClientDetails
|
||||
child.PID = candidate.PID
|
||||
IncrementLevel(child, t.Level+1)
|
||||
|
||||
// Overwrite old record
|
||||
|
||||
@@ -220,14 +220,14 @@
|
||||
<script type="text/x-handlebars-template" id="traces">
|
||||
{{#.}}
|
||||
<tr class="trace" data-key="{{Key}}">
|
||||
{{#if ServerDetails}}
|
||||
{{#with ServerDetails}}
|
||||
{{#if ClientDetails}}
|
||||
{{#with ClientDetails}}
|
||||
<td>{{spaces ../Level}}{{ts Start}}</td><td>{{duration .}}</td>
|
||||
<td>{{../PID}}</td><td>{{FromAddr}}:{{FromPort}}</td>
|
||||
<td>{{ToAddr}}:{{ToPort}}</td><td>{{count ../.}}</td>
|
||||
{{/with}}
|
||||
{{else}}
|
||||
{{#with ClientDetails}}
|
||||
{{#with ServerDetails}}
|
||||
<td>{{spaces ../Level}}{{ts Start}}</td><td>{{duration .}}</td>
|
||||
<td>{{../PID}}</td><td>{{FromAddr}}:{{FromPort}}</td>
|
||||
<td>{{ToAddr}}:{{ToPort}}</td><td>{{count ../.}}</td>
|
||||
@@ -241,15 +241,15 @@
|
||||
</script>
|
||||
<script type="text/x-handlebars-template" id="children">
|
||||
{{#.}}
|
||||
{{#if ServerDetails}}
|
||||
{{#with ServerDetails}}
|
||||
{{#if ClientDetails}}
|
||||
{{#with ClientDetails}}
|
||||
<tr>
|
||||
<td>{{spaces ../Level}}{{ts Start}}</td><td>{{duration .}}</td>
|
||||
<td>{{../PID}}</td><td>{{FromAddr}}:{{FromPort}}</td>
|
||||
<td>{{ToAddr}}:{{ToPort}}</td><td>{{count ../.}}</tr>
|
||||
{{/with}}
|
||||
{{else}}
|
||||
{{#with ClientDetails}}
|
||||
{{#with ServerDetails}}
|
||||
<tr>
|
||||
<td>{{spaces ../Level}}{{ts Start}}</td><td>{{duration .}}</td>
|
||||
<td>{{../PID}}</td><td>{{FromAddr}}:{{FromPort}}</td>
|
||||
|
||||
Reference in New Issue
Block a user