Navigation

getCmdLineOpts

getCmdLineOpts

The getCmdLineOpts command returns a document containing command line options used to start the given mongod or mongos.

The command has the following syntax:

Changed in version 3.6.

{
   getCmdLineOpts: 1
   txnNumber: <long>,
   lsid: { id: <UUID> }
}

The command can take the following options:

Option Type Description
txnNumber 64-bit integer/long

Optional.

A strictly increasing non-negative number that uniquely identifies the command in the command’s session.

If specified, the command must also include the lsid option.

Tip

The mongo shell and the drivers provide helpers to start the session and assign a txnNumber to the commands in the session.

New in version 3.6.

lsid Document

Optional.

The document that specifies the unique id of the session associated with the command. If the txnNumber is specified, the lsid is required.

Tip

The mongo shell and the drivers provide helpers to start the session and assign the lsid for the commands in the session.

New in version 3.6.

Run getCmdLineOpts in the admin database.

db.adminCommand( { getCmdLineOpts: 1  } )

This command returns a document with two fields, argv and parsed. The argv field contains an array with each item from the command string used to invoke mongod or mongos. The document in the parsed field includes all runtime options, including those parsed from the command line and those specified in the configuration file, if specified.

Consider the following example output of getCmdLineOpts:

{
   "argv" : [
      "/usr/bin/mongod",
      "--config",
      "/etc/mongod.conf"
   ],
   "parsed" : {
      "config" : "/etc/mongod.conf",
      "net" : {
         "bindIp" : "127.0.0.1",
         "port" : 27017
      },
      "processManagement" : {
         "fork" : true
      },
      "storage" : {
         "dbPath" : "/data/db"
      },
      "systemLog" : {
         "destination" : "file",
         "logAppend" : true,
         "path" : "/var/log/mongodb/mongod.log"
      }
   },
   "ok" : 1
}
←   features getLog  →