1. Help Center
  2. OpsCompass Integrations

How do I bulk-load data gathering configuration details?

Overview

Database configurations provide our data gathering scripts with the connection details necessary to collect data for license, configuration, and compliance checks in the Opscompass product. 

Configuration details can be entered through the UI under Licenses -> Data Configuration 

A dark flyout on the left side of the page is expanded with a highlight on a page that says Data Configuration. The body of the page to the right consists of cards with fields for users to enter their Oracle server configurations.

The information may also be entered via atomic commands using the Opscompass CLI, or by using the bulk_load.js script provided in the data gathering base-scripts module. 

 

For details on using the Opscompass CLI refer to the following KB: 

Getting Started with OpsCompass Command Line Interface 

The bulk_load.js Script 

As the name implies, this is a JavaScript utility that requires Node.js to run.  It is provided as part of the base-scripts module, which can be found in ~/.opscompass/scripts/base-scripts/src/scripts/bulk_load.js.  The script makes use of ~/.opscompass/defaults.json to determine the company and account details under which to create the configuration(s). 

Conceptually, all the utility does is to break apart an Opscompass data gathering configuration file into its components and send them to Opscompass using the appropriate CLI commands. 

It can be invoked directly using “bulk_load.js push {filename}” where {filename} points to the file to be loaded.  Any valid file path may be specified.   

Input Data 

The bulk_load.js script expects the input file to match the Opscompass data gathering configuration file format, with an optional bulk_create section.  The bulk_create section can be used to specify default credentials for each connection type.  Additional examples can be found in the base-scripts/src/Config/ directory.  If no configurationId is specified, as shown in this example, a new configuration file will be created. 



  "configurationId": null, 

  "bulk_create": { 

    "oracle_default_credentials": { 

      "user": "0racle_test", 

      "password": "secretPassword" 

    }, 

   "microsoft_default_credentials": { 
     "user": "AD_User42", 
     "password": "SQL$erver-Welcome2", 
     "directory_auth": "SESSION", 
   } 
  }, 

  "oracle_dbs": [ 

    { 

      "name": "host1~svc1", 

      "server": "host1:1521/svc1", 

      "actions": [ 

        "dblicensing" 

      ] 

    }, 

   ... 

  ], 

     "microsoft_dbs": [ 

      { 

        "name": "with_backslash_and_others", 

        "NOTE": [ 

         "We will never get a string with just one backslash", 

         "The password below is 'a!b\cd$fg@h~ hoorah'", 

         "But the backslash must be escaped by a second backslash" 

       ], 

       "server": "sqltest", 

       "user": "$qltest", 

       "password": "a!b\\cd$fg@h~ hoorah", 

       "actions": ["dblicensing"] 

     } 

    ] 

How can I generate the JSON? 

The easiest way is to start with an existing configuration or sample file and make changes.  When configurationId is set to a valid number under your authorized account(s), the bulk loader will attempt to apply changes to the existing configuration file.  The default configurationId can be found in the “~/.opscompass/defaults.json” file. 

A quick way to duplicate a configuration file is to copy it to a new file, change the configurationId property to null, and then push it to Opscompass using the bulk loader. When configurationId is missing, undefined, or null, the bulk loader will create a new configuration file with the same name as the source file. 

Extracting from an Asset Management Tool other than Opscompass 

The JSON format is straightforward, so if you can run a report listing your Oracle and/or Microsoft databases in the Opscompass format, you can bulk load that directly.  However, some tools only offer limited export / output options.  Using CSV is almost always an option and there are many tools for converting CSV to JSON.  

Here is an example: 

#!/bin/bash 




# This script shows how to convert an example CSV format to JSON 

# The output can be pushed to Opscompass via the bulk_load.js utility 

#   found in the base-scripts module 



# Refer to bulk_sample*.json in the base-scripts/src/Config directory 

#   for full examples including default credentials 




# This example uses the npm package csv2json 

# npm install -g csv2json 




# Example input: 

# cat host_port_service.csv  

#  hostname,port,service_name 

#  host1,1521,svc1 

#  host2,1521,svc2 

#  host3,1523,svc3 

#  host4,1521,svc4 






printf '{\n"oracle_dbs":\n' 

awk -F, ' 

  BEGIN{print "name,server"} 

  NR>1{ 

    print $1"~"$3","$1":"$2"/"$3 

  } 

' host_port_service.csv | csv2json 

printf "}\n" 

) | jq '.oracle_dbs[] += {"actions": ["dblicensing"]}' 




# Example output: 

# { 

#   "oracle_dbs": [ 

#     { 

#       "name": "host1~svc1", 

#       "server": "host1:1521/svc1", 

#       "actions": [ 

#         "dblicensing" 

#       ] 

#     }, 

#     { 

#       "name": "host2~svc2", 

#       "server": "host2:1521/svc2", 

#       "actions": [ 

#         "dblicensing" 

#       ] 

#     }, 

#     { 

#       "name": "host3~svc3", 

#       "server": "host3:1523/svc3", 

#       "actions": [ 

#         "dblicensing" 

#       ] 

#     }, 

#     { 

#       "name": "host4~svc4", 

#       "server": "host4:1521/svc4", 

#       "actions": [ 

#         "dblicensing" 

#       ] 

#     } 

#   ] 

# } 

The output above can be pushed as-is, or you can add the bulk_create section as shown above in the Input Data section.  To add the connections to an existing configuration file, add the corresponding configurationId.  

To get a list of existing configuration files run the following command: 

$ opscompass license-manager list-monitoring-configurations 



  { 

    "configurationName": "Test Configuration", 

    "id": "1", 

    "companyId": "37" 

  }, 

  { 

    "configurationName": "dgConfig-prod.json", 

    "id": "79", 

    "companyId": "37" 

  }, 

... 

]