Beispiel #1
0
func InitCfcProxy() error {
	s := tcp.NewServer(GlobalConfig.TCP_BIND, &handle{})
	proxy = &CfcProxy{
		s,
		&tcp.Session{},
		HostPluginList{M: make(map[string][]types.Plugin)},
	}
	return proxy.srv.ListenAndServe()
}
Beispiel #2
0
func InitInspector() error {
	server := tcp.NewServer("", &InspectorHandle{})
	server.SetMaxPacketSize(uint32(GlobalConfig.MAX_PACKET_SIZE))
	inspector = &Inspector{server, nil, NewTaskPool(GlobalConfig.MAX_TASK_BUFFER), NewResultPool(GlobalConfig.MAX_RESULT_BUFFER)}
	go inspector.DialForever()
	go inspector.HeartBeatForever()
	go inspector.GetInspectorTasksForever()
	go inspector.ProcessInspectorTasksForever()
	go inspector.SendResultForever()
	return nil
}
Beispiel #3
0
func InitNetCollect() error {
	s := tcp.NewServer("", &handle{})
	c := &NetCollect{}
	c.srv = s
	c.tsdBuffer = make(chan *types.TimeSeriesData, GlobalConfig.BUFFER_SIZE)
	c.metricBuffer = make(chan *types.MetricConfig, GlobalConfig.BUFFER_SIZE)
	c.switchs = []*types.Switch{}
	c.repeater = &tcp.Session{}
	c.cfc = &tcp.Session{}
	netCollect = c
	return nil
}
Beispiel #4
0
func InitAgent() error {
	s := tcp.NewServer(GlobalConfig.TCP_BIND, &cfcHandle{})
	agent = Agent{
		"",
		s,
		&tcp.Session{},
		&tcp.Session{},
		make(chan types.TimeSeriesData, GlobalConfig.BUFFER_SIZE),
		make(map[string]float64),
	}
	return agent.ListenAndServe()
}
Beispiel #5
0
func InitController() error {
	controllerServer := tcp.NewServer(GlobalConfig.TCP_BIND, &ControllerHandle{})
	controllerServer.SetMaxPacketSize(uint32(GlobalConfig.MAX_PACKET_SIZE))
	if err := controllerServer.ListenAndServe(); err != nil {
		return err
	}
	lg.Info("Start listen: %v", GlobalConfig.TCP_BIND)

	controller = &Controller{controllerServer,
		NewTaskPool(GlobalConfig.TASK_POOL_SIZE),
		NewResultPool(GlobalConfig.RESULT_POOL_SIZE),
		NewResultPool(GlobalConfig.RESULT_POOL_SIZE),
		NewNodePool()}

	go controller.loadStrategiesiForever()
	go controller.processStrategyResultForever()
	go controller.checkNodesForever()
	return nil
}
Beispiel #6
0
func InitRepeater() error {
	s := tcp.NewServer(GlobalConfig.TCP_BIND, &handle{})
	repeater = &Repeater{}
	repeater.srv = s
	repeater.buffer = make(chan []byte, GlobalConfig.BUFFER_SIZE)
	switch GlobalConfig.BACKEND {
	case "opentsdb":
		backend, err := backend.NewOpentsdbBackend(GlobalConfig.OPENTSDB_ADDR)
		if err != nil {
			return err
		}
		repeater.backend = backend
	case "repeater":
		backend, err := backend.NewRepeaterBackend(GlobalConfig.REPEATER_ADDR)
		if err != nil {
			return err
		}
		repeater.backend = backend
	default:
		return errors.New(fmt.Sprintf("unsupported backend %s", GlobalConfig.BACKEND))
	}
	return repeater.srv.ListenAndServe()
}
Beispiel #7
0
func InitCfc() error {
	cfcServer = tcp.NewServer(GlobalConfig.TCP_BIND, &handle{})
	return cfcServer.ListenAndServe()
}