Last active
December 17, 2015 13:13
-
-
Save marcoberri/4c28b94ab9890adb6dcc to your computer and use it in GitHub Desktop.
MongoDB - Get last profiled query in all db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var dbs_list = db.getMongo().getDBNames(); | |
| for(var d in dbs_list){ | |
| var name = dbs_list[d]; | |
| if(name == 'admin' || name == 'local') | |
| continue; | |
| dbOne = db.getSisterDB(name); | |
| print("dbname -->" + name); | |
| var cursor = dbOne.system.profile.find( { op:"query", millis : { $gte : 5 },ns : { $ne : (name + '.system.profile') } },{ ts:1,millis:1, nscanned:1, nreturned:1, ns:1, query:1} ).sort({ts:-1}).limit(5); | |
| cursor.forEach(function(r) { | |
| print(JSON.stringify(r)); | |
| }); | |
| print(); | |
| print(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment