Check the current number of connections to MongoDb

前端 未结 12 1085
南方客
南方客 2020-12-12 14:27

What is the command to get the number of clients connected to a particular MongoDB server?

12条回答
  •  时光取名叫无心
    2020-12-12 15:09

    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" : ,
       "available" : ,
       "totalCreated" : NumberLong()
    },
    

    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.

提交回复
热议问题