From c2b97cbabde746f1a413ff4fb40a0ae426c48213 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Mon, 21 Aug 2023 07:56:18 +1000 Subject: [PATCH] Report fix + missing-in-last-scan functionality --- pialert/plugin.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pialert/plugin.py b/pialert/plugin.py index 3703efa0..44aa0763 100755 --- a/pialert/plugin.py +++ b/pialert/plugin.py @@ -563,17 +563,18 @@ def process_plugin_events(db, plugin, pluginsState, plugEventsArr): index += 1 # Loop thru events and check if previously available objects are missing - # Create a set of hashes of IDs in pluginObjects - plugin_objects_ids_hash = set(x.idsHash for x in pluginObjects) + for tmpObj in pluginObjects: + + isMissing = True - for tmpObjFromEvent in pluginEvents: - if tmpObjFromEvent.idsHash not in plugin_objects_ids_hash: - for x in pluginObjects: - if x.primaryId == tmpObjFromEvent.primaryId and x.secondaryId == tmpObjFromEvent.secondaryId: - mylog('debug', ['[Plugins] Missing from last scan: ', x.primaryId , x.secondaryId]) - x.status = "missing-in-last-scan" - x.changed = datetime.now(timeZone).strftime("%Y-%m-%d %H:%M:%S") - break + for tmpObjFromEvent in pluginEvents: + if tmpObj.idsHash == tmpObjFromEvent.idsHash: + isMissing = False + + if isMissing: + tmpObj.status = "missing-in-last-scan" + tmpObj.changed = timeNowTZ() + mylog('debug', ['[Plugins] Missing from last scan: ', x.primaryId , x.secondaryId]) # Merge existing plugin objects with newly discovered ones and update existing ones with new values