Replace JSON string with TLV for alerts generated by the datapath. This removes a JSON decode in housekeeping.lua (#3148)

This commit is contained in:
Alfredo Cardigliano 2019-12-27 17:03:28 +01:00
parent 8caed2a438
commit 2a3bef9d6c
7 changed files with 191 additions and 75 deletions

View file

@ -2548,24 +2548,18 @@ function checkStoreAlertsFromC(deadline)
end
while(os.time() <= deadline) do
local message = ntop.popInternalAlerts()
local alert = ntop.popInternalAlerts()
if((message == nil) or (message == "")) then
if alert == nil then
break
end
if(verbose) then print(message.."\n") end
if(verbose) then tprint(alert) end
local alert = json.decode(message)
local entity_info, type_info = processStoreAlertFromQueue(alert)
if(alert == nil) then
if(verbose) then io.write("JSON Decoding error: "..message.."\n") end
else
local entity_info, type_info = processStoreAlertFromQueue(alert)
if((type_info ~= nil) and (entity_info ~= nil)) then
alerts_api.store(entity_info, type_info, alert.alert_tstamp)
end
if((type_info ~= nil) and (entity_info ~= nil)) then
alerts_api.store(entity_info, type_info, alert.alert_tstamp)
end
end
end