Mongo Active Connected Users

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

Do you have any question to us?

Contact us and we'll get back to you as soon as possible.