Permalink
Browse files

helper script

  • Loading branch information...
1 parent b2c68df commit eebf74fa174060e2b0e52a5d04a0e51c85ff7489 @dwight dwight committed Sep 28, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 js/opsbyip.js
View
@@ -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.