Navigation
This version of the documentation is archived and no longer supported.

db.currentOp()

db.currentOp()
Returns:A document that contains an array named inprog.

The inprog array reports the current operation in progress for the database instance. See Current Operation Reporting for full documentation of the output of db.currentOp().

db.currentOp() is only available for users with administrative privileges.

Consider the following JavaScript operations for the mongo shell that you can use to filter the output of identify specific types of operations:

  • Return all pending write operations:

    db.currentOp().inprog.forEach(
       function(d){
         if(d.waitingForLock && d.lockType != "read")
            printjson(d)
         })
    
  • 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)
         })
    

Warning

Terminate running operations with extreme caution. Only use db.killOp() to terminate operations initiated by clients and do not terminate internal database operations.