amit_saxena

Forwarding alarms from Nimsoft to a 3rd party tool through LUA

Discussion created by amit_saxena on May 30, 2011

Hi,

 

My requirement is to forward alarms from RSP probe  to a 3rd party tool through an external perl script provided by the 3rd party tool. At present, Nimsoft is polling for devices every 5 minutes and I need to call that perl script so as to send the alert to the 3rd party tool.

 

Initially I thought of using on-arrival option in auto operator in nas but decided against it because it does not ensures resending the failed alarms when the connectivity is restored between Nimsoft and 3rd party tool.

 

To overcome this limitation, I opted for using alarms.list to iterate over all active alarms from RSP probe and using the custom tag 1 for synchronization i.e. keeping a check which alarm is already sent and which one is recently de-duplicated and hence need to be sent.

 

The logic for custom tag 1 is as follows.

 

1) Process alarm only under following conditions

      a) If the custom tag 1 flag is not set

      b) If the custom tag 1 flag is set and time populated in custom tag 1 is not same as the suppression time of the alarm

      c) If the custom tag is not populated with "Error"

 

2) If the suppression time of the current alarm is not nil, populate custom tag 1 with suppression time of the current alarm else populate custom tag 1 with arrival time of the alarm

 

3) Finally, populate the custom tag with "Error" in case the perl program returns with an error.

 

The screenshots of the LUA script and the equivalent profile are mentioned below. Please suggest whether there is a better way for the same and also what changes I need to do so as to ensure that the perl script is called only when the severity changes from the previous one in case of de-duplication.

 

LUA Script

 

 

printf ("Script execution started....\n")  active_alarms=alarm.list("prid","%rsp%") if active_alarms ~= nil then    for i=1,#active_alarms do     current_alarm = active_alarms[i]        if current_alarm.nimid == nil then           local b1          b1 = { nimid = current_alarm.nimid, nimid = "N/A" }          alarm.set (b1)       end        if current_alarm.hostname == nil then           local b1          b1 = { nimid = current_alarm.nimid, hostname = "N/A" }          alarm.set (b1)       end        if current_alarm.source == nil then           local b1          b1 = { nimid = current_alarm.nimid, source = "N/A" }          alarm.set (b1)       end        if current_alarm.nimts == nil then           local b1          b1 = { nimid = current_alarm.nimid, nimts = -1 }          alarm.set (b1)       end        if current_alarm.level == nil then           local b1          b1 = { nimid = current_alarm.nimid, level = -1 }          alarm.set (b1)       end        if current_alarm.origin == nil then           local b1          b1 = { nimid = current_alarm.nimid, origin = "N/A" }          alarm.set (b1)       end        if current_alarm.message == nil then           local b1          b1 = { nimid = current_alarm.nimid, message = "N/A" }          alarm.set (b1)       end        if current_alarm.prid == nil then           local b1          b1 = { nimid = current_alarm.nimid, prid = "N/A" }          alarm.set (b1)       end        if current_alarm.supp_key == nil then           local b1          b1 = { nimid = current_alarm.nimid, supp_key = "N/A" }          alarm.set (b1)       end        if current_alarm.suppcount == nil then           local b1          b1 = { nimid = current_alarm.nimid, suppcount = -1 }          alarm.set (b1)       end        if ( current_alarm.custom_1 == nil ) or ( current_alarm.custom_1 ~= nil and current_alarm.custom_1 ~= current_alarm.supptime ) or ( current_alarm.custom_1 ~= "Error" ) then           if current_alarm.supptime ~= nil then                      local a1             a1 = { nimid = current_alarm.nimid, custom_1 = current_alarm.supptime }             alarm.set (a1)          else             local a1             a1 = { nimid = current_alarm.nimid, custom_1 = current_alarm.arrival }             alarm.set (a1)          end           command_to_forward_nimsoft_alarms = "c:\\Perl64\\bin\\perl.exe e:\\ABCD\\efgh.pl" .. " \"" .. current_alarm.nimid .. "\" \"" .. current_alarm.hostname .. "\" \"" .. current_alarm.source .. "\" " .. current_alarm.nimts .. " " .. current_alarm.level .. " \"" .. current_alarm.origin .. "\" \"" .. current_alarm.message .. "\" \"" .. current_alarm.prid .. "\" \"" .. current_alarm.supp_key .. "\" \"" .. current_alarm.suppcount .. "\""           local output1          local return_status1           printf ("%s",command_to_forward_nimsoft_alarms)          output1,return_status1 = action.command (command_to_forward_nimsoft_alarms)           if return_status1 ~= NIME_OK then             local b1             b1 = { nimid = current_alarm.nimid, custom_1 = "Error" }             alarm.set (b1)          --else          --   local c1          --   c1 = { nimid = current_alarm.nimid, custom_1 = "Success" }          --   alarm.set (c1)          end                 end     end end  printf ("Script execution finished....\n") 

 

 

Profile

 

 

 

 

 

 

 

Regards,

Amit Saxena

Outcomes