Пример #1
0
func NewOvsSFlowProbesHandlerFromConfig(tb *probes.TopologyProbeBundle, g *graph.Graph, p *mappings.FlowMappingPipeline, a *analyzer.Client) *OvsSFlowProbesHandler {
	probe := tb.GetProbe("ovsdb")
	if probe == nil {
		return nil
	}

	agent, err := sflow.NewSFlowAgentFromConfig(g)
	if err != nil {
		logging.GetLogger().Errorf("Unable to start an OVS SFlow probe handler: %s", err.Error())
		return nil
	}
	agent.SetMappingPipeline(p)

	if a != nil {
		agent.SetAnalyzerClient(a)
	}

	expire := config.GetConfig().GetInt("cache.expire")
	cleanup := config.GetConfig().GetInt("cache.cleanup")

	o := NewOvsSFlowProbesHandler(probe.(*probes.OvsdbProbe), agent, expire, cleanup)

	agent.SetProbePathGetter(o)

	return o
}
Пример #2
0
func NewOvsSFlowProbesHandler(tb *probes.TopologyProbeBundle, g *graph.Graph, m *mappings.FlowMappingPipeline, a *analyzer.Client) *OvsSFlowProbesHandler {
	probe := tb.GetProbe("ovsdb")
	if probe == nil {
		logging.GetLogger().Error("Agent.ovssflow probe depends on agent.ovsdb topology probe: agent.ovssflow probe can't start properly")
		return nil
	}
	p := probe.(*probes.OvsdbProbe)

	o := &OvsSFlowProbesHandler{
		Graph:     g,
		ovsClient: p.OvsMon.OvsClient,
		allocator: sflow.NewSFlowAgentAllocator(a, m),
	}

	return o
}