Esempio n. 1
0
func TestSFlowAgent(t *testing.T) {
	helper.InitConfig(t, confAgentAnalyzer)

	router := mux.NewRouter().StrictSlash(true)
	server, err := analyzer.NewServerFromConfig(router)
	if err != nil {
		t.Fatal(err)
	}

	ts := NewTestStorage()
	server.SetStorage(ts)
	go server.ListenAndServe()
	defer server.Stop()

	agent := helper.StartAgent(t)
	defer agent.Stop()

	time.Sleep(1 * time.Second)
	for _, trace := range flowsTraces {
		fulltrace, _ := filepath.Abs("pcaptraces" + string(filepath.Separator) + trace.filename)
		helper.ReplayTraceHelper(t, fulltrace, "localhost:55000")

		/* FIXME (nplanel) remove this Sleep when agent.FlushFlowTable() exist */
		time.Sleep(2 * time.Second)
		ts.Validate(t, &trace)
	}
}
Esempio n. 2
0
func NewAnalyzerStorage(t *testing.T, s storage.Storage) *analyzer.Server {
	server, err := analyzer.NewServerFromConfig()
	if err != nil {
		t.Fatal(err)
	}

	server.SetStorage(s)
	return server
}
Esempio n. 3
0
func StartAgentAndAnalyzerWithConfig(t *testing.T, conf string, s storage.Storage) (*agent.Agent, *analyzer.Server) {
	InitConfig(t, conf)

	router := mux.NewRouter().StrictSlash(true)
	server, err := analyzer.NewServerFromConfig(router)
	if err != nil {
		t.Fatal(err)
	}

	server.SetStorage(s)

	go server.ListenAndServe()

	return StartAgent(), server
}
Esempio n. 4
0
func main() {
	filename := flag.String("conf", "/etc/skydive/skydive.ini",
		"Config file with all the skydive parameter.")
	flag.CommandLine.Usage = usage
	flag.Parse()

	err := config.InitConfigFromFile(*filename)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%v\n", err)
		os.Exit(1)
	}

	logging.GetLogger().Notice("Skydive Analyzer starting...")

	router := mux.NewRouter().StrictSlash(true)

	server, err := analyzer.NewServerFromConfig(router)
	if err != nil {
		logging.GetLogger().Fatalf("Can't start Analyzer : %v", err)
	}

	storage, err := elasticseach.New()
	if err != nil {
		logging.GetLogger().Fatalf("Can't connect to ElasticSearch server : %v", err)
	}
	server.SetStorage(storage)

	logging.GetLogger().Notice("Skydive Analyzer started !")
	go server.ListenAndServe()

	ch := make(chan os.Signal)
	signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
	<-ch

	server.Stop()

	logging.GetLogger().Notice("Skydive Analyzer stopped.")
}
Esempio n. 5
0
	"github.com/redhat-cip/skydive/storage/elasticsearch"

	"github.com/spf13/cobra"
)

var Analyzer = &cobra.Command{
	Use:          "analyzer",
	Short:        "Skydive analyzer",
	Long:         "Skydive analyzer",
	SilenceUsage: true,
	Run: func(cmd *cobra.Command, args []string) {
		logging.GetLogger().Notice("Skydive Analyzer starting...")

		router := mux.NewRouter().StrictSlash(true)

		server, err := analyzer.NewServerFromConfig(router)
		if err != nil {
			logging.GetLogger().Fatalf("Can't start Analyzer : %v", err)
		}

		storage, err := elasticseach.New()
		if err != nil {
			logging.GetLogger().Fatalf("Can't connect to ElasticSearch server : %v", err)
		}
		server.SetStorage(storage)

		logging.GetLogger().Notice("Skydive Analyzer started !")
		go server.ListenAndServe()

		ch := make(chan os.Signal)
		signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)