Implements stateful alerts in C and sqlite

This commit is contained in:
Simone Mainardi 2016-08-11 19:56:49 +02:00
parent 781b3d4988
commit 12f24a87b4
11 changed files with 425 additions and 214 deletions

View file

@ -287,6 +287,13 @@ alert_type_keys = {
{ "<i class='fa fa-exclamation'></i> Suspicious Activity", 10, "suspicious_activity" },
}
alert_entity_keys = {
{ "Interface", 0, "interface" },
{ "Host", 1, "host" },
{ "Network", 2, "network" },
{ "SNMP device", 3, "snmp_device" }
}
function alertSeverityLabel(v)
return(_handleArray(alert_level_keys, tonumber(v)))
end
@ -311,6 +318,18 @@ function alertType(v)
return(_handleArray(typetable, v))
end
function alertEntityLabel(v)
return(_handleArray(alert_entity_keys, tonumber(v)))
end
function alertEntity(v)
local typetable = {}
for i, t in ipairs(alert_entity_keys) do
typetable[#typetable + 1] = {t[2], t[3]}
end
return(_handleArray(typetable, v))
end
function firstToUpper(str)
str = tostring(str)
return (str:gsub("^%l", string.upper))