-- -- close alarms based on message, probe or time (uncomment and change what you need) -- local debug = 0 local t_close_alarms = {} local t_time = {} local alarms = alarm.list() local now = timestamp.now() t_time["hour"] = tonumber(timestamp.format(now, "%H")) t_time["day"] = tonumber(timestamp.format(now, "%w")) -- --- start loop --- for _,a in pairs(alarms) do -- match on message -- if string.match(a.message,'syslog_generic') then -- match on probe name if string.match(a.prid,'alarm_generator') then -- match on time (hour) (time fields: a.arrival, a.time.origin, ) -- local time_diff = timestamp.diff(timestamp.fromISO(a.time_origin),"hours", timestamp.now()) -- if (time_diff > 1) then local print_line = 0 table.insert(t_close_alarms, a.nimid) print_line = 1 if print_line == 1 and debug == 1 then printf("%s: %s - %d: %d", a.nimid, a.time_origin, timestamp.diff(timestamp.fromISO(a.time_origin), "hours", timestamp.now()),a.level) end end end -- --- end loop --- -- do now the real close/ack of all alarms in the temporary table local s_close_alarms = table.concat(t_close_alarms, ",") printf("closing %d alarms: %s", #t_close_alarms, s_close_alarms) action.close(s_close_alarms)