예제 #1
0
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
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
}
예제 #3
0
func InitConfig(t *testing.T, conf string, params ...HelperParams) {
	f, err := ioutil.TempFile("", "skydive_agent")
	if err != nil {
		t.Fatal(err.Error())
	}

	if len(params) == 0 {
		params = []HelperParams{make(HelperParams)}
	}
	params[0]["AnalyzerPort"] = 64500
	if testing.Verbose() {
		params[0]["LogLevel"] = "DEBUG"
	} else {
		params[0]["LogLevel"] = "INFO"
	}

	tmpl, err := template.New("config").Parse(conf)
	if err != nil {
		t.Fatal(err.Error())
	}
	buff := bytes.NewBufferString("")
	tmpl.Execute(buff, params[0])

	f.Write(buff.Bytes())
	f.Close()

	t.Logf("Configuration: %s", buff.String())

	err = config.InitConfig("file", f.Name())
	if err != nil {
		t.Fatal(err.Error())
	}

	err = logging.InitLogger()
	if err != nil {
		t.Fatal(err)
	}
}
예제 #4
0
	"github.com/spf13/cobra"
)

var (
	showVersion bool
	cfgPath     string
	cfgBackend  string
)

var rootCmd = &cobra.Command{
	Use:          "skydive [sub]",
	Short:        "Skydive",
	SilenceUsage: true,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		if cfgPath != "" {
			if err := config.InitConfig(cfgBackend, cfgPath); err != nil {
				fmt.Fprintf(os.Stderr, "%v\n", err)
				os.Exit(1)
			}
		}
	},
}

var versionCmd = &cobra.Command{
	Use:   "version",
	Short: "Print the version number of Skydive",
	Run: func(cmd *cobra.Command, args []string) {
		version.PrintVersion()
	},
}