Example - LUA script - close alarm
search cancel

Example - LUA script - close alarm

book

Article ID: 188806

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM)

Issue/Introduction

Example - LUA script  - close alarm

Environment

Any UIM Version

Resolution

run this script in AO profiles that generally have intervals in hours or days. Some run like every 15 minutes but have specific match criteria to avoid doing that on a lot of alarms.

-- Get idle time from script argument
local idle_time = tonumber(SCRIPT_ARGUMENT)

-- Check argument
if idle_time == nil then
   print("ERROR: Idle time must be passed in as the script argument")
   return
end

-- Get alarm that kicked this script
local a = alarm.get()

-- Check alarm
if a == nil then
   print("ERROR: Script must be run by AO profile")
   return
end

-- Use arrival time as received time by default
local received = a.arrival

-- Use suppression time if alarm was suppressed
if a.supptime ~= nil then
   received = a.supptime
end

-- Reference time is idle_time seconds ago
local ref_time = os.time() - idle_time

-- Close alarm if received time is prior to reference time
if received < ref_time then
   action.close(a.nimid)
   print("Closed alarm: "..a.nimid)​