mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Support 'contains' op in alerts
This commit is contained in:
parent
9bd30a049a
commit
6c9dd9f7df
1 changed files with 15 additions and 2 deletions
|
|
@ -243,11 +243,24 @@ function alert_store:build_sql_cond(cond)
|
|||
|
||||
-- Number
|
||||
elseif cond.value_type == 'number' then
|
||||
sql_cond = string.format("%s %s %u", cond.field, sql_op, cond.value)
|
||||
if cond.op == 'in' then
|
||||
sql_cond = 'bitAnd(' .. cond.field .. ', ' .. cond.value .. ') = ' .. cond.value
|
||||
elseif cond.op == 'nin' then
|
||||
sql_cond = cond.field .. '!=' .. cond.value .. '/' .. cond.value
|
||||
else
|
||||
sql_cond = string.format("%s %s %u", cond.field, sql_op, cond.value)
|
||||
end
|
||||
|
||||
-- String
|
||||
else
|
||||
sql_cond = string.format("%s %s '%s'", cond.field, sql_op, cond.value)
|
||||
if cond.op == 'in' then
|
||||
sql_cond = cond.field .. ' LIKE ' .. string.format("'%%%s%%'", cond.value)
|
||||
elseif cond.op == 'nin' then
|
||||
sql_cond = cond.field .. ' NOT LIKE ' .. string.format("'%%%s%%'", cond.value)
|
||||
else
|
||||
-- Any other operator
|
||||
sql_cond = string.format("%s %s '%s'", cond.field, sql_op, cond.value)
|
||||
end
|
||||
end
|
||||
|
||||
return sql_cond
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue