Skip to content

Commit

Permalink
status: list available probes in status api
Browse files Browse the repository at this point in the history
  • Loading branch information
masco committed Feb 2, 2018
1 parent 1daae94 commit 9348e1c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
12 changes: 8 additions & 4 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ type AnalyzerConnStatus struct {

// AgentStatus represents the status of an agent
type AgentStatus struct {
Clients map[string]shttp.WSConnStatus
Analyzers map[string]AnalyzerConnStatus
Clients map[string]shttp.WSConnStatus
Analyzers map[string]AnalyzerConnStatus
TopologyProbes []string
FlowProbes []string
}

// GetStatus returns the status of an agent
Expand All @@ -112,8 +114,10 @@ func (a *Agent) GetStatus() interface{} {
}

return &AgentStatus{
Clients: a.wsServer.GetStatus(),
Analyzers: analyzers,
Clients: a.wsServer.GetStatus(),
Analyzers: analyzers,
TopologyProbes: a.topologyProbeBundle.ActiveProbes(),
FlowProbes: a.flowProbeBundle.ActiveProbes(),
}
}

Expand Down
1 change: 1 addition & 0 deletions analyzer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (s *Server) GetStatus() interface{} {
Subscribers: s.subscriberWSServer.GetStatus(),
Alerts: types.ElectionStatus{IsMaster: s.alertServer.IsMaster()},
Captures: types.ElectionStatus{IsMaster: s.onDemandClient.IsMaster()},
Probes: s.probeBundle.ActiveProbes(),
}
}

Expand Down
1 change: 1 addition & 0 deletions api/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ type AnalyzerStatus struct {
Subscribers map[string]shttp.WSConnStatus
Alerts ElectionStatus
Captures ElectionStatus
Probes []string
}

// Capture describes a capture API
Expand Down
9 changes: 9 additions & 0 deletions probe/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ func (p *ProbeBundle) GetProbe(name string) Probe {
return nil
}

//ActiveProbes returns all active probes name
func (p *ProbeBundle) ActiveProbes() []string {
activeProbes := make([]string, 0, len(p.probes))
for k := range p.probes {
activeProbes = append(activeProbes, k)
}
return activeProbes
}

// AddProbe adds a probe to the bundle
func (p *ProbeBundle) AddProbe(name string, probe Probe) {
p.RLock()
Expand Down

0 comments on commit 9348e1c

Please sign in to comment.