mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 09:41:57 +00:00
Make it lint and compile after rebase.
This commit is contained in:
@@ -45,8 +45,9 @@ func (t *tracer) pidsForContainer(id string) ([]int, error) {
|
||||
return pidTree.GetChildren(container.PID())
|
||||
}
|
||||
|
||||
// Container is the type exported by the HTTP API.
|
||||
type Container struct {
|
||||
Id string
|
||||
ID string
|
||||
Name string
|
||||
PIDs []int
|
||||
}
|
||||
@@ -66,7 +67,7 @@ func (t *tracer) http(port int) {
|
||||
children, _ := pidTree.GetChildren(container.PID())
|
||||
out := Container{
|
||||
Name: strings.TrimPrefix(container.Container().Name, "/"),
|
||||
Id: container.ID(),
|
||||
ID: container.ID(),
|
||||
PIDs: children,
|
||||
}
|
||||
containers = append(containers, out)
|
||||
|
||||
@@ -54,31 +54,31 @@ func newKey(fd *ptrace.Fd) key {
|
||||
return key{fromAddr, fd.FromPort, fd.Start}
|
||||
}
|
||||
|
||||
func (l key) LessThan(other skiplist.Comparable) bool {
|
||||
func (k key) LessThan(other skiplist.Comparable) bool {
|
||||
r := other.(key)
|
||||
|
||||
if l.fromAddr != r.fromAddr {
|
||||
return l.fromAddr > r.fromAddr
|
||||
if k.fromAddr != r.fromAddr {
|
||||
return k.fromAddr > r.fromAddr
|
||||
}
|
||||
|
||||
if l.fromPort != r.fromPort {
|
||||
return l.fromPort < r.fromPort
|
||||
if k.fromPort != r.fromPort {
|
||||
return k.fromPort < r.fromPort
|
||||
}
|
||||
|
||||
if l.Equal(other) {
|
||||
if k.Equal(other) {
|
||||
return false
|
||||
}
|
||||
|
||||
return l.startTime < r.startTime
|
||||
return k.startTime < r.startTime
|
||||
}
|
||||
|
||||
func (l key) Equal(other skiplist.Comparable) bool {
|
||||
func (k key) Equal(other skiplist.Comparable) bool {
|
||||
r := other.(key)
|
||||
if l.fromAddr != r.fromAddr || l.fromPort != r.fromPort {
|
||||
if k.fromAddr != r.fromAddr || k.fromPort != r.fromPort {
|
||||
return false
|
||||
}
|
||||
|
||||
diff := l.startTime - r.startTime
|
||||
diff := k.startTime - r.startTime
|
||||
return -epsilon < diff && diff < epsilon
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ func (s *store) RecordConnection(pid int, connection *ptrace.Fd) {
|
||||
}
|
||||
}
|
||||
|
||||
// IncrementLevel ...
|
||||
func IncrementLevel(trace *trace, increment int) {
|
||||
trace.Level += increment
|
||||
for _, child := range trace.Children {
|
||||
|
||||
@@ -29,6 +29,7 @@ var (
|
||||
tcpRegexp = regexp.MustCompile(tcpPattern)
|
||||
)
|
||||
|
||||
// ConnectionDetails ...
|
||||
type ConnectionDetails struct {
|
||||
direction int
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ const (
|
||||
ptraceTracesysgoodBit = 0x80
|
||||
)
|
||||
|
||||
// Store ...
|
||||
type Store interface {
|
||||
RecordConnection(int, *Fd)
|
||||
}
|
||||
@@ -58,6 +59,7 @@ func NewPTracer(store Store) PTracer {
|
||||
return t
|
||||
}
|
||||
|
||||
// Stop stop stop
|
||||
func (t *PTracer) Stop() {
|
||||
out := make(chan []int)
|
||||
t.ops <- func() {
|
||||
|
||||
@@ -52,7 +52,7 @@ type thread struct {
|
||||
|
||||
currentIncoming map[int]*Fd
|
||||
currentOutgoing map[int]*Fd
|
||||
closedOutgoing []*Fd
|
||||
closedOutgoing []*Fd
|
||||
}
|
||||
|
||||
func newThread(pid int, process *process, tracer *PTracer) *thread {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
var traces = [];
|
||||
|
||||
Handlebars.registerHelper('isSelected', function(input) {
|
||||
if (currentContainer && input === currentContainer.Id) {
|
||||
if (currentContainer && input === currentContainer.ID) {
|
||||
return 'class=selected';
|
||||
}
|
||||
});
|
||||
@@ -122,14 +122,14 @@
|
||||
containersByID = {};
|
||||
containersByPID = {};
|
||||
$.each(data, function(i, container) {
|
||||
containersByID[container.Id] = container
|
||||
containersByID[container.ID] = container
|
||||
$.each(container.PIDs, function(i, pid) {
|
||||
containersByPID[pid] = container
|
||||
});
|
||||
});
|
||||
// auto-select first container
|
||||
if (containers.length && currentContainer === null) {
|
||||
currentContainer = containersByID[containers[0].Id];
|
||||
currentContainer = containersByID[containers[0].ID];
|
||||
}
|
||||
render();
|
||||
window.setTimeout(updateContainers, 5 * 1000);
|
||||
@@ -183,14 +183,14 @@
|
||||
$("body").on("click", "div.mainview button.start", function() {
|
||||
var id = $(this).parent().data("containerId")
|
||||
var container = containersByID[id]
|
||||
$.post(sprintf("/container/%s", container.Id))
|
||||
$.post(sprintf("/container/%s", container.ID))
|
||||
})
|
||||
|
||||
$("body").on("click", "div.mainview button.stop", function() {
|
||||
var id = $(this).parent().data("containerId")
|
||||
var container = containersByID[id]
|
||||
$.ajax({
|
||||
url: sprintf("/container/%s", container.Id),
|
||||
url: sprintf("/container/%s", container.ID),
|
||||
type: 'DELETE',
|
||||
});
|
||||
})
|
||||
@@ -353,7 +353,7 @@
|
||||
<div class="heading">Containers</div>
|
||||
<ul class="containers">
|
||||
{{#containers}}
|
||||
<li {{isSelected Id}} id={{Id}}>{{Name}}</li>
|
||||
<li {{isSelected ID}} id={{ID}}>{{Name}}</li>
|
||||
{{/containers}}
|
||||
</ul>
|
||||
</div>
|
||||
@@ -361,7 +361,7 @@
|
||||
<div class="col-md-8 mainview">
|
||||
{{#if container}}
|
||||
<h2 class="pull-left">{{container.Name}}</h2>
|
||||
<div class="btn-group btn-group-sm" role="group" data-container-id="{{container.Id}}">
|
||||
<div class="btn-group btn-group-sm" role="group" data-container-id="{{container.ID}}">
|
||||
<button type="button" class="btn btn-default start">
|
||||
<span class="fa fa-play" aria-hidden="true"></span> Start</button>
|
||||
<button type="button" class="btn btn-default stop">
|
||||
|
||||
@@ -53,7 +53,7 @@ func (pt *tree) GetChildren(pid int) ([]int, error) {
|
||||
}
|
||||
|
||||
children := []int{pid}
|
||||
for id, _ := range pt.processes {
|
||||
for id := range pt.processes {
|
||||
if isChild(id) {
|
||||
children = append(children, id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user