DX Unified Infrastructure Management

  • 1.  LUA scripting

    Posted May 18, 2011 11:43 PM

    Hi there.  I have no experience with LUA and only have 2 months experience with Nimsoft.  I have a request to have some nt services stopped and restarted in a particular order for 6 servers.  ie.  stop and start an nt service on a particular server, then stop and start another service on another server after the previous has been successfully restarted.  This goes on for 6 servers.  I was lead to understand that a LUA script will need to be written.  I know where I can put the scripts (NAS-auto operator-scripts) however I do not know how to write a script.  Suggestions?  Should I be opening a case with Nimsoft?
    Thank you!  Bryan



  • 2.  Re: LUA scripting

    Posted May 19, 2011 03:22 PM

    The below code is only an example but by changing the "addr" variable you can specify what order you want the services stopped and started in.  Also, this assumes that the NTServices probe is running on those servers as well.  The top part, alarm.get, simply grabs the robot path from the event for use in the addr variable.

     

    -- Get data from current alarm
    a = alarm.get ()
    addr = "/" ..a.domain.. "/" ..a.hub.. "/" ..a.robot.. "/ntservices"
    
    -- Create variable for Windows Service name
    argsa = pds.create()
    pds.putString (argsa,"name","Service_Name_Here")
    
    -- Stop Windows Service
    s_statusa,rca = nimbus.request(addr,"stop_service",argsa)
    
    -- Start Windows Service
    s_statusa,rca = nimbus.request(addr,"start_service",argsa)

     



  • 3.  Re: LUA scripting

    Posted May 19, 2011 04:36 PM
    Thanks for the quick response Dave. What would I add if this was to be done every 30 days? Also, I got this error when tesing the script: Error in line 3: attempt to index global 'a' (a nil value). Do I have to put the robot name in there?
    Thanks again, Bryan


  • 4.  Re: LUA scripting
    Best Answer

    Posted May 19, 2011 06:25 PM

    The a variable is created off the "a.alarm" function.  This function works when you associate the script to an auto-operator profile.  It will select the data from the matching alarm and use them in the script.  If you would like to run the script directly, just comment out that line and create a new variable called "addr" with the address to the required robot.