From 9348e1c4af8046862f7f653fa6b1559c24f9393f Mon Sep 17 00:00:00 2001 From: Masco Kaliyamoorthy Date: Fri, 2 Feb 2018 12:44:37 +0530 Subject: [PATCH] status: list available probes in status api --- agent/agent.go | 12 ++++++++---- analyzer/server.go | 1 + api/types/types.go | 1 + probe/bundle.go | 9 +++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 69384900e1..22b8b313fc 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -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 @@ -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(), } } diff --git a/analyzer/server.go b/analyzer/server.go index 9ec9b9de25..247c78451c 100644 --- a/analyzer/server.go +++ b/analyzer/server.go @@ -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(), } } diff --git a/api/types/types.go b/api/types/types.go index 949be7e570..344e5e6e17 100644 --- a/api/types/types.go +++ b/api/types/types.go @@ -75,6 +75,7 @@ type AnalyzerStatus struct { Subscribers map[string]shttp.WSConnStatus Alerts ElectionStatus Captures ElectionStatus + Probes []string } // Capture describes a capture API diff --git a/probe/bundle.go b/probe/bundle.go index 34e29354e7..7105ba5ac5 100644 --- a/probe/bundle.go +++ b/probe/bundle.go @@ -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()