for {
select {
case event := <-r.eventsCh:
+ r.log.Noticef("got event with thing=%s, action=%s, tags=<%+v>\n", event.ItemType, event.Event, event.Tags)
r.stats.eventsReceived.WithLabelValues(mbclient.KV{"thing": event.ItemType, "action": event.Event}).Add(1)
if event.ItemType == "host" && event.Event == "seen" {
if via, ok := event.Tags["via"]; !ok || via != "dhcp" {
mu sync.Mutex `json:"-"`
log *log.Logger
- Sites map[string]*machines.Site `json:"Sites"`
- Domains map[string]*machines.Domain `json:"Domains"`
- Hosts map[string]*machines.Host `json:"Hosts"`
- Ifaces map[string]*machines.Iface `json:"Ifaces"`
- Records map[string]map[recordKey][]*machines.DNSRecord `json:"Records"`
- HostNames map[string]string `json:"-"`
- Addrs *machines.RouterAddresses `json:"-"`
+ Sites map[string]*machines.Site `json:"Sites"`
+ Domains map[string]*machines.Domain `json:"Domains"`
+ Hosts map[string]*machines.Host `json:"Hosts"`
+ Ifaces map[string]*machines.Iface `json:"Ifaces"`
+ Records map[string]map[recordKey][]*machines.DNSRecord `json:"Records"`
+ HostNames map[string]string `json:"-"`
+ HostInterfaceNames map[string]string `json:"-"`
+ Addrs *machines.RouterAddresses `json:"-"`
}
type recordKey string
rs.Addrs = ras
rs.HostNames = make(map[string]string)
+ rs.HostInterfaceNames = make(map[string]string)
rs.Hosts = make(map[string]*machines.Host)
for _, h := range hosts {
h.Name = strings.ToLower(h.Name)
rs.Ifaces = make(map[string]*machines.Iface)
for _, i := range ifaces {
rs.Ifaces[i.ID()] = i
+ if i.Host.ID() != "" {
+ if host, ok := rs.Hosts[i.Host.ID()]; ok {
+ key := fmt.Sprintf("%s.%s", strings.ToLower(i.NameScrubbed), strings.ToLower(host.Name))
+ rs.HostInterfaceNames[key] = i.ID()
+ }
+ }
}
// loop through again and populate LastSeenIface
for _, i := range ifaces {