connPoolStats

在本页面

Definition

要运行connPoolStats,请使用db.runCommand( { <command> })方法。

Note

connPoolStats仅针对分片群集中的mongos实例和mongod实例返回有意义的结果。

该命令采用以下形式:

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

参数的值(即1)不会影响命令的输出。

Behavior

connPoolStats在其输出中包括汇总的统计信息:

  • hosts字段显示主机汇总的信息。

  • pools字段显示按池汇总的信息。

Note

为避免干扰任何正在运行的操作,connPoolStats不进行任何锁定。因此,随着connPoolStats收集信息,计数可能会略有变化,从而导致hostspools连接计数之间略有差异。

Example

以下操作使用db.runCommand()方法在分片群集的mongos上运行connPoolStats命令。分片群集具有 2 个分片,每个分片都是一个单成员副本集和一个配置服务器副本集。 mongos在四核计算机上运行。

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

该命令返回以下形式的输出:

Note

connPoolStats输出取决于部署和您要针对其运行connPoolStats的成员以及其他因素。

{
   "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>
            },
            {
               "addr" : "cfg3.example.net:27019",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            }
         ]
      },
      "shardB" : {
         "hosts" : [
            {
               "addr" : "shard2.example.net:27018",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            }
         ]
      },
      "shardA" : {
         "hosts" : [
            {
               "addr" : "shard1.example.net:27018",
               "ok" : <bool>,
               "ismaster" : <bool>,
               "hidden" : <bool>,
               "secondary" : <bool>,
               "pingTimeMillis" : <num>
            }
         ]
      }
   },
   "ok" : 1,
   "$clusterTime" : {
      "clusterTime" : <timestamp>,
      "signature" : <document>
   },
   "operationTime" : <timestamp>

}

Output

这些连接是池的一部分,该池是totalAvailabletotalCreatedtotalInUse报告的数据的子集。

这些连接是池的一部分,该池是totalAvailabletotalCreatedtotalInUse报告的数据的子集。

  • connPoolStats. pools

    • 按连接池分组的连接统计信息(正在使用/可用/已创建/刷新)报告。 mongodmongos具有两个不同的传出连接池家族:
  • 基于 DBClient 的池(“写路径”)和

  • 基于 NetworkInterfaceASIO 的池(“读取路径”)。

对于每个池,该命令将返回类似于以下内容的文档:

{
  "poolInUse" : <num>,
  "poolAvailable" : <num>,
  "poolCreated" : <num>,
  "poolRefreshing" : <num>,
  "[host1]" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" : <num> },
  "[host2]" : { "inUse" : <num>, "available" : <num>, "created" : <num>, "refreshing" : <num> },
  ...
}

Note

如果特定池没有任何连接(正在使用/可用/已创建/刷新),则connPoolStats不会返回该池的统计信息。

  • connPoolStats.pools. NetworkInterfaceASIO-TaskExecutorPool-[n]
    • 显示与 TaskExecutor 池相关的连接静态信息。通常,每个核心只有一个 TaskExecutorPool,例如NetworkInterfaceASIO-TaskExecutorPool-0NetworkInterfaceASIO-TaskExecutorPool-7(用于 8 核处理器)。
  • connPoolStats.pools. NetworkInterfaceASIO-ShardRegistry
    • *如果命令在分片群集的成员上运行,则可用。

显示当前mongod/mongos实例与分片群集的其他成员之间的连接的池统计信息。

  • connPoolStats.pools. NetworkInterfaceASIO-Replication
    • 如果命令在副本集的成员上运行,则可用.

显示当前mongod实例与副本集的其他成员之间的连接的池统计信息。

  • connPoolStats.pools. global

    • 显示基于 DBClient 的池统计信息。
  • connPoolStats. hosts

    • 报告按主机分组的连接统计信息(正在使用/可用/已创建/刷新)。

包含documents,代表当前mongod/mongos实例与sharded clusterreplica set的每个成员之间的连接报告。

  • connPoolStats.hosts.[host]. available

    • 报告可用于连接到[host]的连接总数。
  • connPoolStats.hosts.[host]. created

    • 报告与曾经创建的[host]的连接数。
  • connPoolStats.hosts.[host]. inUse

    • 报告当前正在使用的与[host]的连接数。
  • connPoolStats. replicaSets

  • connPoolStats.replicaSets. replicaSet

  • connPoolStats.replicaSets.[replicaSets]. hosts

这些值来自副本集状态值。

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

    -以[hostname]:[port]格式报告replica set成员的地址。

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

    -在以下情况下报告false

  • 当前的mongosmongod无法连接到实例。

  • 当前的mongosmongod接收到连接异常或错误。

此字段仅供内部使用。

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

    -如果此hostreplica setprimary成员,则报告true

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

    -如果此hostreplica sethidden member,则报告true

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

    -如果此hostreplica setsecondary成员,则报告true

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

    -报告从mongosmongod到此host的 ping 时间(以毫秒为单位)。

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

    -如果集合的此成员已配置标签,则报告members[n].tags

另请参见Response,以获取有关ok状态字段,operationTime字段和$clusterTime字段的详细信息。