Esempio n. 1
0
func main() {
	configFilePath := flag.String("configPath", "", "path to the configuration file")

	flag.Parse()

	conf := config.Configuration(*configFilePath)

	if len(conf.Syslog) > 0 {
		logging.SetSysLogger(conf.Syslog)
	}
	logging.SetLevel(conf.LogLevel)

	dropsonde.Initialize("localhost:"+strconv.Itoa(conf.MetronPort), valuemetricsender.ForwarderOrigin)

	go func() {
		err := tcp.Open(conf.IncomingPort, forwarder.StartMessageForwarder(valuemetricsender.NewValueMetricSender()))
		if err != nil {
			logging.Log.Panic("Could not open the TCP port", err)
		}
	}()

	logging.Log.Info("Bosh HM forwarder initialized")

	infoHandler := handlers.NewInfoHandler()
	router := mux.NewRouter()
	router.Handle("/info", infoHandler).Methods("GET")

	if conf.DebugPort > 0 {
		go pprofServer(conf.DebugPort)
	}

	logging.Log.Info(fmt.Sprintf("Starting Info Server on port %d", conf.InfoPort))

	err := http.ListenAndServe(net.JoinHostPort("", fmt.Sprintf("%d", conf.InfoPort)), router)
	if err != nil {
		logging.Log.Panic("Failed to start up alerter: ", err)
	}
}
		unit:              unit,
	}
	f.passedParametersCh <- parameters

	return nil
}

var _ = Describe("MessageForwarder", func() {
	Context("Forwards the message", func() {
		var (
			fakeSender *fakeValueMetricSender
			messageCh  chan<- string
		)
		BeforeEach(func() {
			fakeSender = newFakeValueMetricSender()
			messageCh = forwarder.StartMessageForwarder(fakeSender)
		})

		It("should write messages to the sender", func(done Done) {
			defer close(done)
			messageCh <- "put system.healthy 1445463675 1 deployment=metrix-bosh-lite index=2 job=etcd role=unknown"
			var received *SendValueMetricParamaters
			Eventually(fakeSender.passedParametersCh).Should(Receive(&received))
			expectedParameters := SendValueMetricParamaters{
				deployment:        "metrix-bosh-lite",
				job:               "etcd",
				index:             "2",
				eventName:         "system.healthy",
				secondsSinceEpoch: 1445463675,
				value:             1.0,
				unit:              "b",