Mongodb – How to list connections in Secondary Nodes

mongodbmongodb-atlasnosql

In my cluster on Atlas, have a many connections in secondary nodes.
How to list this connections?

When execute this command, list the current connections in primary node.

db.currentOp(true).inprog.reduce(
  (accumulator, connection) => {
    ipaddress = connection.client ? connection.client.split(":")[0] : "unknown";
    accumulator[ipaddress] = (accumulator[ipaddress] || 0) + 1;
    accumulator["TOTAL_CONNECTION_COUNT"]++;
    return accumulator;
  },
  { TOTAL_CONNECTION_COUNT: 0 }
)


{
    "TOTAL_CONNECTION_COUNT" : 229,
}

But, I have 700 connection in replicaSet.Connections in Atlas Server

Thank's

Best Answer

  1. Go to the command line tools

enter image description here

  1. Copy mongostat command under Set Up Diagnostics section

enter image description here

  1. Update password and add --discover option at the end

  2. Run it in any command-line tool

  3. You should be able to see the number of connections as below for all primary and secondaries enter image description here