connPoolStats

Definition

connPoolStats

The command connPoolStats returns information regarding the open outgoing connections from the current database instance to other members of the sharded cluster or replica set.

To run connPoolStats, use the db.runCommand( { <command> } ) method.

Note

connPoolStats only returns meaningful results for mongos instances and for mongod instances in sharded clusters.

The command takes the following form:

db.runCommand( { "connPoolStats" : 1 } )

The value of the argument (i.e. 1 ) does not affect the output of the command.

Behavior

connPoolStats includes aggregated statistics in its output:

  • The hosts field displays the information aggregated by host.
  • The pools field displays the information aggregated by pool.

Note

To avoid interference with any running operations, connPoolStats does not take any locks. As such, the counts may change slightly as connPoolStats gathers information, resulting in slight differences between the hosts and pools connection counts.

Example

The following operation uses the db.runCommand() method to run the connPoolStats command on a mongos of a sharded cluster. The sharded cluster has 2 shards, each a single-member replica set, and a config server replica set. The mongos runs on a 4-core machine.

db.runCommand( { "connPoolStats" : 1 } )

The command returns the output of the following form:

Note

The connPoolStats output varies depending on the deployment and the member against which you run connPoolStats among other factors.

{
   "numClientConnections" : <num>,
   "numAScopedConnections" : <num>,
   "totalInUse" : <num>,
   "totalAvailable" : <num>,
   "totalCreated" : <num>,
   "totalRefreshing" : <num>,
   "pools" : {
      "NetworkInterfaceASIO-TaskExecutorPool-0" : {
         "poolInUse" : <num>,
         "poolAvailable" : <num>,
         "poolCreated" : <num>,
         "poolRefreshing" : <num>,
         "cfg1.example.net:27019" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         }
      },
      "NetworkInterfaceASIO-TaskExecutorPool-1" : {
         "poolInUse" : <num>,
         "poolAvailable" : <num>,
         "poolCreated" : <num>,
         "poolRefreshing" : <num>,
         "cfg1.example.net:27019" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         }
      },
      "NetworkInterfaceASIO-TaskExecutorPool-2" : {
         "poolInUse" : <num>,
         "poolAvailable" : <num>,
         "poolCreated" : <num>,
         "poolRefreshing" : <num>,
         "cfg1.example.net:27019" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         }
      },
      "NetworkInterfaceASIO-TaskExecutorPool-3" : {
         "poolInUse" : <num>,
         "poolAvailable" : <num>,
         "poolCreated" : <num>,
         "poolRefreshing" : <num>,
         "cfg1.example.net:27019" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         }
      },
      "NetworkInterfaceASIO-ShardRegistry" : {
         "poolInUse" : <num>,
         "poolAvailable" : <num>,
         "poolCreated" : <num>,
         "poolRefreshing" : <num>,
         "cfg1.example.net:27019" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         },
         "cfg2.example.net:27019" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         },
         "cfg3.example.net:27019" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         },
         "shard1.example.net:27018" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         },
         "shard2.example.net:27018" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         }
      },
      "global" : {
         "poolInUse" : <num>,
         "poolAvailable" : <num>,
         "poolCreated" : <num>,
         "poolRefreshing" : <num>,
         "cfg3.example.net:27019" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         },
         "cfg1.example.net:27019" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         },
         "cfg2.example.net:27019" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         },
         "shard2.example.net:27018" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         },
         "shard1.example.net:27018" : {
            "inUse" : <num>,
            "available" : <num>,
            "created" : <num>,
            "refreshing" :<num>
         }
      }
   },
   "hosts" : {
      "cfg3.example.net:27019" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>,
         "refreshing" :<num>
      },
      "cfg1.example.net:27019" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>,
         "refreshing" :<num>
      },
      "cfg2.example.net:27019" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>,
         "refreshing" :<num>
      },
      "shard2.example.net:27018" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>,
         "refreshing" :<num>
      },
      "shard1.example.net:27018" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>,
         "refreshing" :<num>
      }
   },
   "replicaSets" : {
      "csRS" : {
         "hosts" : [
            {
               "addr" : "cfg1.example.net:27019",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            },
            {
               "addr" : "cfg2.example.net:27019",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            },