chris.naude

LUA - Escalate alarm when value increases

Discussion created by chris.naude on Mar 17, 2011
Latest reply on Mar 18, 2011 by chris.naude

I wrote this simple LUA script so that I can escalate an alarm when a value increases. Basically an alarm comes in that says "Alert value is 500." Then 5 minutes later another message (same supp key) says "Alert value is 510." Based on this the script will figure out that 510 is greater than 500 and escalate the alarm. So far it's working quite well. Anyone else done something similar? I'm sure there is a better way to do this, but I'm new to LUA. :smileyhappy:

 

 

args=SCRIPT_ARGUMENT --args="is ([%d]+)" a = alarm.get() nimid=a.nimid trans = alarm.transactions(nimid)  t = {} for a,b in pairs(trans) do    my_msg = trans[a].message    --printf("message[%s] => %s",a,my_msg)    start,endpos,cur_val = string.find(my_msg,args)    t[a] = tonumber(cur_val) end  if #t > 1 and a.severity ~= "clear" then    c_val = t[1]    p_val = t[2]    if c_val >= p_val then       printf("Auto escalating %s because %s >= %s.",nimid,c_val,p_val)       action.escalate(5,nimid)    end end

Outcomes