Check the current number of connections to MongoDb

前端 未结 12 1111
南方客
南方客 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:11

    In OS X, too see the connections directly on the network interface, just do:

    $ lsof -n -i4TCP:27017
    
    mongod     2191 inanc    7u  IPv4 0xab6d9f844e21142f  0t0  TCP 127.0.0.1:27017 (LISTEN)
    mongod     2191 inanc   33u  IPv4 0xab6d9f84604cd757  0t0  TCP 127.0.0.1:27017->127.0.0.1:56078 (ESTABLISHED)
    stores.te 18704 inanc    6u  IPv4 0xab6d9f84604d404f  0t0  TCP 127.0.0.1:56078->127.0.0.1:27017 (ESTABLISHED)
    
    • No need to use grep etc, just use the lsof's arguments.

    • Too see the connections on MongoDb's CLI, see @milan's answer (which I just edited).

提交回复
热议问题