mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Make use of Hosts and Envs
This commit is contained in:
parent
468623d3cd
commit
fef7d94508
2 changed files with 22 additions and 4 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package configobject
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.icinga.com/icingadb/icingadb-json-decoder"
|
||||
"git.icinga.com/icingadb/icingadb-main/supervisor"
|
||||
"git.icinga.com/icingadb/icingadb-utils"
|
||||
|
|
@ -120,21 +119,25 @@ func (h Host) UpdateValues() []interface{} {
|
|||
return v
|
||||
}
|
||||
|
||||
func (h *Host) GetId() string {
|
||||
func (h Host) GetId() string {
|
||||
return h.Id
|
||||
}
|
||||
|
||||
func (h *Host) SetId(id string) {
|
||||
func (h Host) SetId(id string) {
|
||||
h.Id = id
|
||||
}
|
||||
|
||||
func HostOperator(super *supervisor.Supervisor) error {
|
||||
chBack := make(chan *icingadb_json_decoder.JsonDecodePackage)
|
||||
var hosts = map[[20]byte]*Host{}
|
||||
|
||||
//get checksums from redis
|
||||
go func() {
|
||||
res, err := super.Rdbw.HGetAll("icinga:config:checksum:host")
|
||||
count := len(res)
|
||||
|
||||
hosts = make(map[[20]byte]*Host, count)
|
||||
|
||||
if err != nil {
|
||||
super.ChErr <- err
|
||||
return
|
||||
|
|
@ -154,7 +157,7 @@ func HostOperator(super *supervisor.Supervisor) error {
|
|||
}()
|
||||
|
||||
for ret := range chBack {
|
||||
fmt.Println(ret)
|
||||
hosts[ret.Id] = ret.Row.(*Host)
|
||||
count--
|
||||
if 0 == count {
|
||||
close(chBack)
|
||||
|
|
|
|||
15
main.go
15
main.go
|
|
@ -41,6 +41,21 @@ func main() {
|
|||
chErr <- configobject.HostOperator(&super)
|
||||
}()
|
||||
|
||||
for {
|
||||
select {
|
||||
case err := <- chErr:
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
case env := <- super.ChEnv: {
|
||||
if env != nil {
|
||||
log.Print("Got env: " + hex.EncodeToString(env.ID))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//go create object type supervisors
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue