DX Unified Infrastructure Management

 View Only
Expand all | Collapse all

Interface_traffic List

  • 1.  Interface_traffic List

    Posted Oct 14, 2015 09:53 AM

    Hi,

     

    Do we have any ways of exporting the list of devices in interface_traffic probe along with the ports monitored for the device?

     

     

    -kag



  • 2.  Re: Interface_traffic List

    Broadcom Employee
    Posted Oct 14, 2015 12:19 PM

    We have nothing "out of the box" for this; it may be possible to write a script (perl?) to parse the .cfg file but it can be tricky.

     

    You might also be able to get some useful information out of the following:

     

    https://na4.salesforce.com/articles/HowToProcedures/How-to-create-a-report-of-all-probe-configurations?popup=true



  • 3.  Re: Interface_traffic List

    Posted Oct 14, 2015 06:36 PM

    This LUA script will loop through your hubs and robots looking for the interface_traffic probe and  provide an output of robotaddress,profilename,interface. This was done in haste so its not as advanced as it could be.

     

    EDIT: Code is posted further down in the thread.



  • 4.  Re: Interface_traffic List

    Posted Oct 15, 2015 11:47 AM

    Thanks Bryan. Upon executing this script in nas I am not getting the relevant details that I am looking for. Can you give me an insight on how to run this in the nsa probe? I did deploy this sdk in my development primary hub, however executing the command

     

    nsa -|file_name

     

    is not giving me the desired output.

     

     

    -kag



  • 5.  Re: Interface_traffic List

    Posted Oct 15, 2015 11:50 AM

    You will need to add a login to the BUS in the script. Add the following line to the very top of the script and replace the administrator and nimsoft with your username and password.

     

    nimbus.login("administrator","nimsoft")



  • 6.  Re: Interface_traffic List

    Posted Oct 15, 2015 12:38 PM

    Thanks Again Bryan. And how do I execute it using nsa?

     

    -kag



  • 7.  Re: Interface_traffic List
    Best Answer

    Posted Oct 15, 2015 01:06 PM

    Ok, this will need a slight modification to run outside the NAS, wasn't paying attention to the script earlier.

     

    You will need to change the hub variable in line 2 to your Primary hub address and change the username and password in line one.

     

    Save the file with a .lua extension and save it into the Nimsoft/sdk/nsa folder and then open a command probe from that directory and run nsa filename.lua

     

    nimbus.login("username","password")
    hub = "/Domain/Hub/Robot/hub"
    domain = "Domain"
    
    
    local hosts = {}
    z = 1
    
    
    -- This block will get all the probes running interface_traffic
    
    
    
    resp,rc = nimbus.request(hub, "gethubs")
    for h,hinfo in pairs(resp.hublist) do
     if hinfo.domain == domain then
      local args = pds.create()
      pds.putInt(args, "detail", 1)
      sessionhandle = nimbus.session_open(hinfo.addr)
      if sessionhandle ~= nil then
          local r_resp,rc = nimbus.session_request(sessionhandle, "getrobots", args, 300)
          if rc == 0 then
            for r,rinfo in pairs(r_resp.robotlist) do
                if rinfo.probelist ~= nil then
                  for p,pinfo in pairs (rinfo.probelist) do
                      if pinfo.name == "interface_traffic" then
                        --print("Found interface_traffic probe at " .. rinfo.addr)
                        hosts[z] = rinfo.addr
                        z = z + 1
                      end
                  end
                end
            end
          end
      end
      nimbus.session_close(sessionhandle)
    end
    end
    
    
    --This block will retreive all the devices on each interface_traffic probe
    
    
    for i,hostinfo in ipairs(hosts) do
      host = hostinfo .. "/interface_traffic"
      local result,rc = nimbus.request(host, "get_profile_status", "", 300)
      if rc == 0 then
          if result.Profiles ~= nil then
            for i, agentinfo in pairs(result.Profiles) do
             if agentinfo.Interfaces ~= nil then
                for j, interface in pairs(agentinfo.Interfaces) do
                  print (hostinfo..","..agentinfo.profile_name..","..interface.name)
                end
             end
            end
          end
      end
    end
    
    


  • 8.  Re: Interface_traffic List

    Posted Oct 16, 2015 04:45 AM

    Hey Bryan,

     

    I am getting the below error after doing the changes you said. And moreover, the result on executing is giving me the information of the probe which I have not referenced. I have given the script to look for my dev hub however it is fetching me my prod hub details.

     

    Oct 16 04:44:16:200 nsa: Script error, interface_report.lua:47: bad argument #1

    to 'pairs' (table expected, got nil)

     

    -kag



  • 9.  Re: Interface_traffic List

    Posted Oct 16, 2015 11:51 AM

    Your dev and production hub are probably on the same subnet, which would allow the hubs to 'discovery' each other through broadcasts on 48002.

     

    I have added a domain variable at the top to easily take care of this, just put the development domain name in that variable. I have also added a check to make sure agentinfo.Interfaces is not nil to error.

     

     

    I edited the previously posted script above.



  • 10.  Re: Interface_traffic List

    Posted Oct 20, 2015 08:37 AM

    Hi Bryan,

     

    Still getting the same error.

     

    Oct 20 08:34:12:420 nsa: Script error, interface_report.lua:48: bad argument #1

    to 'pairs' (table expected, got nil)

     

    Although the script runs a while and shows the desired output for just a couple devices only and ends with the error above.

     

     

    -kag



  • 11.  Re: Interface_traffic List

    Posted Oct 20, 2015 09:52 AM

    Are you sure you copied the correct code? Line 48 has a check for nil so it should bypass that response. I edited the first set of code as it wasn't current, leaving the correct one.



  • 12.  Re: Interface_traffic List

    Posted Oct 20, 2015 12:36 PM

    Hey Bryan,

     

     

    That's right. I was referencing the incorrect one. This gives me the exact result which I am looking for. Thanks a lot.

     

     

    -kag



  • 13.  Re: Interface_traffic List

    Posted Oct 26, 2015 02:45 PM

    Receiving the following error.

    Error in line 15: attempt to index global 'resp' (a nil value)

    I'm sure it's a easy fix but i;m not versed in it.

     

     

     

    thank you,

     

    Scott



  • 14.  Re: Interface_traffic List

    Posted Oct 26, 2015 04:03 PM

    Make sure you fill out the top three lines with your correct username and password (if using NSA and comment it out if using NAS), your UIM domain and your hub address.



  • 15.  Re: Interface_traffic List

    Posted Nov 19, 2015 10:04 AM

    needed to change this resp,rc = nimbus.request(hub, "gethubs")   to   resp,rc = nimbus.request("hub", "gethubs")

     

     

    what would need to be altered to run this against one robot with interface traffic probe instead of whole domain?

     

    regards,

     

    Scott



  • 16.  Re: Interface_traffic List

    Posted Nov 19, 2015 12:00 PM

    The following should work, just change the host variable.

     

    --nimbus.login("username","password") 
    host = "/Domain/Hub/Robot/interface_traffic"
    
    
    --This block will retreive all the devices on each interface_traffic probe 
    
    
      local result,rc = nimbus.request(host, "get_profile_status", "", 300) 
      if rc == 0 then 
          if result.Profiles ~= nil then 
            for i, agentinfo in pairs(result.Profiles) do 
            if agentinfo.Interfaces ~= nil then 
                for j, interface in pairs(agentinfo.Interfaces) do 
                  print (host..","..agentinfo.profile_name..","..interface.name) 
                end 
            end 
            end 
          end 
      end 
    


  • 17.  Re: Interface_traffic List

    Posted Mar 09, 2016 12:34 PM

    Hi Bryan,

     

    I know that the script worked earlier, however when I tried it now the script just opens the scriptfile.lua. Does it have something to do with the version of UIM. Previously, the script ran on Nimsoft 7.6 and I am not able to run the same script in UIM 8.31. Curious to know if this is a barrier? Any suggestions?

     

     

    -kag



  • 18.  Re: Interface_traffic List

    Posted Mar 11, 2016 12:33 AM

    Try to redeploy the bad probe maybe?



  • 19.  Re: Interface_traffic List

    Posted Mar 11, 2016 12:33 AM

    NSA probe, not bad. 



  • 20.  Re: Interface_traffic List

    Posted Mar 11, 2016 07:17 AM

    Hi Bryan,

     

    I am not sure what has changed but previously I executed the same script as

     

    Nsa -| filename.lua and it gave me the result.

     

    Now I had to run it as

     

    Nsa filename.lua however, it is not giving the entire list. I don’t have the details for most of the device. Any help? And yes, I deployed a fresh nsa sdk package. Also, getting this error when executing in command prompt

     

    Mar 11 07:16:22:703 nsa: Script error, interface_report.lua:48: bad argument #1

    to 'pairs' (table expected, got nil)

     

     

    -kag