DX Infrastructure Manager

Expand all | Collapse all

Lua - using nimbus.request()

Jump to Best Answer
  • 1.  Lua - using nimbus.request()

    Posted 04-13-2010 07:57 PM

    I'm trying to list the status of a probe using nimbus.request., but I get nothing retrurned.  What am I doing wrong?  I know this should return one table.

     

    mypds = pds.create()
    pds.putString (mypds,"name", "logmon")
    pds.putString (mypds,"robot", "isp998")
    result,rc=nimbus.request("/Enterprise/MONIMBUSP3/isp998", "probe_list",mypds)

    for i=1, #result do
      if result ~= nil then  
        data = result[i]
        print(data.active)
      end

    end

    pds.delete(mypds)



  • 2.  Re: Lua - using nimbus.request()

    Posted 04-13-2010 09:07 PM

    A couple of things:

     

    • You have to login before you can send a request
    • The result table is associative rather than indexed, so you cannot use #result

    Give this a try (put in a username and password first):

     

    nimbus.login("user", "password")

    mypds = pds.create()
    pds.putString (mypds,"name", "logmon")
    pds.putString (mypds,"robot", "isp998")
    result,rc=nimbus.request("/Enterprise/MONIMBUSP3/isp998", "probe_list",mypds)

    if result ~= nil then
      for k,v in pairs(result.logmon) do
        print(k.." : "..v)
      end
    end
    pds.delete(mypds)

     

    By the way, I do not think you need to include the robot argument to the callback. That should be optional. (Of course, it should not hurt either.)

     

    -Keith



  • 3.  Re: Lua - using nimbus.request()

    Posted 04-14-2010 12:15 AM

    This would be nimbus.request from a lua script running on the NAS, not NSA.... Were you thinking NSA? nimbus.login() does not exist on the NAS....



  • 4.  Re: Lua - using nimbus.request()

    Posted 04-14-2010 12:27 AM

    Yes, I tested the code using the NSA. I think you should be able to use the code I posted in the NAS if you leave out the nimbus.login() call. Let me know if that does not work.

     

    -Keith



  • 5.  Re: Lua - using nimbus.request()

    Posted 04-14-2010 01:02 AM

    No error, but I don't think it's pulling anything back.  I'm wondering if it's a bug with the probe. I tried pulling the same data using the nimbus request in the EC and I get an error message "token contains data in a format not supported" .  The pu can handle the request no problem. 



  • 6.  Re: Lua - using nimbus.request()

    Posted 04-14-2010 05:46 AM

    I just tried the code in the NAS, and it actually worked fine for me. But I noticed when I copied and pasted it that there was an extra space in the robot address. I just edited the code above and fixed that, so you might want to check the copy you ran. That would probably make a big difference.

     

    If that does not work, try putting in a line to print the rc variable after calling nimbus.request() and see what value it returns.

     

    -Keith



  • 7.  Re: Lua - using nimbus.request()
    Best Answer

    Posted 04-14-2010 03:56 PM

    You should also (although implisit) add the "probe-name" to the request.  Note how the associative table can

    be accessed in the snippet below.  You can leave out the "robot" parameter to the arguments, this is only needed when the probe is running under a virtual robot e.g. Novell

     

    Carstein

     

    mypds = pds.create()
    pds.putString (mypds,"name", "logmon")

    result,rc=nimbus.request("/Development/Holmen/prexpcase/controller", "probe_list",mypds)
    if rc == NIME_OK then
       for k,v in pairs(result["logmon"]) do
          printf("%s = %s",k,v)
       end
    else
       printf("no data...")
    end

    pds.delete(mypds)

     



  • 8.  Re: Lua - using nimbus.request()

    Posted 04-14-2010 05:46 PM

    Thanks, Keith and Carstein!  Solid solution, works!



  • 9.  Re: Lua - using nimbus.request()

    Posted 04-22-2010 11:03 AM

    Hi!

     

    Could this perhaps be moved to General Development.

     

    Just discovered the Message, nearly the same as I asked in development :->

     

    cheers

    Matthias