Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status: list available probes in status api #756

Merged
merged 1 commit into from
Feb 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 12 additions & 0 deletions probe/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ func (p *ProbeBundle) GetProbe(name string) Probe {
return nil
}

//ActiveProbes returns all active probes name
func (p *ProbeBundle) ActiveProbes() []string {
p.RLock()
defer p.RUnlock()

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