diff --git a/modules/agent/common/helper.go b/modules/agent/common/helper.go index 7e2775be..48b12429 100644 --- a/modules/agent/common/helper.go +++ b/modules/agent/common/helper.go @@ -373,6 +373,9 @@ func GetLatestOnlineAgentIDs(agentIds []string, lastSeconds int) (map[string]str }, }, } + if len(agentIds) == 0 { + queryDSL["size"] = 2000 + } q.RawQuery = util.MustToJSONBytes(queryDSL) err, result := orm.Search(event.Event{}, &q) if err != nil { diff --git a/modules/agent/state/state.go b/modules/agent/state/state.go index f6d982f8..b833f956 100644 --- a/modules/agent/state/state.go +++ b/modules/agent/state/state.go @@ -109,7 +109,9 @@ func (sm *StateManager) checkAgentStatus() { return } // status change to online + sm.agentMutex.Lock() sm.agentIds[agentID] = model.StatusOnline + sm.agentMutex.Unlock() log.Infof("status of agent [%s] changed to online", agentID) return }else{ @@ -119,7 +121,9 @@ func (sm *StateManager) checkAgentStatus() { } } // status change to offline + sm.agentMutex.Lock() sm.agentIds[agentID] = model.StatusOffline + sm.agentMutex.Unlock() ag, err := sm.GetAgent(agentID) if err != nil { if err != elastic.ErrNotFound {