DX Unified Infrastructure Management

 View Only

 Fetch a file from all robots

Jump to Best Answer
Espen Hanssen's profile image
Espen Hanssen posted May 23, 2023 07:27 AM

Hello,

In DX UIM, I need to loop through all robots and transfer two specific files to the primary hub. And this has to be done on a schedule.

I could get the list of robots using LUA, but I'm not sure if it's possible to use LUA to transfer the files. The files will always be located in the directory for the nexec probe.  Ideally, the files should also be renamed so they contain the name of the robot.

Does anyone have any ideas as to how (if possible) this could be done?

regards

Espen B Hanssen

Garin Walsh's profile image
Garin Walsh Best Answer
Pretty easy to do - note that this works only with text files. There's a set of callbacks that works with binary files but they use a "void" type which has no Lua equivalent and so while you can successfully transfer the binary file, there's no way in Lua to interact with that result:

local mypds = pds.create()
local address = "/domain/hub/robot"
local filename = "hub.log"
 
pds.putString ( mypds, "directory", "/opt/nimsoft/hub")
pds.putString ( mypds, "file", filename )
pds.putInt    ( mypds, "buffer_size", 10240000 )
   
output1,return_status1 = nimbus.request ( address .. "/controller", "text_file_get", mypds)
pds.delete(mypds)
 
destfile = "c:\\temp\\" .. filename
file = io.open(destfile , "w")
if file then
   file:write(output1["file_content"], "\n")
   file:close()
else
   print("Open of " .. destfile .. " file for write failed.")
end