mirror of
https://github.com/weaveworks/scope.git
synced 2026-08-19 04:16:21 +00:00
Add flag to disable reporting of processes (and procspied endpoints)
This commit is contained in:
+19
-22
@@ -25,14 +25,14 @@ const (
|
||||
|
||||
// Reporter generates Reports containing the Endpoint topology.
|
||||
type Reporter struct {
|
||||
hostID string
|
||||
hostName string
|
||||
includeProcesses bool
|
||||
includeNAT bool
|
||||
flowWalker flowWalker // interface
|
||||
scanner procspy.ConnectionScanner
|
||||
natMapper natMapper
|
||||
reverseResolver *reverseResolver
|
||||
hostID string
|
||||
hostName string
|
||||
spyProcs bool
|
||||
walkProc bool
|
||||
flowWalker flowWalker // interface
|
||||
scanner procspy.ConnectionScanner
|
||||
natMapper natMapper
|
||||
reverseResolver *reverseResolver
|
||||
}
|
||||
|
||||
// SpyDuration is an exported prometheus metric
|
||||
@@ -52,15 +52,16 @@ var SpyDuration = prometheus.NewSummaryVec(
|
||||
// on the host machine, at the granularity of host and port. That information
|
||||
// is stored in the Endpoint topology. It optionally enriches that topology
|
||||
// with process (PID) information.
|
||||
func NewReporter(hostID, hostName string, includeProcesses bool, useConntrack bool, scanner procspy.ConnectionScanner) *Reporter {
|
||||
func NewReporter(hostID, hostName string, spyProcs, useConntrack, walkProc bool, scanner procspy.ConnectionScanner) *Reporter {
|
||||
return &Reporter{
|
||||
hostID: hostID,
|
||||
hostName: hostName,
|
||||
includeProcesses: includeProcesses,
|
||||
flowWalker: newConntrackFlowWalker(useConntrack),
|
||||
natMapper: makeNATMapper(newConntrackFlowWalker(useConntrack, "--any-nat")),
|
||||
reverseResolver: newReverseResolver(),
|
||||
scanner: scanner,
|
||||
hostID: hostID,
|
||||
hostName: hostName,
|
||||
spyProcs: spyProcs,
|
||||
walkProc: walkProc,
|
||||
flowWalker: newConntrackFlowWalker(useConntrack),
|
||||
natMapper: makeNATMapper(newConntrackFlowWalker(useConntrack, "--any-nat")),
|
||||
reverseResolver: newReverseResolver(),
|
||||
scanner: scanner,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +136,8 @@ func (r *Reporter) Report() (report.Report, error) {
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
conns, err := r.scanner.Connections(r.includeProcesses)
|
||||
if r.walkProc {
|
||||
conns, err := r.scanner.Connections(r.spyProcs)
|
||||
if err != nil {
|
||||
return rpt, err
|
||||
}
|
||||
@@ -174,10 +175,6 @@ func (r *Reporter) Report() (report.Report, error) {
|
||||
}
|
||||
|
||||
func (r *Reporter) addConnection(rpt *report.Report, t fourTuple, extraFromNode, extraToNode map[string]string) {
|
||||
// Update endpoint topology
|
||||
if !r.includeProcesses {
|
||||
return
|
||||
}
|
||||
var (
|
||||
fromEndpointNodeID = report.MakeEndpointNodeID(r.hostID, t.fromAddr, strconv.Itoa(int(t.fromPort)))
|
||||
toEndpointNodeID = report.MakeEndpointNodeID(r.hostID, t.toAddr, strconv.Itoa(int(t.toPort)))
|
||||
|
||||
@@ -69,12 +69,11 @@ func TestSpyNoProcesses(t *testing.T) {
|
||||
)
|
||||
|
||||
scanner := procspy.FixedScanner(fixConnections)
|
||||
reporter := endpoint.NewReporter(nodeID, nodeName, false, false, scanner)
|
||||
reporter := endpoint.NewReporter(nodeID, nodeName, false, false, false, scanner)
|
||||
r, _ := reporter.Report()
|
||||
//buf, _ := json.MarshalIndent(r, "", " ")
|
||||
//t.Logf("\n%s\n", buf)
|
||||
|
||||
// No process nodes, please
|
||||
if want, have := 0, len(r.Endpoint.Nodes); want != have {
|
||||
t.Fatalf("want %d, have %d", want, have)
|
||||
}
|
||||
@@ -87,7 +86,7 @@ func TestSpyWithProcesses(t *testing.T) {
|
||||
)
|
||||
|
||||
scanner := procspy.FixedScanner(fixConnectionsWithProcesses)
|
||||
reporter := endpoint.NewReporter(nodeID, nodeName, true, false, scanner)
|
||||
reporter := endpoint.NewReporter(nodeID, nodeName, true, false, true, scanner)
|
||||
r, _ := reporter.Report()
|
||||
// buf, _ := json.MarshalIndent(r, "", " ") ; t.Logf("\n%s\n", buf)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user