Esempio n. 1
0
func main() {
	cli.SetupLogging()
	options := cli.ParseArguments()

	ins, err := inspeqtor.New(options.ConfigDirectory, options.SocketPath)
	if err != nil {
		log.Fatalln(err)
	}
	err = ins.Parse()
	if err != nil {
		log.Fatalln(err)
	}

	if options.TestConfig {
		util.Info("Configuration parsed ok.")
		os.Exit(0)
	} else if options.TestAlertRoutes {
		ins.TestAlertRoutes()
	} else {
		// Fire up the Inspeqtor singleton
		ins.Start()

		// Install the global signal handlers
		// This method never returns.
		inspeqtor.HandleSignals()
	}
}
Esempio n. 2
0
func main() {
	inspeqtor.Name = "Inspeqtor Pro"

	cli.StartupInfo = func() {
	}

	cli.SetupLogging()
	options := cli.ParseArguments()

	_, err := verifyLicense(options.ConfigDirectory)
	if err != nil {
		util.Warn("Error verifying license file: %s", err)
		os.Exit(127)
	}

	ins, err := inspeqtor.New(options.ConfigDirectory, options.SocketPath)
	if err != nil {
		log.Fatalln(err)
	}
	err = ins.Parse()
	if err != nil {
		log.Fatalln(err)
	}

	err = bootstrapJobs(ins, options.ConfigDirectory)
	if err != nil {
		log.Fatalln(err)
	}

	err = bootstrapStatsd(ins, options.ConfigDirectory)
	if err != nil {
		log.Fatalln(err)
	}

	err = expose.Bootstrap(ins)
	if err != nil {
		log.Fatalln(err)
	}

	if options.TestConfig {
		util.Info("Configuration parsed ok.")
		os.Exit(0)
	} else if options.TestAlertRoutes {
		ins.TestAlertRoutes()
	} else {
		ins.Start()
		inspeqtor.HandleSignals()
	}
}
func TestBuildAction(t *testing.T) {
	t.Parallel()

	i, err := inspeqtor.New("test", "")
	assert.Nil(t, err)
	assert.NotNil(t, i)

	err = i.Parse()
	assert.Nil(t, err)
	for _, r := range i.Services[0].Rules() {
		for _, a := range r.Actions {
			assert.NotNil(t, a)
		}
	}
}
Esempio n. 4
0
func TestStatsd(t *testing.T) {

	conn, err := Dial("localhost:9909")
	assert.NotNil(t, conn)
	assert.Nil(t, err)

	conn.Close()

	i, err := inspeqtor.New("../test", "")
	assert.NotNil(t, i)
	assert.Nil(t, err)

	err = i.Parse()
	assert.Nil(t, err)

	var buff bytes.Buffer
	Export(&buff, i)

	actual := string(buff.Bytes())

	assert.Contains(t, actual, "local.host.cpu:0.00|c")
	assert.Contains(t, actual, "local.host.cpu.iowait:0.00|c")
	assert.Contains(t, actual, "local.host.cpu.steal:0.00|c")
	assert.Contains(t, actual, "local.host.cpu.system:0.00|c")
	assert.Contains(t, actual, "local.host.cpu.user:0.00|c")
	assert.Contains(t, actual, "local.host.disk./:-1.00|g")
	assert.Contains(t, actual, "local.host.load.1:-1.00|g")
	assert.Contains(t, actual, "local.host.load.15:-1.00|g")
	assert.Contains(t, actual, "local.host.load.5:-1.00|g")
	assert.Contains(t, actual, "local.host.swap:-1.00|g")
	assert.Contains(t, actual, "local.homebrew.mxcl.memcached.cpu.system:0.00|c")
	assert.Contains(t, actual, "local.homebrew.mxcl.memcached.cpu.total_system:0.00|c")
	assert.Contains(t, actual, "local.homebrew.mxcl.memcached.cpu.total_user:0.00|c")
	assert.Contains(t, actual, "local.homebrew.mxcl.memcached.cpu.user:0.00|c")
	assert.Contains(t, actual, "local.homebrew.mxcl.memcached.memory.rss:-1.00|g")
}