Run lua database.query command from secondary hub nas probe
search cancel

Run lua database.query command from secondary hub nas probe

book

Article ID: 263023

calendar_today

Updated On:

Products

DX Unified Infrastructure Management (Nimsoft / UIM)

Issue/Introduction

I am considering creating a scheduled lua script to run from the nas probes on our secondary hubs which would require a query of the UIM database.

For initial testing, I ran the following from the nas script editor on a secondary hub (this works from the primary hub):

database.open("provider=nis;database=CA_UIM;driver=none")

Error: unable to open the database.

I assume this is because secondary hubs cannot run queries of the UIM database. 

Is it possible to run the database.<command> commands from nas lua scripts on secondary hubs?  If so, what would be required to do so?

Environment

Release: any

Resolution

The way this works when using "provider=nis" is that it creates a connection string based on the information already available to NAS via the NiS Bridge.  So this does only work on the primary hub since you cannot have NiS Bridge enabled elsewhere.

There is a workaround but it's not terribly secure as you would have to put the username and password for the DB server into a script, e.g.:

--BEGIN LUA--

local dbuser = 'user'
local dbpass = 'password'
local dbserver = '10.0.1.1'
local dbname = 'CA_UIM'

 local mydb = "Provider=SQLOLEDB;Initial Catalog="..dbname..";Data Source="..dbserver..";User ID="..dbuser..";Password="..dbpass..";Network Library=dbmssocn;Language=us_english"

database.open(mydb)

--END LUA--

So it is technically possible - but as mentioned this may violate security best practices.  Please ensure you are following your organization's security policies.