Skip to content

Instantly share code, notes, and snippets.

@davemackintosh
Last active August 29, 2015 14:10
Show Gist options
  • Save davemackintosh/77c017e3882485918c37 to your computer and use it in GitHub Desktop.
Save davemackintosh/77c017e3882485918c37 to your computer and use it in GitHub Desktop.
Mongo database currentOp() helper. Makes it a bit nicer
db.currentOp().inprog.forEach(function(op) {
if (op.progress) {
var remaining = op.progress.total - op.progress.done;
var running_for = op.secs_running / 60 / 60;
print(op.ns, op.opid, 'running for', running_for.toPrecision(4), 'hours')
print('job "'+ op.insert.name +'" running in background?', op.insert.background ? 'yes' : 'no');
print(op.msg)
print('Remaining records', remaining, 'finished', op.progress.done, 'docs')
print('Estimated', ((running_for / op.progress.done) * remaining).toPrecision(4), 'hours remaining')
print('\n')
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment