DX Unified Infrastructure Management

Expand all | Collapse all

Robot configs

  • 1.  Robot configs

    Posted Mar 13, 2014 08:49 PM

    Anyone know of a way to pull all the config files from robots(robot.cfg) in a domain?  I'd like to be able to identify some config items in there and check for consistancy.



  • 2.  Re: Robot configs

    Posted Mar 13, 2014 08:56 PM
    Use text_file_get callback on controller. You can first pull nimroot variable from get_environment to work out the directory


  • 3.  Re: Robot configs

    Posted Mar 13, 2014 08:59 PM

    Would this be executed against every controller?  Not sure how a script would even look or how to even execute it.  I know I can launch the probe utility and try to execute the text_file_get against a given controller, but it doesn't return anything for me.



  • 4.  Re: Robot configs

    Posted Mar 14, 2014 10:37 AM

    Here's an example that would go through all the robots and print the robot.cfg on screen. It needs to be run on a hub machine through NSA.

     

    --functions
    function get_robots(hub_address)
         robots = {}
         getrobots = nimbus.request(hub_address, "getrobots")
         for x, robot in pairs(getrobots.robotlist) do
              robots[robot.name] = robot.addr
         end
         return robots
    end
    
    function get_robot_cfg(robot_address)
         pds_argument = pds.create()
         
         pds.putString(pds_argument, "file", "robot.cfg")
         
         getrobotinfo = nimbus.request(robot_address, "get_info")
         
         if getrobotinfo ~= nil then
              pds.putString(pds_argument, "directory", getrobotinfo["workdir"].."\\robot")
         else
              return 666
         end
         
         config, rc = nimbus.request(robot_address, "text_file_get", pds_argument)
    
         if rc ~= 0 then 
              return 667
         end
         
         
         pds.delete(pds_argument)
    
         return config["file_content"]
    end
    
    --main
    nimbus.login("user", "pass")
    hubs, rc = nimbus.request("hub", "gethubs")
    
    if rc ~=  0 then
         printf ("couldn't get hublist. rc: %d", rc)
    end
    
    for _, hub in pairs (hubs.hublist) do
         robot_addresses = get_robots(hub.addr)
         
         for _, robot_address in pairs (robot_addresses) do
              robot_config = get_robot_cfg(robot_address)
              
              if type(robot_config) == number then
                   printf ("%s error getting config: %d", robot_address, robot_config)
              else
                   print (robot_config)
                   
              end

                    print("============================")      end end

     

    You need to deploy the "nsa" package to your hub. it will install under nim_folder\sdk\nsa. go there and run nsa.exe script_name.lua

     

    -jon



  • 5.  Re: Robot configs

    Posted Mar 14, 2014 03:02 PM

    I pretty much have in place johns script except I store the info in a  database for controller,cisco_ucm,snmptoolkit,net_connect,vmware,cisco_ucs and a couple other probes and run it from the nas.



  • 6.  Re: Robot configs

    Posted Mar 14, 2014 07:13 PM

    How could I print this to a file in say, the nsa directory?



  • 7.  Re: Robot configs

    Posted Mar 14, 2014 08:03 PM

    In addition to printing to a file, I noticed when I use the lua mentioned in the thread, It returns the configs, but there isn't any reference as to what the robot was.. For example:

     

    ========================
    <controller>
    domain = EmeraldCity
    hubip = 159.49.196.152
    first_probe_port = 48002
    hub = seavvtstnimsoft
    hubrobotname = seavvtstnimsoft
    hubport = 48002
    access_0 = 0
    access_1 = 1
    access_2 = 2
    access_3 = 3
    access_4 = 4
    </controller>

    ========================
    <controller>
    domain = EmeraldCity
    hubip = 159.49.196.152
    hub = seavvtstnimsoft
    hubrobotname = seavvtstnimsoft
    hubport = 48002
    access_0 = 0
    access_1 = 1
    access_2 = 2
    access_3 = 3
    access_4 = 4
    audit = 6
    <environment>
    PERL5LIB = $PERL5LIB;$NIM_ROOT\perllib
    </environment>
    </controller>

    ========================
    <controller>
    domain = EmeraldCity
    hub = seavvtstnimsoft
    hubrobotname = seavvtstnimsoft
    hubip = 159.49.196.152
    hubport = 48002
    access_0 = 0
    access_1 = 1
    access_2 = 2
    access_3 = 3
    access_4 = 4
    </controller>

     

     

    Nothing references the robot.  These are default robot configs here.  How can I tell what is what?



  • 8.  Re: Robot configs

    Posted Mar 14, 2014 09:59 PM

    To tell which robot was the source of each config, just drop this in before it prints the config:

     

    print(robot_address)

     



  • 9.  Re: Robot configs

    Posted Mar 14, 2014 10:56 PM

    Cool!  Thanks!  Also, Not sure why this does this, but when the script returns all the configs, it prints this at the end of the output...

     

    </controller>

    ========================
    /EmeraldCity/seavvtstnimsoft/seavvtstnimsoft
    <controller>
    domain = EmeraldCity
    hub = seavvtstnimsoft
    hubrobotname = seavvtstnimsoft
    hubport = 48002
    access_0 = 0
    access_1 = 1
    access_2 = 2
    access_3 = 3
    access_4 = 4
    first_probe_port = 48000
    hubip = 159.49.196.152
    robotip = 159.49.196.152
    logsize = 1000
    ip_version = ipv4
    local_ip_validation = yes
    strict_ip_binding = no
    robotname =
    secondary_domain =
    secondary_hub =
    secondary_hubrobotname =
    secondary_hubip =
    secondary_hubport =
    secondary_hub_dns_name =
    robotip_alias =
    secondary_robotip_alias = same
    loglevel = 0
    autoremove = no
    suspend_on_loopback_only = yes
    config_locking = no
    hub_update_interval = 900
    temporary_hub_broadcast = yes
    system_uptime_qos = no
    set_qos_source = no
    unmanaged_security = domain_locked
    alarm_level_comfail_restart =
    alarm_level_dispatch_error = major
    alarm_level_max_restarts = major
    alarm_level_start_error = major
    alarm_level_timed_not_finished = warning
    alarm_level_unregister = major
    alarm_level_request_error = major
    alarm_level_timed_error_return = warning
    alarm_level_postinstall = no alarm
    robot_mode = normal
    <environment>
    NIM_JRE_HOME = jre\jre6
    NIM_JRE_HOME_1_6_0 = jre\jre6
    </environment>
    </controller>
    <setup>
    service_user =
    service_passwd =
    </setup>

    ========================
    /Airgroup/seavvtstnimbus/seavvqadna01
    667
    ========================
    /Airgroup/seavvtstnimbus/seavxascombatb1
    667
    ========================
    /Airgroup/seavvtstnimbus/seatsappsqa03
    667
    ========================
    /Airgroup/seavvtstnimbus/seatsappsqa02
    667
    ========================
    /Airgroup/seavvtstnimbus/seavvqadnw01
    667
    ========================
    /Airgroup/seavvtstnimbus/seavvtstnime2e
    667
    ========================
    /Airgroup/seavvtstnimbus/seavvqatws01
    667
    ========================
    /Airgroup/seavvtstnimbus/seadvs4aapp01
    667

     

     

    To print those lines, it doubles the time it takes to run the script.  What's that all about?



  • 10.  Re: Robot configs

    Posted Mar 15, 2014 12:50 AM
    It cant get cfg from those. Apparently its different domain and the user doesnt have permission there


  • 11.  Re: Robot configs

    Posted Mar 15, 2014 01:12 AM

    Interesting... I didn't even notice that..  Why would the script identify a different domain?  It's identified a different domain, but only robots under one hub in that domain.



  • 12.  Re: Robot configs

    Posted Mar 15, 2014 01:29 AM
    That hub is likely in the same network with the hub you ran the script from, or has sufficient connectivity (broadcast i believe) to it.


  • 13.  Re: Robot configs

    Posted Mar 15, 2014 01:31 AM

    I see.. Is there a way to modify the script to just find the robots under a given hub?  I guess I'm a little hesitant on running this in a production environment against 800 robots.  Maybe if I ran it at each hub level to just get the robots under any given hub.  Trying to modify the script now, but not having much luck.



  • 14.  Re: Robot configs

    Posted Mar 17, 2014 12:03 AM

    Can't remember without checking if gethubs takes hub name as argument.. getrobots does at least. Don't think NSA's version of LUA has loop control implemented either..

     

    Here's one way to modify it that's not quite as neat:

     

    for _, hub in pairs (hubs.hublist) do
         if hub.name == "***" then
              robot_addresses = get_robots(hub.addr)
              
              for _, robot_address in pairs (robot_addresses) do
                   robot_config = get_robot_cfg(robot_address)
                   
                   if type(robot_config) == number then
                        printf ("%s error getting config: %d", robot_address, robot_config)
                   else
                        print (robot_config)
                        
                   end
    
                             print("============================")
              end
         end
    end

     -jon



  • 15.  Re: Robot configs

    Posted Mar 17, 2014 05:28 PM

    If you don't need to break it up by hub, you should be able to check the domain specifically:

     

    if hub.domain == "EmeraldCity" then