Skip to content

Commit

Permalink
helper script
Browse files Browse the repository at this point in the history
  • Loading branch information
dwight committed Sep 28, 2011
1 parent b2c68df commit eebf74f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions js/opsbyip.js
@@ -0,0 +1,24 @@
print("opsbyip.js");
print("usage:");
print("mongo --shell <otheroptions> opsbyip.js");
print("> ops() // to see # of ops in progress by client ip address");
print("> ops(true) // to include inactive ops in the report");
print("> ops // with no parens to see the function's implementation");

function ops(includeinactive) {
var c = db.currentOp().inprog;

var res = {};

for( i in c ) {
var op = c[i];
if( op.active || includeinactive ) {
var ip = op.client.split(':')[0];
if( !res[ip] )
res[ip] = 0;
res[ip]++;
}
}

printjson(res);
}

0 comments on commit eebf74f

Please sign in to comment.