How to export alarms from nas to a file using a script

Document ID : KB000034011
Last Modified Date : 14/02/2018
Show Technical Document Details
--This LUA script outputs active alarm information to a csv file. It can be edited to include more alarm data. It is "sorted"
--by severity, Critical first, then Major, etc... It can be run manually from the NAS (scripts) or run from a NAS schedule.

local buffer = ""
-- Delete the target file so we don't keep appending to it.
file.delete ("C:\\myAlarm.csv")
-- Get all critical alarms
al = alarm.list ("severity","Critical")
if al ~= nil then
for i,a in pairs(al) do
buffer = (buffer .. a.nimid .. "," .. a.severity .. "," ..
a.message .. "\n")
end
end
-- now all major alarms
al = alarm.list ("severity","Major")
if al ~= nil then
for i,a in pairs(al) do
buffer = (buffer .. a.nimid .. "," .. a.severity .. "," ..
a.message .. "\n")
end
end
-- now all minor alarms
al = alarm.list ("severity","Minor")
if al ~= nil then
for i,a in pairs(al) do
buffer = (buffer .. a.nimid .. "," .. a.severity .. "," ..
a.message .. "\n")
end
end
-- now all warning alarms
al = alarm.list ("severity","Warning")
if al ~= nil then
for i,a in pairs(al) do
buffer = (buffer .. a.nimid .. "," .. a.severity .. "," ..
a.message .. "\n")
end
end

-- now all informational alarms
al = alarm.list ("severity","Informational") if al ~= nil then
for i,a in pairs(al) do
buffer = (buffer .. a.nimid .. "," .. a.severity .. "," ..
a.message .. "\n")
end
end

fstat=file.write ("C:\\myAlarm.csv",buffer) if fstat ~= false then
print("File written")
end


See also:

http://docs.nimsoft.com/prodhelp/en_US/Probes/Catalog/nas/3.6/index.htm?toc.htm?1942546.html?zoom_highlight=alarm.history