Skip to content

Instantly share code, notes, and snippets.

@vitrun
Last active August 29, 2015 13:57
Show Gist options
  • Save vitrun/9635228 to your computer and use it in GitHub Desktop.
Save vitrun/9635228 to your computer and use it in GitHub Desktop.
function killall(ns, wet_run) {
ns = (typeof (ns) != 'undefined') ? ns : "";
inprog = db.currentOp().inprog;
for (var i in inprog) {
var op = inprog[i];
if (op.ns.indexOf(ns) != -1) {
if (wet_run == true) {
db.killOp(op.opid);
} else {
var toprint = {}
toprint.opid = op.opid;
toprint.secs_running = op.secs_running;
toprint.client = op.client;
printjsononeline(toprint);
}
}
}
}
var i = 0; while (i < 50000){killall("shoppingDB.taobaoItem", true); i++;}
@vitrun
Copy link
Author

vitrun commented May 22, 2014

get operation by collection
function getOpByColl(ns, wet_run) {
ns = (typeof (ns) != 'undefined') ? ns : "";
inprog = db.currentOp().inprog;
for (var i in inprog) {
var op = inprog[i];
if (op.ns.indexOf(ns) != -1) {
var toprint = {}
toprint.opid = op.opid;
toprint.ns = op.ns;
toprint.secs_running = op.secs_running;
toprint.client = op.client;
printjsononeline(toprint);
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment