Exemple #1
0
func statsCollect() {
	if graphiteServer != "" {
		addr, err := net.ResolveTCPAddr("tcp", graphiteServer)
		if err != nil {
			go metrics.Graphite(metrics.DefaultRegistry, 10e9, "skydns", addr)
		}
	}
	if stathatUser != "" {
		go stathat.Stathat(metrics.DefaultRegistry, 10e9, stathatUser)
	}

	if influxConfig.Host != "" {
		go influxdb.Influxdb(metrics.DefaultRegistry, 10e9, influxConfig)
	}
}
Exemple #2
0
func main() {
	toRecorder := make(chan Measurement)
	toWebsocket := make(chan Measurement)

	if config.LibratoEmail != "" && config.LibratoToken != "" && config.LibratoSource != "" {
		log.Println("fn=main metrics=librato")
		go librato.Librato(metrics.DefaultRegistry,
			10e9,                  // interval
			config.LibratoEmail,   // account owner email address
			config.LibratoToken,   // Librato API token
			config.LibratoSource,  // source
			[]float64{50, 95, 99}, // precentiles to send
			time.Millisecond,      // time unit
		)
	}

	if config.LogStderr == true {
		go metrics.Log(metrics.DefaultRegistry, 10e9, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))
	}

	if config.InfluxdbHost != "" &&
		config.InfluxdbDatabase != "" &&
		config.InfluxdbUser != "" &&
		config.InfluxdbPassword != "" {
		log.Println("fn=main metrics=influxdb")

		go influxdb.Influxdb(metrics.DefaultRegistry, 10e9, &influxdb.Config{
			Host:     config.InfluxdbHost,
			Database: config.InfluxdbDatabase,
			Username: config.InfluxdbUser,
			Password: config.InfluxdbPassword,
		})
	}

	connectToRedis(config)

	go runWebsocketHub(wsHub)
	go httpServer(config, wsHub)
	go udpServer(config.Port, toRecorder, toWebsocket)
	go websocketWriter(config, wsHub, toWebsocket)

	recorder := NewRecorder(client, config.Publish)
	go recordMeasurements(config, recorder, toRecorder)

	select {}
}
Exemple #3
0
// Burst sends our local information after recieving the server's burst.
func Burst() {
	for _, script := range ActiveConfig.Autoload {
		LoadScript(script)
	}

	for _, client := range Services {
		Conn.SendLine(client.Euid())
		if client.Certfp != "" {
			Conn.SendLine(":%s ENCAP * CERTFP :%s", client.Uid, client.Certfp)
		}

		client.Join(ActiveConfig.General.SnoopChan)
	}

	for _, channel := range Channels {
		for uid := range channel.Clients {
			if !strings.HasPrefix(uid, Info.Sid) {
				continue
			}
			str := fmt.Sprintf(":%s SJOIN %d %s + :%s", Info.Sid, channel.Ts, channel.Name, uid)
			Conn.SendLine(str)
		}
	}

	metrics.Register("clientcount", Clients.Gauge)

	if ActiveConfig.Stats.Host != "NOCOLLECTION" {
		go GetNetworkStats()
		go GetChannelStats()

		go influxdb.Influxdb(metrics.DefaultRegistry, 5*time.Minute, &influxdb.Config{
			Host:     ActiveConfig.Stats.Host,
			Database: ActiveConfig.Stats.Database,
			Username: ActiveConfig.Stats.Username,
			Password: ActiveConfig.Stats.Password,
		})

		metrics.Register(ActiveConfig.Server.Name+"_clients", Info.Counter)
	}

	Bursted = true

	RunHook("BURSTED")
}
Exemple #4
0
func Collect() {
	// Set up metrics if specified on the command line
	if metricsToStdErr {
		go metrics.Log(metrics.DefaultRegistry, 60e9, log.New(os.Stderr, "metrics: ", log.Lmicroseconds))
	}

	if len(graphiteServer) > 1 {
		addr, err := net.ResolveTCPAddr("tcp", graphiteServer)
		if err != nil {
			go metrics.Graphite(metrics.DefaultRegistry, 10e9, "skydns", addr)
		}
	}

	if len(stathatUser) > 1 {
		go stathat.Stathat(metrics.DefaultRegistry, 10e9, stathatUser)
	}

	if influxConfig.Host != "" {
		go influxdb.Influxdb(metrics.DefaultRegistry, 10e9, influxConfig)
	}
}