|
|
|
@ -108,11 +108,14 @@ func genContent(isUpgrade bool, events []*models.Event) (string, string) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resources := getResources(events)
|
|
|
|
|
|
|
|
|
|
metric := strings.Join(metricList, ",")
|
|
|
|
|
|
|
|
|
|
status := genStatus(events)
|
|
|
|
|
sname := events[cnt-1].Sname
|
|
|
|
|
endpoint := genEndpoint(events)
|
|
|
|
|
name, note := genNameAndNoteByResources(resources)
|
|
|
|
|
tags := genTags(events)
|
|
|
|
|
value := events[cnt-1].Value
|
|
|
|
|
info := events[cnt-1].Info
|
|
|
|
@ -156,6 +159,8 @@ func genContent(isUpgrade bool, events []*models.Event) (string, string) {
|
|
|
|
|
"Status": status,
|
|
|
|
|
"Sname": sname,
|
|
|
|
|
"Endpoint": endpoint,
|
|
|
|
|
"Name": name,
|
|
|
|
|
"Note": note,
|
|
|
|
|
"CurNodePath": curNodePath,
|
|
|
|
|
"Metric": metric,
|
|
|
|
|
"Tags": tags,
|
|
|
|
@ -282,6 +287,38 @@ func HostBindingsForMon(endpointList []string) ([]string, error) {
|
|
|
|
|
return list, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getResources(events []*models.Event) []models.Resource {
|
|
|
|
|
idents := []string{}
|
|
|
|
|
for i := 0; i < len(events); i++ {
|
|
|
|
|
idents = append(idents, events[i].Endpoint)
|
|
|
|
|
}
|
|
|
|
|
resources, err := models.ResourcesByIdents(idents)
|
|
|
|
|
if err != nil {
|
|
|
|
|
logger.Errorf("get resources by idents failed : %v", err)
|
|
|
|
|
}
|
|
|
|
|
return resources
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func genNameAndNoteByResources(resources []models.Resource) (name, note string) {
|
|
|
|
|
names := []string{}
|
|
|
|
|
notes := []string{}
|
|
|
|
|
for i := 0; i < len(resources); i++ {
|
|
|
|
|
names = append(names, resources[i].Name)
|
|
|
|
|
notes = append(notes, resources[i].Note)
|
|
|
|
|
}
|
|
|
|
|
names = config.Set(names)
|
|
|
|
|
notes = config.Set(notes)
|
|
|
|
|
|
|
|
|
|
if len(resources) == 1 {
|
|
|
|
|
name = names[0]
|
|
|
|
|
note = notes[0]
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
name = fmt.Sprintf("%s(%v)", strings.Join(names, ","), len(names))
|
|
|
|
|
note = fmt.Sprintf("%s(%v)", strings.Join(notes, ","), len(notes))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func getEndpoint(events []*models.Event) []string {
|
|
|
|
|
endpointList := []string{}
|
|
|
|
|
for i := 0; i < len(events); i++ {
|
|
|
|
|