-jws4a
Last Updated: February 25, 2016
·
1.05K
· brandonblack
Brandonblack

Showing active queries by type in MongoDB

Print all active reads:

db.currentOp().inprog.forEach(
   function(d){
     if(d.waitingForLock && d.lockType != "read")
        printjson(d)
     })

Print all active writes:

db.currentOp().inprog.forEach(
   function(d){
     if(d.waitingForLock && d.lockType != "write")
        printjson(d)
     })

You can get a lot more granular if you like using currentOp.op to filter by a specific operation type (insert, update, delete, etc).

Check out the following page from MongoDB.org's documentation for more info:
http://docs.mongodb.org/manual/reference/current-op/

Say Thanks
Respond