I am unable to get mongod binary path using "db.serverStatus().process" on Ubuntu 20.04. I need to incorporate this command in a script. But "db.serverStatus().process" gives just 'mongod' as output. In Windows it gives exact path. I even included binary path in PATH environment variable and verified the path (echo $PATH).I tried using exact mongo shell path in the mongodb connect string yet same result(not simply mongo --host --port)
1 Answer
Thank you so much @wernfried-domscheit. It is a good one. Output of "db.serverCmdLineOpts().argv"
db.serverCmdLineOpts().argv
[ "/mongo/4.4.22/bin/mongod", "--config", "/etc/mongod.conf" ]
I slightly modified it. Now it is giving what is required. I am just accessing [0] element from the Array which is the exact 'mongod' binary path.
Output of "db.serverCmdLineOpts().argv[0]"
db.serverCmdLineOpts().argv[0]
/mongo/4.4.22/bin/mongod
mongos
ormongod
is the desired value, i.e. the value on Windows is actually wrong.db.serverCmdLineOpts().argv