db.currentOp() in mongodb

currentOp(operations?)

This method returns a document that contains information on in-progress operations for the database instance.


Example 1:

This example returns information on all write operations that are waiting for a lock

MongoDB

db.currentOp({
        "waitingForLock" : true,
        $or: [
          { "op" : { "$in" : [ "insert", "update", "remove" ] } },
          { "query.findandmodify": { $exists: true } }
        ]
      })

Output:

{ "inprog" : [ ], "ok" : 1 }


Example 2:

This example returns information on all active operations for database db1 that have been running longer than 10 seconds:


MongoDB

db.currentOp({
        "active" : true,
        "secs_running" : { "$lt" : 10 },
        "ns" : /^db1\./
      })

Output:

{ "inprog" : [ ], "ok" : 1 }


No comments:

Post a Comment