Exemple #1
0
// Init method initializes the Sensu structure with the provided configuration and start the Uchiwa daemon
func Init(c *config.Config) *Uchiwa {

	// Get the datacenters
	datacenters := initDatacenters(c)

	d := &daemon.Daemon{
		Data:        &structs.Data{},
		Datacenters: datacenters,
		Enterprise:  c.Uchiwa.Enterprise,
	}

	u := &Uchiwa{
		Config:       c,
		Daemon:       d,
		Data:         &structs.Data{},
		Datacenters:  datacenters,
		Mu:           &sync.Mutex{},
		PublicConfig: c.GetPublic(),
	}

	// start Uchiwa daemon and listen for results over data channel
	interval := c.Uchiwa.Refresh
	data := make(chan *structs.Data, 1)
	go d.Start(interval, data)
	go u.listener(interval, data)

	return u
}
Exemple #2
0
// Init method initializes the Sensu structure with the provided configuration and start the Uchiwa daemon
func Init(c *config.Config) *Uchiwa {

	// build datacenters list from configuration
	datacenters := make([]sensu.Sensu, len(c.Sensu))
	for i, datacenter := range c.Sensu {
		datacenter := sensu.New(datacenter.Name, datacenter.Path, datacenter.URL, datacenter.Timeout, datacenter.User, datacenter.Pass, datacenter.Insecure)
		datacenters[i] = *datacenter
	}

	d := &daemon.Daemon{
		Data:        &structs.Data{},
		Datacenters: &datacenters,
		Enterprise:  c.Uchiwa.Enterprise,
	}

	u := &Uchiwa{
		Config:       c,
		Daemon:       d,
		Data:         &structs.Data{},
		Datacenters:  &datacenters,
		Mu:           &sync.Mutex{},
		PublicConfig: c.GetPublic(),
	}

	// start Uchiwa daemon and listen for results over data channel
	interval := c.Uchiwa.Refresh
	data := make(chan *structs.Data, 1)
	go d.Start(interval, data)
	go u.listener(interval, data)

	return u
}