AnsweredAssumed Answered

Newbie LUA question executing an external program

Question asked by sperich on Jun 11, 2011
Latest reply on Jun 14, 2011 by keith_k

Hi all,

 

Trying to build a LUA script to act as an alarm gateway in a customer trial. They use HP Openview and want to use Nimsoft for now in one particular business area. So they need to export alarms from Nimbus into the HP Openview console.  They have a script that calls a program called opcmsg to do this (which has been tested to work okay).  I'm attempting to call it with the following LUA script (hacked from the script at http://forum.nimsoft.com/t5/General/LUA-script-to-execute-command-line/m-p/8419/highlight/true#M3556), which fails with the error "attempt to index global 'c' (a nil value)"

 

I'm also curious about the Script Parameters field in the nas Auto Operator when you select "Script" for a profile. Do you need to 'export' each of the variables (message, subsys, hostname, severity etc) to the script through this field or can LUA call all the fields from the alarm.get() call?

 

Here is the script. Note that defining opc_message was my attempt at encasing c.message with double quotes.

 

c = alarm.get()

opc_message = ""..c.message..""

opc_string = "/opt/nimsoft/bin/nim2om "..c.severity.." "..c.hostname.."..opc_message.." "..c.subsys.."Nimsoft_Monitor Nimsoft"

action.command (opc_string)

Outcomes