diff --git a/src/models/mon_stra.go b/src/models/mon_stra.go index f00bacde..98321f87 100644 --- a/src/models/mon_stra.go +++ b/src/models/mon_stra.go @@ -230,6 +230,11 @@ func StraDel(id int64) error { return session.Commit() } +func StraDelByNid(nid int64) error { + _, err := DB["mon"].Where("nid=?", nid).Delete(new(Stra)) + return err +} + func StrasList(name string, priority int, nid int64) ([]*Stra, error) { session := DB["mon"].NewSession() defer session.Close() diff --git a/src/models/node.go b/src/models/node.go index 7e168ecd..00ef4f03 100644 --- a/src/models/node.go +++ b/src/models/node.go @@ -577,6 +577,8 @@ func GetLeafNidsForMon(nid int64, exclNid []int64) ([]int64, error) { } if node == nil { + // 节点已经被删了,相关的告警策略也删除 + StraDelByNid(nid) return []int64{}, nil }