Page tree
Skip to end of metadata
Go to start of metadata

Pattern Goal

The goal of the _MongoDB MongoDB _ Database Detail pattern is to obtain the list of Databases being managed by the MongoDB Server.

The information is then stored within the Atrium Discovery Model as DatabaseDetail Nodes. In Atrium Discovery 8.3 and later, the DatabaseDetail node has additional attributes added which permit easy mapping by the CMDB sync mechanism to the BMC_Database CIs in Atrium CMDB.

The _MongoDB MongoDB _ Database Detail pattern triggers off a MongoDB MongoDB Server, Config Server or Shard Server SI whose db_path attribute is populated.

Command-based discovery method

The pattern attempts to discover the list of installed databases by executing one of the following commands:

  • <install_root>/bin/mongo admin -port <port> --eval "printjson(db.adminCommand('listDatabases'))"
  • <install_root>\bin\mongo.exe" admin -port <port> --eval "printjson(db.adminCommand('listDatabases'))"
  • <install_root>/bin/mongo admin --eval "printjson(db.adminCommand('listDatabases'))"
  • <install_root>\bin\mongo.exe" admin --eval "printjson(db.adminCommand('listDatabases'))"

Should the above command fail on the UNIX platform, an attempt will be made to rerun it in privileged execution mode.

Pattern will also try to get the Database Server version from the result of the command, if one is not found as a part of the main pattern discovery. The name will be updated accordingly.

Directory Listing - file-based discovery method

The pattern's second discovery method is that of attempting to execute one of two commands per platform, dependant on the trigger SI's __directory_per_db flag, which will return a list of .ns files in the directory (and its subdirectories as required) pointed to by dbpath.

 

 __directory_per_db not set__directory_per_db set
UNIX


ls "%si.db_path%" | grep ".ns"


ls -R "%si.db_path%" | grep ".ns"

Windows


dir "%si.db_path%\\*.ns"


dir /s "%si.db_path%\\*.ns"