Reputation: 1743
I can determine the current number of connections by
db.serverStatus().connections
but all that gives me is the current number of connections. Is there anywhay to determine which ips are connected and which connection number they have been assigned to?
Upvotes: 18
Views: 28084
Reputation: 3635
From mongo shell, this will print client IP:port, along with connection ID:
db.currentOp(true).inprog.forEach(function(d){if(d.client)print(d.client, d.connectionId)})
Note: passing true
to db.currentOp()
shows all connections (including idle). The docs have more examples on filtering connections, see:
db.currentOp reference and currentOp output fileds with descriptions.
Upvotes: 22
Reputation: 1458
From mongo shell run db.currentOp() to show all active connections or db.currentOp(true) to show all connections.
Upvotes: 14
Reputation: 1466
It depends on your db engine, but one simple way you can do it with netstat, checking the port your database allows to connect, and if you have security concerns you can limit the ip addresses that connect in the configuration file. Most databases by default only allow localhost to connect to them.
Upvotes: 0