Check the current number of connections to MongoDb

connect to the admin database and run db.serverStatus():

> var status = db.serverStatus()
> status.connections
   {"current" : 21, "available" : 15979}
> 

You can directly get by querying

db.serverStatus().connections

To understand what does MongoDb’s db.serverStatus().connections response mean, read the documentation here.

connections

"connections" : {
   "current" : <num>,
   "available" : <num>,
   "totalCreated" : NumberLong(<num>)
},

connections
A document that reports on the status of the connections. Use these values to assess the current load and capacity requirements of the server.

connections.current
The number of incoming connections from clients to the database server . This number includes the current shell session. Consider the value of connections.available to add more context to this datum.

The value will include all incoming connections including any shell connections or connections from other servers, such as replica set members or mongos instances.

connections.available
The number of unused incoming connections available. Consider this value in combination with the value of connections.current to understand the connection load on the database, and the UNIX ulimit Settings document for more information about system thresholds on available connections.

connections.totalCreated
Count of all incoming connections created to the server. This number includes connections that have since closed.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)