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

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

book

Article ID: 34011

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM) CA Unified Infrastructure Management On-Premise (Nimsoft / UIM) CA Unified Infrastructure Management SaaS (Nimsoft / UIM)

Issue/Introduction

-- This nas 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.

Environment

Release: Any
Component: UIMNAS

Resolution

-- 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