コード例 #1
0
ファイル: skydive_analyzer.go プロジェクト: razorinc/skydive
func main() {
	filename := flag.String("conf", "/etc/skydive/skydive.ini",
		"Config file with all the skydive parameter.")
	flag.Parse()

	err := config.InitConfig(*filename)
	if err != nil {
		panic(err)
	}

	mapper := mappings.NewFlowMapper()
	drivers, err := getInterfaceMappingDrivers()
	if err != nil {
		panic(err)
	}
	mapper.SetInterfaceMappingDrivers(drivers)

	elasticsearch := elasticseach.GetInstance("127.0.0.1", 9200)

	analyzer := analyzer.NewAnalyzer(mapper, elasticsearch)

	fmt.Println("Skydive Analyzer started !")
	listener, err := net.Listen("tcp", "127.0.0.1:8888")
	if err != nil {
		panic(err)
	}

	for {
		if conn, err := listener.Accept(); err == nil {
			go handleMessage(conn, analyzer)
		} else {
			continue
		}
	}
}
コード例 #2
0
ファイル: skydive_agent.go プロジェクト: razorinc/skydive
func main() {
	filename := flag.String("conf", "/etc/skydive/skydive.ini",
		"Config file with all the skydive parameter.")
	flag.Parse()

	err := config.InitConfig(*filename)
	if err != nil {
		panic(err)
	}

	quit = make(chan bool)

	sflowAgent := agents.NewSFlowAgent("127.0.0.1", 6345)

	ovsSFlowAgent := ovsdb.SFlowAgent{
		ID:         "SkydiveSFlowAgent",
		Interface:  "eth0",
		Target:     sflowAgent.GetTarget(),
		HeaderSize: 256,
		Sampling:   1,
		Polling:    0,
	}
	sflowHandler := ovsdb.NewOvsSFlowAgentsHandler([]ovsdb.SFlowAgent{ovsSFlowAgent})

	ovsmon := ovsdb.NewOvsMonitor("127.0.0.1", 6400)
	ovsmon.AddMonitorHandler(sflowHandler)

	topo := topology.NewTopology()
	root := topo.NewContainer("root", topology.Root)

	ns := topology.NewNetNSTopoUpdater(topo)
	ns.Start()

	nl := topology.NewNetLinkTopoUpdater(root)
	nl.Start()

	ovs := topology.NewOvsTopoUpdater(topo, ovsmon)
	ovs.Start()

	mapper := mappings.NewFlowMapper()
	drivers, err := getInterfaceMappingDrivers(topo)
	if err != nil {
		panic(err)
	}
	mapper.SetInterfaceMappingDrivers(drivers)
	sflowAgent.SetFlowMapper(mapper)

	analyzer, err := analyzer.NewClient("127.0.0.1", 8888)
	if err != nil {
		panic(err)
	}
	sflowAgent.SetAnalyzerClient(analyzer)
	sflowAgent.Start()

	ovsmon.StartMonitoring()

	fmt.Println("Skydive Agent started !")
	<-quit
}