func run() {
	if err := aggregations.Init(configFile.DataConfig().DataLocation, configFile.DataConfig().TTL, errorChannel); err != nil {
		log.Fatalf("Initialization error: %s", err)
	}

	if err := graphite.Init(configFile, errorChannel); err != nil {
		log.Fatalf("Initialization error: %s", err)
	}

	if config.CLIConfig.IsPiping {
		payload, err := ioutil.ReadAll(os.Stdin)

		if err != nil {
			errorChannel <- err
		}

		agent.ProcessPipeRequest(configFile, errorChannel, completionChannel, payload)
	} else if config.CLIConfig.IsNotifying {
		agent.ProcessNotificationRequest(configFile, errorChannel, completionChannel, config.CLIConfig.NotificationChannel, config.CLIConfig.NotificationFlow, config.CLIConfig.Notification)
	} else {
		if configFile.ListenAddress() != "" {
			if err := server.Init(configFile, errorChannel); err != nil {
				log.Fatal("Web server initialization error: %s", err)
			}
		}

		_, err := job.NewJobManager(configFile, errorChannel, completionChannel)

		if err != nil {
			log.Fatalf("Initialization error: %s", err)
		}
	}
}
예제 #2
0
func run() {
	if err := aggregations.Init(configFile.DataConfig().Listen, configFile.DataConfig().DataLocation, configFile.DataConfig().TTL, errorChannel); err != nil {
		log.Fatalf("Initialization error: %s", err)
	}

	if err := graphite.Init(configFile, errorChannel); err != nil {
		log.Fatalf("Initialization error: %s", err)
	}

	oauth.Init(configFile.OAuthConfig())

	if config.CLIConfig.IsPiping {
		payload, err := ioutil.ReadAll(os.Stdin)

		if err != nil {
			errorChannel <- err
		}

		agent.ProcessPipeRequest(configFile, errorChannel, completionChannel, payload)
	} else if config.CLIConfig.IsNotifying {
		agent.ProcessNotificationRequest(configFile, errorChannel, completionChannel, config.CLIConfig.NotificationChannel, config.CLIConfig.NotificationFlow, config.CLIConfig.Notification)
	} else if config.CLIConfig.OAuthCommand != config.OAuthCommands.None {
		oauth.RunCommand(config.CLIConfig, errorChannel, completionChannel)
	} else {
		_, err := job.NewJobManager(configFile, errorChannel, completionChannel)

		if err != nil {
			log.Fatalf("Initialization error: %s", err)
		}
	}
}
예제 #3
0
func BenchmarkGraphiteMemory(b *testing.B) {
	cfg := config.ConfigFile{}
	cfg.Graphite = config.GraphiteConfig{
		UDPListenPort: ":2000",
	}

	errorChannel := make(chan error, 1)

	go func() {
		for e := range errorChannel {
			b.Logf("%s", e)
		}
	}()

	p := ":2000"
	l := "/tmp/agent.db"
	ttl := "1h"
	aggregations.Init(&p, &l, &ttl, errorChannel)

	Init(&cfg, errorChannel)

	for n := 0; n < b.N; n++ {
		testGraphiteMemoryRun(b, 1)
	}

}
예제 #4
0
func TestSeries(t *testing.T) {
	l := "/tmp/agent.bolt"
	ttl := "1h"
	aggregations.Init(nil, &l, &ttl, make(chan error, 99999))

	ts := float64(time.Now().Unix() + 10)
	tss := fmt.Sprintf("%g", ts)

	runTests(
		t,
		[]test{
			{"Series", `local st = require("telemetry/storage"); st.series("test")`, shouldNotError},
			{"Series name", `local st = require("telemetry/storage"); output.out = st.series("test").name()`, map[string]interface{}{"out": "test"}},
			{"Series trim since by timestamp", `local st = require("telemetry/storage"); st.series("test").trimSince(os.time() - (60 * 2))`, shouldNotError},
			{"Series trim since by duration", `local st = require("telemetry/storage"); st.series("test").trimSince("2m")`, shouldNotError},
			{"Series trim by count", `local st = require("telemetry/storage"); st.series("test").trimCount(30)`, shouldNotError},
			{"Series push", `local st = require("telemetry/storage"); st.series("test").push(123)`, shouldNotError},
			{"Series pop", `local st = require("telemetry/storage"); s = st.series("test"); s.push(125, "` + tss + `"); output.out = s.pop(true)`, map[string]interface{}{"out": map[string]interface{}{"value": 125.0, "ts": ts}}},
			{"Series last", `local st = require("telemetry/storage"); s = st.series("test"); s.push(126, "` + tss + `"); output.out = s.last()`, map[string]interface{}{"out": map[string]interface{}{"value": 126.0, "ts": ts}}},
			{"Series compute by timestamp", `local os = require("os"); local st = require("telemetry/storage"); output.out = st.series("test").compute(st.Functions.SUM, os.time() - 10000000, os.time() + 10000)`, shouldNotError},
			{"Series compute by interval", `local os = require("os"); local st = require("telemetry/storage"); output.out = st.series("test").compute(st.Functions.SUM, "6m")`, shouldNotError},
			{"Series get raw items", `local os = require("os"); local st = require("telemetry/storage"); output.out = st.series("test").items(10)`, shouldNotError},
			{"Series aggregate", `local os = require("os"); local st = require("telemetry/storage"); output.out = st.series("test").aggregate(st.Functions.SUM, 60, 10, os.time())`, resultValidator(func(t *testing.T, err error, res map[string]interface{}) bool {
				return err == nil && len(res["out"].([]interface{})) == 10
			})},
			{"Series aggregate no end time", `local os = require("os"); local st = require("telemetry/storage"); output.out = st.series("test").aggregate(st.Functions.SUM, 60, 10)`, resultValidator(func(t *testing.T, err error, res map[string]interface{}) bool {
				return err == nil && len(res["out"].([]interface{})) == 10
			})},
			{"Series aggregate string interval", `local os = require("os"); local st = require("telemetry/storage"); output.out = st.series("test").aggregate(st.Functions.SUM, "1m", 10)`, resultValidator(func(t *testing.T, err error, res map[string]interface{}) bool {
				return err == nil && len(res["out"].([]interface{})) == 10
			})},
			{"Series values", `local os = require("os"); local st = require("telemetry/storage"); output.out = st.series("test").aggregate(st.Functions.SUM, 60, 10, os.time()).values()`, resultValidator(func(t *testing.T, err error, res map[string]interface{}) bool {
				return err == nil && len(res["out"].([]interface{})) == 10
			})},
			{"Series timestamps", `local os = require("os"); local st = require("telemetry/storage"); output.out = st.series("test").aggregate(st.Functions.SUM, 60, 10, os.time()).ts()`, resultValidator(func(t *testing.T, err error, res map[string]interface{}) bool {
				return err == nil && len(res["out"].([]interface{})) == 10
			})},
		},
	)
}