josh_cowpland

Using Timestamps in Lua

Discussion created by josh_cowpland on Feb 20, 2012
Latest reply on Feb 20, 2012 by 1_keithk

Hi,
I'm hoping you might be able to assist with a lua scripting issue I'm having. I have created the following script to close down and alerts generated by the cdm probe where the alert count is less than 52. This script is run every morning at 07:05, and so closes down the alerts generated between 18:00 and 07:00. Ideally, I would prefer the script to use the timestamp values rather than the alarm count so that the script can be run at any time. Is there someway of using the .time_arrival and truncating the date part of the timestamp?

Script:
--Author: Joshua Cowpland
--Date: 16/02/2012
--Purpose: Clears all alerts generated during the 18:00 to 7:00 window during which Netbackup runs.

--get all alarms from the cdm probe
al=alarm.list("prid","cdm")

--if the alarm list isn't empty
if al ~= nil then
-- for each alarm in the list
for i=1, #al do
--place alarm into a for readibility
a = al[i]
-- cdm monitors memory ever 15mins, i.e. max alarm count of 52 between 18:00 and 7:00
if a.suppcount < 52 then
-- close alarm if it has been generated between 18:00 and 7:00
action.close(a.nimid)
end
end
end


Any help would be appreciated!
Thanks,
Josh

Outcomes