Fix This Page
Navigation

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:

{ connPoolStats: 1 }

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

Behavior

A mongod or mongos has a number of connection pools used for outgoing connections to members in a sharded cluster or replica set. connPoolStats returns aggregated statistics related to all of the outgoing connection pools used by the mongod or mongo running the command.

Example

The following operation uses the db.runCommand() method to run the connPoolStats command.

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

Output

The following output is a sample of what connPoolStats returns. It represents a sharded cluster with 3 single-member replica set shards and a config server replica set.

Note

This example does not represent all possible output data from the connPoolStats command.

{
   "numClientConnections" : <num>,
   "numAScopedConnections" : <num>,
   "totalInUse" : <num>,
   "totalAvailable" : <num>,
   "totalCreated" : <num>,
   "hosts" : {
      "cfg1.example.net:27800" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>
      },
      "cfg2.example.net:27800" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>
      },
      "cfg3.example.net:27800" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>
      },
      "shard1.example.net:27100" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>
      },
      "shard2.example.net:27200" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>
      },
      "shard3.example.net:27300" : {
         "inUse" : <num>,
         "available" : <num>,
         "created" : <num>
      }
   },
   "replicaSets" : {
      "cfgReplSet" : {
         "hosts" : [
            {
               "addr" : "cfg1.example.net:27800",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            },
            {
               "addr" : "cfg2.example.net:27800",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            },
            {
               "addr" : "cfg3.example.net:27800",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            },
         ]
      },
      "shard1" : {
         "hosts" : [
            {
               "addr" : "shard1.example.net:27100",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            }
         ]
      },
      "shard2" : {
         "hosts" : [
            {
               "addr" : "shard2.example.net:27200",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            }
         ]
      },
      "shard3" : {
         "hosts" : [
            {
               "addr" : "shard3.example.net:27300",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            }
         ]
      }
   },
   "ok" : 1
}

Output

connPoolStats.totalAvailable

Reports the total number of available outgoing connections from the current mongod/mongos instance to other members of the sharded cluster or replica set.

connPoolStats.totalCreated

Reports the total number of outgoing connections ever created by the current mongod/mongos instance to other members of the sharded cluster or replica set.

connPoolStats.totalInUse

Reports the total number of outgoing connections from the current mongod/mongos instance to other members of the sharded cluster or replica set that are currently in use.

connPoolStats.numClientConnection

Reports the number of active and stored outgoing synchronous connections from the current mongod/mongos instance to other members of the sharded cluster or replica set.

These connections are a part of a pool that is a subset of the data reported by totalAvailable, totalCreated, and totalInUse.

connPoolStats.numAScopedConnection

Reports the number of active and stored outgoing scoped synchronous connections from the current mongod/mongos instance to other members of the sharded cluster or replica set.

These connections are a part of a pool that is a subset of the data reported by totalAvailable, totalCreated, and totalInUse.

connPoolStats.hosts

Contains documents that represent a report of connections between the current mongod/mongos instance and each member of the sharded cluster or replica set.

connPoolStats.hosts.[host].available

Reports the total number of connections available for connecting to the [host].

connPoolStats.hosts.[host].created

Reports the number of connections to the [host] ever created.

connPoolStats.hosts.[host].inUse

Reports the number of connections to the [host] that are currently in use.

connPoolStats.replicaSets

Contains documents that represent a report of information related to each replica set connected to the current mongod/mongos.

connPoolStats.replicaSets.replicaSet

Reports on each replica set connected to the current mongod/mongos.

connPoolStats.replicaSets.[replicaSets].hosts

Holds an array of documents that reports on each member in the replica set.

These values derive from the replica set status values.

connPoolStats.replicaSets.[replicaSet].hosts[n].addr

Reports the address for the member in the replica set in [hostname]:[port] format.

connPoolStats.replicaSets.[replicaSet].hosts[n].ok

Reports false when:

  • the current mongos or mongod cannot connect to instance.
  • the current mongos or mongod received a connection exception or error.

This field is for internal use.

connPoolStats.replicaSets.[replicaSet].hosts[n].ismaster

Reports true if this host is the primary member of the replica set.

connPoolStats.replicaSets.[replicaSet].hosts[n].hidden

Reports true if this host is a hidden member of the replica set.

connPoolStats.replicaSets.[replicaSet].hosts[n].secondary

Reports true if this host is a secondary member of the replica set.

connPoolStats.replicaSets.[replicaSet].hosts[n].pingTimeMillis

Reports the ping time in milliseconds from the mongos or mongod to this host.

connPoolStats.replicaSets.[replicaSet].hosts[n].tags

Reports the members[n].tags, if this member of the set has tags configured.

←   collStats cursorInfo  →