hi,
i have changed the script to the next one: (trying to look for the last hour critical alerts which visible and contain NetworkTeam stirng on message and not updated on time recived field - all works great until i changed line 13 - the time_origin to time_supp - do you know what is wrong at what i have done?
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
the error i get:
Error in line 13: bad argument #1 to 'fromISO' (string expected, got nil)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
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"))
for _,a in pairs(alarms) do
local time_diff = timestamp.diff(timestamp.fromISO(a.time_supp),"hours", timestamp.now())
local print_line = 0
if (a.level == 5 and time_diff > 1 and string.match(a.message, "NetworkTeam") and a.visible == 1) then
table.insert(t_close_alarms, a.nimid)
print_line = 1
end
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
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)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------
regards