1

I'm attempting to create a list of all current connections to my MongoDB 3.2 database. So far I've been able to list connections using:

db.currentOp(true).inprog.forEach(function(x) { print(x.client_s) })

hacked together from another answer for MongoDB 2.2 but it's a bit messy:

mongos> db.currentOp(true).inprog.forEach(function(x) { print(x.client_s) })
10.0.8.37:34572
10.0.8.42:40883
10.0.8.39:37430
10.0.8.39:43980
10.0.8.43:60428
10.0.8.38:37615
10.0.8.39:57476
[unknown type]
10.0.8.37:39592
[unknown type]
[unknown type]
10.0.8.38:44813
10.0.8.41:55001
[unknown type]
[unknown type]
[unknown type]
10.0.8.43:37350
[unknown type]
[unknown type]
[unknown type]
[unknown type]
[unknown type]
[unknown type]
[unknown type]
10.0.8.40:42973
[unknown type]
[unknown type]
[unknown type]
10.0.8.39:57488
[unknown type]
[unknown type]

I'd like to filter out the [unknown type] result and then tie each op to a user. I've noticed username and connectionId pop up in the MongoDB logs, so I can see it's possible — just not sure how to proceed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.