Check the current number of connections to MongoDB?

MongoDBDatabaseBig Data Analytics

You can check the current number of connections to MongoDB with the help of the following syntax −

var anyVariableName= db.serverStatus();
yourVariableName.connections;

The second syntax is as follows −

db.serverStatus().connections;

To understand both the above syntaxes, let us see them one by one −

Case 1 − The first query is as follows −

> var checkCurrentNumberOfConnections = db.serverStatus()
> checkCurrentNumberOfConnections.connections;

The following is the output −

{ "current" : 1, "available" : 999999, "totalCreated" : 1 }

Case 2 − The second query is as follows −

> db.serverStatus().connections

The following is the output −

{ "current" : 1, "available" : 999999, "totalCreated" : 1 }
raja
Published on 29-Mar-2019 11:18:44
Advertisements