Friday, July 18, 2014

db.currentOp() - MongoDB in-progress operations for database instance


db.currentOp() will return a document that reports in-progress operations for the database instance


i.e

db.currentOp(true)
This will return a more descriptive output, including idle connections and system operations.

Note: db.currentOp() is available only for Administrative users




To get current users;

db.currentOp().inprog.forEach(
   function(d){
     if(d.client)
        printjson(d.client)
     })

 Shards Environment

db.currentOp().inprog.forEach(
   function(d){
     if(d.client_s)
        printjson(d.client_s)
     })

Return the active write operation 

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



Return all active read operations

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




No comments:

Post a Comment