DX Unified Infrastructure Management

 View Only
Expand all | Collapse all

DB connection error on NAS profile Script

  • 1.  DB connection error on NAS profile Script

    Posted Aug 09, 2019 03:52 PM

    When I tried to connect to a MS SQL DB from NAS probe Script, it cannot connect to the Database. I know am using the right DB server name, db name, user ID and password, but something am missing here.

    I used the below syntax as given in the communities, https://ca-broadcom.wolkenservicedesk.com/external/article?articleId=46250

    database.open ("Driver={SQL Server}; Server=servername; Database=database; Uid=username; Pwd=password;")

    Do I need to install any driver here? I don't see any log except saying the "Error : Unable to open the Database".

    Any help on this would be appreciated! Thanks!



    ------------------------------
    ~Vis
    ------------------------------


  • 2.  RE: DB connection error on NAS profile Script

    Broadcom Employee
    Posted Aug 09, 2019 04:03 PM
    what is the OS type and version on the primary?
    The connection string assumes windows and will not work on Linux/unix

    ------------------------------
    Gene Howard
    Principal Support Engineer
    Broadcom
    ------------------------------



  • 3.  RE: DB connection error on NAS profile Script

    Posted Aug 13, 2019 07:38 AM
    UIM 9.0.2 is installed on a cloud server with the windows Server 2012 OS. 
    I have created a ODBC datasource on the server and the test is successful. But when I try the same on the NAS probe, it fails.

    Is it possible to use the datasource on the database.open()?, as the datasource already has the connection details

    ------------------------------
    ~Vis
    ------------------------------



  • 4.  RE: DB connection error on NAS profile Script

    Posted Aug 14, 2019 06:06 AM
    Example LUA script that should work on w2012 and MSSQL:
    ----------------
    -- Do you want also the informational messages
    debug=0
    -- Open MSSQL DB and check rc
    rc = database.open ("Driver={SQL Server}; Server=bgbulab57; Database=CA_UIM; Uid=sa; Pwd=??????;")
    if rc == 0
    then
    if debug == 1
    then
    printf ("Open db CA_UIM ok, rc:%d",rc)
    end
    else
    printf ("Open db CA_UIM NOK, rc:%d",rc)
    end
    -- Get rows from table
    --rs,rc = database.query("SELECT r.robot_id,robot, r.ip, p.probe_name,p.pkg_version, p.probe_status FROM cm_nimbus_robot r, cm_nimbus_probe p where r.robot_id = p.robot_id order by robot, probe_name")
    rs,rc = database.query("SELECT robot,ip FROM cm_nimbus_robot")
    if rc == 0
    then
    if debug == 1
    then
    printf ("Select DB ok, rc:%d #rows: %d",rc,#rs)
    end
    else
    printf ("Select DB NOK, rc:%d",rc)
    end
    -- print info of row 1 directly
    printf ("xxx robot:%s, ip:%s",rs[1].robot,rs[1].ip)
    vara=rs[1].robot
    printf ("yyy robot saved: %s",vara)
    -- Loop in return of sql
    for i=1,#rs do
    printf ("%02d robot:%s, ip:%s",i,rs[i].robot,rs[i].ip)
    end
    -- Close db
    database.close()



  • 5.  RE: DB connection error on NAS profile Script

    Posted Aug 14, 2019 07:07 AM
    Hi Luc,
            Thanks for the script! I had tried connecting to ca_uim DB and it works fine. But when I connect to another MSSQL DB on a non UIM DB server, I get the error as Unable to open the Database.

    ------------------------------
    ~Vis
    ------------------------------



  • 6.  RE: DB connection error on NAS profile Script

    Posted Aug 14, 2019 07:19 AM
    If you use mssql management studio on your server, can you connect to the other server/db?


  • 7.  RE: DB connection error on NAS profile Script

    Posted Aug 14, 2019 07:23 AM
    I don't have the SQL server management studio on the server. so only I used the ODBC datasource to test the connectivity.

    ------------------------------
    ~Vis
    ------------------------------



  • 8.  RE: DB connection error on NAS profile Script

    Broadcom Employee
    Posted Aug 14, 2019 01:40 PM
    what is the ODBC driver version you are using?
    Is it 32-bit or 64-bit?
    What is the exact ODBC driver name?
    What is the target sqlserver type and version?

    ------------------------------
    Gene Howard
    Principal Support Engineer
    Broadcom
    ------------------------------



  • 9.  RE: DB connection error on NAS profile Script

    Posted Aug 15, 2019 01:24 AM
    If the local connection works and like in your case the remote connection fails you have to take a step back.
    This is probably a sql problem and the easiest way to test this is to use the sql utlities, this can be the management studio or OSQL.
    It will perhaps be a simple sql setting, like "Allow remote connections" that is not set on the remote server.


  • 10.  RE: DB connection error on NAS profile Script

    Posted Aug 16, 2019 04:32 AM
    Edited by Vishwanathan Rangaswamy Aug 16, 2019 04:51 AM
    I have configured this DB on SQL server management Studio my CA SDM server and I can access it there. So the Allow remote connections is enabled. Its not working only from UIM NAS probe. 

    UIM database is 2016 and the other database which am trying to connect is 2008. So it might be the driver compatibility issue. but the 2016 driver should be having the backward compatibility. If not, I install the 2008 DB driver, will it affect connecting to UIM Database?.

    ------------------------------
    ~Vis
    ------------------------------


  • 11.  RE: DB connection error on NAS profile Script

    Posted Aug 16, 2019 05:22 AM
    Edited by Luc Christiaens Aug 16, 2019 05:23 AM
    Perhaps check on a "LUA communities" site?
    With the same database.open statement I can connect without problems to another server's mssql server.-------------------------------------------
    (from sql: 11.0.701 to sql 10.50.6220)