Clear niscache and reset the robot_device_id of all robots in a DX UIM domain
search cancel

Clear niscache and reset the robot_device_id of all robots in a DX UIM domain

book

Article ID: 208622

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM) CA Unified Infrastructure Management On-Premise (Nimsoft / UIM) CA Unified Infrastructure Management SaaS (Nimsoft / UIM)

Issue/Introduction

Sometimes (usually due to issues caused by robot cloning) it may be necessary to reset the robot_device_id and clear the niscache on every active robot in the entire DX UIM domain.

The need to implement this cleanup/change may also be due to other environmental reasons.

Symptoms:

  • robot not discovered correctly
  • Discovery inconsistencies
  • Metrics not showing int the right place
  • QOS partially showing in OC
  • MCS profiles pending or not deployed
  • Server not showing in cm_nimbus_robot
  • other metric/group/MCS related inconsistencies

Environment

DX UIM 23.4.*

Cause

  • Leftover/erroneous hub/robot systems artifacts
  • ci_metric_id inconsistencies 

Resolution

Updated: February 24, 2023 (Resolves execution issues in NAS 9.36 and higher). Older script versions are attached to this article for Support reference only.

Important Guidelines

  • Test First: Always run these scripts in a test/dev environment prior to production use. They are provided as-is.

  • Hubs are Skipped: To prevent the script from restarting its own host and failing, it automatically bypasses any robot with the hub probe installed. Hubs must be cleared manually.

  • Robot Status: Robots must be active and communicating with the controller probe to be processed.

  • Scale: In large environments or those with many offline robots, the full-domain script may time out. If this occurs, use the single-hub script instead.

1.Open Scripts Menu:

Open the NAS GUI and navigate to Auto-Operator and select Scripts.

2.Create a New Script:

Create a new script and paste one of the code blocks below.

3.Configure Target:

Edit the first line of the script to define your specific domain or hub address.

4.Execute:

Click the green Play button. The script will print error-checking information and a list of results upon completion.






Script 1: Full Domain

Clears niscache on all non-hub robots in the entire domain.

--Lua
 
hubdomain = "domain_here" -- put your UIM Domain here

local gethubs = nimbus.request("hub","gethubs")
for row,hub in pairs(gethubs.hublist) do
 if (hub.domain == hubdomain) then
   print("correct domain for hub " ..hub.addr)
   getrobots, rc = nimbus.request(hub.addr, "getrobots")
   print("return code for getrobots is " ..rc)
   for x,y in pairs(getrobots.robotlist) do
    if (y.status == 0) then
      print("working on robot " ..y.addr)
      local probes, rc2 = nimbus.request(y.addr.."/controller", "port_list")
      if (not probes["hub"]) then
        print("Not a hub robot, resetting " ..y.addr)
        local reset, rc3 = nimbus.request(y.addr.."/controller", "_reset_device_id_and_restart")
        if (rc3 == 0) then
          print("success " ..y.addr)
        else
          print("failure " ..y.addr)
        end
      else
      print("Skipping hub robot "..y.addr )
      end
    else
     print("robot status for " ..y.addr..  " is not OK - skipping")
    end
   end
 else
 print("Wrong domain for hub " .. hub.addr)
 end
end

Script 2: Single Hub

Processes one hub at a time. This is more reliable for large environments or if the full-domain script returns errors like attempt to index local 'probes' (a nil value).

--Lua
 
hub_to_clear = "/MyDomain/HubName/hubrobotname/hub"  
 -- use the full address including /hub at the end

   getrobots, rc = nimbus.request(hub_to_clear, "getrobots")
   print("return code for getrobots is " ..rc)
   for x,y in pairs(getrobots.robotlist) do
    if (y.status == 0) then
      print("working on robot " ..y.addr)
      local probes, rc2 = nimbus.request(y.addr.."/controller", "port_list")
      if (not probes["hub"]) then
        print("Not a hub robot, resetting " ..y.addr)
        local reset, rc3 = nimbus.request(y.addr.."/controller", "_reset_device_id_and_restart")
        if (rc3 == 0) then
          print("success " ..y.addr)
        else
          print("failure " ..y.addr)
        end
      else
      print("Skipping hub robot "..y.addr )
      end
    else
     print("robot status for " ..y.addr..  " is not OK - skipping")
    end
   end

Additional Information

Note: These scripts intentionally bypass hubs. You must clear hubs manually if needed, though this is rarely required since hubs typically do not host monitoring probes.

Alternative Method: Command Line

If you prefer to execute this action via the command line rather than using NAS scripts, refer to the following article:

Attachments

1677280744765__clear_single_hub_new_version.lua get_app
1677280733424__clear_domain_new_version.lua get_app
1677280607794__clear_domain_old_version.lua get_app
1677280597471__clear_single_hub_old_version.lua get_app