AnsweredAssumed Answered

NAS Lua script to close inactive/idle alarms

Question asked by DanielDMarques on Oct 14, 2015
Latest reply on Oct 15, 2015 by DanielDMarques



You can create a NAS auto-operator profile that operates on messages that are over a certain age, which I believe is based on the arrival time.  I wanted to close alarms that had not been updated in over 7 days based on the received time in the alarm subconsole.  I did not see any way to do this in an AO profile


I discovered that there is no field in the alarm database for the received time, and I concluded that the received time listed in the alarm subconsole is based on either the arrival time or the suppression time


I need a script to remove alarms that are frozen without receiving new alarms (supression time). I found the script below authorship "keith_k" but not working, they could help?


There seems to be an error in line 30


-- -- Close any alarms that have not been updated recently --  -- Number of days ago the last update to an alarm must have arrived alarm_idle_days = 30  -- Start with empty list of alarms to close close_list = "" close_count = 0  -- Reference time for comparison with most recent update time ref_time = os.time() - alarm_idle_days * 86400  -- All open alarms in a list alarms = alarm.list()  if alarms ~= nil then    for i = 1, #alarms do        -- Determine alarm received time based on suppression time if available,       -- otherwise the arrival time       if alarms.supptime == nil or alarms.supptime == 0 then          recv_time = alarms.arrival       else          recv_time = alarms.supptime       end        -- Check if alarm was received before reference time       if recv_time < ref_time then          close_count = close_count + 1          close_list = close_list .. alarms.nimid .. ","       end    end end  -- Close alarms without updates since the reference time if close_list ~= "" then    print("Closing " .. close_count .. " alarms: " .. close_list)    action.close(close_list) end