keith_k

NAS script to close idle alarms

Discussion created by keith_k on Sep 29, 2011
Latest reply on Sep 30, 2011 by keith_k

The script below can be run by an AO profile to determine if the matching alarm has been "idle" for a certain amount of time and then close the alarm. It can be useful to clear out alarms that do not automatically clear when the problem condition goes away. The script takes an argument that specifies the number of seconds it has been since the last update to the alarm for the script to consider the alarm idle. Note that this script can be dangerous when processing alarms that originate on the other side of a tunnel; if the tunnel is down long enough, the alarm will look like it is idle.

 

The AO profile needs to be configured to run on an interval so that the matching alarm keeps getting checked against the idle threshold.

 

(The reason the function is saved in a table is that the function is actually stored in a separate file on my system, which is loaded as a library. I have combined them here for convenience.)

 

-Keith

 

-------------------------------------------------------------------------------- -- close-idle-alarm -- -- Close alarm if the received time is older than the idle time (in seconds) -- passed in as the argument. --------------------------------------------------------------------------------  alarm_op = {} function alarm_op.received (al)    -- Use suppression time if alarm was suppressed    if al.supptime ~= nil then       return al.supptime    end     -- Use arrival time if never suppressed    return al.arrival end  -- 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 al = alarm.get()  -- Check alarm if al == nil then    print("ERROR: Script must be run by AO profile")    return end  -- Last time alarm was received local rcvd_time = alarm_op.received(al)  -- 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 rcvd_time < ref_time then    action.close(al.nimid)    print("Closed alarm: "..al.nimid) end

Outcomes