DX Unified Infrastructure Management

 View Only
  • 1.  Extract Thresholds of all Robots With LUA

    Posted Aug 27, 2010 02:33 PM

    I have been working on the following LUA script to extract threshold values from the CDM and print them to text file for using later. The goal is to extract thresholds from all robots, but running this script using a profile only returns the CDM thresholds from the hub with the nas probe. Does anyone have any suggestions on accomplishing this task? I am assuming what data is returned depends on how the script is ran.

     

    I have also tried running this on an alarm trigger and tried to extract the hostname that way, but it still returns the hostname of the nas. I can however get the nimid of each individual alarm, but not the corresponding hostname.

     

    --

    -- Extract the CDM configuration file from the controller as a table and

    -- access parts of the configuration, and print the contents sorted by section.

    --

    controller = nimbus.request("controller","get_info")

    args = pds.create()

    pds.putString (args,"name","cdm")

     

    cfg,rc = nimbus.request ("controller","probe_config_get",args)

     

    dir= "E://"

    host = controller.robotname

    ext= ".txt"

    filename= dir..host..ext

    io.output(filename)

     

    io.write("Robot="",controller.robotname)

    print("Robot=",controller.robotname)

     

       pagefile_error = cfg["/memory/alarm/pagefile error"]

    if pagefile_error ~= nil then

       io.write("\nPagefile Error=",pagefile_error.threshold)

       print("Pagefile Error=",pagefile_error.threshold)

    end

       pagefile_warning = cfg["/memory/alarm/pagefile warning"]

    if pagefile_warning ~= nil then

       io.write("\nPagefile Warning=",pagefile_warning.threshold)

       print("Pagefile Warning=",pagefile_warning.threshold)

    end

       physical_error = cfg["/memory/alarm/physical error"]

    if physical_error ~= nil then

       io.write("\nPhysical Error=",physical_error.threshold)

       print("Physical Error=",physical_error.threshold)

    end

       physical_warning = cfg["/memory/alarm/physical warning"]

    if physical_warning ~= nil then

       io.write("\nPhysical Warning=",physical_warning.threshold)

       print("Physical Warning=",physical_warning.threshold)

    end

       swap_error = cfg["/memory/alarm/swap error"]

    if swap_error ~= nil then

       io.write("\nSwap Error=",swap_error.threshold)

       print("Swap Error=",swap_error.threshold)

    end

       swap_warning = cfg["/memory/alarm/swap warning"]

    if swap_warning ~= nil then

       io.write("Swap Warning=",swap_warning.threshold)

       print("Swap Warning=",swap_warning.threshold)

    end

       paging_error = cfg["/memory/alarm/paging error"]

    if paging_error ~= nil then

       io.write("\nPaging Error=",paging_error.threshold)

       print("Paging Error=",paging_error.threshold)

    end

       paging_warning = cfg["/memory/alarm/paging warning"]

    if paging_warning ~= nil then

       io.write("\nPaging Warning=",paging_warning.threshold)

       print("Paging Warning=",paging_warning.threshold)

    end



  • 2.  Re: Extract Thresholds of all Robots With LUA

    Posted Aug 27, 2010 03:34 PM

    You can get a list of all hubs from the hub where the NAS is running. Then you can get a list of all robots for each hub. It would look something like this:

     

    local h_resp,rc = nimbus.request("hub", "gethubs")

    if rc ~= NIME_OK then
       print("Error code "..rc.." received from call to gethubs")
       return
    end

     

    for h_row,h_entry in pairs (h_resp.hublist) do

       local r_resp,rc = nimbus.request(h_entry.addr, "getrobots")

       if rc == NIME_OK then

          for r_row,r_entry in pairs (r_resp.robotlist) do

             -- *** Your logic goes here ***

          end

       else

          print("Error code "..rc.." received from call to getrobots on "..h_entry.addr)

       end

    end

     

    -Keith



  • 3.  Re: Extract Thresholds of all Robots With LUA

    Posted Aug 27, 2010 05:58 PM

    I tried the above code and I am able to return hub names. Not sure if it is what I need or not so I will try to explain my situation further. For every robot with a cdm probe, I want to output their threshold data and write it to a file. The only data I can get is the thresholds for where the nas is.

     

    This is kind of what I'm going for:

    Robot=

    Pagefile Error=

    Pagefile Warning=

    Physical Error=

    Physical Warning=

    Swap Error=

    Swap Warning=

    Paging Error=

    Paging Warning=



  • 4.  Re: Extract Thresholds of all Robots With LUA

    Posted Aug 27, 2010 06:30 PM

    You have to take your code that you have been using, stick it inside the loop, and reference the robot addresses coming back from the getrobots callback.

     

    I edited the script sample to include an additional loop, which might make it easier.

     

    -Keith



  • 5.  Re: Extract Thresholds of all Robots With LUA

    Posted Aug 27, 2010 07:28 PM

    Ok, I really appreciate the help you have given and truly making progress. I am getting unique hostnames, but I dont think the data im pulling from cdm is unique. I went in and changed some thresholds and it hasn't updated yet. Here is my updated script:

     

    local h_resp,rc = nimbus.request("hub", "gethubs")

    if rc ~= NIME_OK then
       print("Error code "..rc.." received from call to gethubs")
       return
    end

    for h_row,h_entry in pairs (h_resp.hublist) do
       local r_resp,rc = nimbus.request(h_entry.addr, "getrobots")
      
       if rc == NIME_OK then
          for r_row,r_entry in pairs (r_resp.robotlist) do

      args = pds.create()
      pds.putString (args,"name","cdm")
      cfg,rc = nimbus.request ("controller","probe_config_get",args)
      dir= "E://NAS//thresholds//"
      host = r_entry.name
      ext= ".txt"
      filename= dir..host..ext
      io.output(filename)
      io.write("Robot=",r_entry.name)
      print("Robot=",r_entry.name)
      
      pagefile_error = cfg["/memory/alarm/pagefile error"]
      if pagefile_error ~= nil then
       io.write("\nPagefile Error=",pagefile_error.threshold)
       print("Pagefile Error=",pagefile_error.threshold)
      end
      
      pagefile_warning = cfg["/memory/alarm/pagefile warning"]
      if pagefile_warning ~= nil then
       io.write("\nPagefile Warning=",pagefile_warning.threshold)
       print("Pagefile Warning=",pagefile_warning.threshold)
      end

      physical_error = cfg["/memory/alarm/physical error"]
      if physical_error ~= nil then
       io.write("\nPhysical Error=",physical_error.threshold)
       print("Physical Error=",physical_error.threshold)
      end

      physical_warning = cfg["/memory/alarm/physical warning"]
      if physical_warning ~= nil then
       io.write("\nPhysical Warning=",physical_warning.threshold)
       print("Physical Warning=",physical_warning.threshold)
      end

      swap_error = cfg["/memory/alarm/swap error"]
      if swap_error ~= nil then
       io.write("\nSwap Error=",swap_error.threshold)
      print("Swap Error=",swap_error.threshold)
      end

      swap_warning = cfg["/memory/alarm/swap warning"]
      if swap_warning ~= nil then
       io.write("\nSwap Warning=",swap_warning.threshold)
      print("Swap Warning=",swap_warning.threshold)
      end

      paging_error = cfg["/memory/alarm/paging error"]
      if paging_error ~= nil then
       io.write("\nPaging Error=",paging_error.threshold)
       print("Paging Error=",paging_error.threshold)
      end

      paging_warning = cfg["/memory/alarm/paging warning"]
      if paging_warning ~= nil then
       io.write("\nPaging Warning=",paging_warning.threshold)
       print("Paging Warning=",paging_warning.threshold)
                      print("\n")
      end
          end
       else
          print("Error code "..rc.." received from call to getrobots on "..h_entry.addr)
       end
    end

     



  • 6.  Re: Extract Thresholds of all Robots With LUA
    Best Answer

    Posted Aug 27, 2010 11:37 PM

    Oh, I see what is going on here. I can see that you tweaked your code a bit to use the r_entry variable, but I think you just missed a spot. The problem is this line:

     

       cfg,rc = nimbus.request ("controller","probe_config_get",args)

     

    You are sending the request to an address of "controller", which will only go to the local controller. Try this instead:

     

       cfg,rc = nimbus.request (r_entry.addr,"probe_config_get",args)

     

    That should help.

     

    -Keith



  • 7.  Re: Extract Thresholds of all Robots With LUA

    Posted Aug 27, 2010 11:50 PM

    Thank You! Thank You! Thank You!

     

    I had tried that before but did not remove the " " from it. This is my first LUA script and I have been working on it on and off for days now and I really appreciate your help in bringing this to a resolution.

     



  • 8.  Re: Extract Thresholds of all Robots With LUA

    Posted Aug 28, 2010 12:06 AM

    Way to jump in with both feet and start knocking out some code! The fact that you had the script working to the point of getting configuration info from one robot before you needed help is pretty good. :smileyhappy: