Skip to content

Instantly share code, notes, and snippets.

@marcoberri
Last active January 28, 2016 08:28
Show Gist options
  • Select an option

  • Save marcoberri/5ff35ced0a8d3c744008 to your computer and use it in GitHub Desktop.

Select an option

Save marcoberri/5ff35ced0a8d3c744008 to your computer and use it in GitHub Desktop.
analyze current Operation
while(1) {
var c = db.currentOp();
if(c && c.inprog && c.inprog.length > 0 && c.inprog[0].op == 'query') {
var el = c.inprog[0];
if( el.ns == 'admin.$cmd' || el.ns == 'local.$cmd' || el.ns == '')
continue;
print("on:" + el.ns);
if(el.microsecs_running && el.microsecs_running.floatApprox)
print("time:" + el.microsecs_running.floatApprox);
print("query: " + JSON.stringify(el.query));
print();
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment