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/
Written by Brandon Black
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mongodb
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#