Created
November 6, 2013 19:15
-
-
Save mpobrien/7342345 to your computer and use it in GitHub Desktop.
mongodb cluster pretty printer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ShardingTest.prototype.prettyPrint = function(){ | |
print("MONGOS instances"); | |
for(var i=0;i<this._mongoses.length;i++){ | |
print("\tmongos",this._mongoses[i].port, this._mongoses[i].getDB("admin").version()) | |
} | |
print("config servers"); | |
for(var i=0;i<this._configServers.length;i++){ | |
print("\tconfig",this._configServers[i].port, this._configServers[i].getDB("admin").version()) | |
} | |
print("Standalone Shards"); | |
for(var i=0;i<this._connections.length;i++){ | |
if(this._connections[i] == null) continue | |
print("\tmongod",this._connections[i].port, this._connections[i].getDB("admin").version()) | |
} | |
print("ReplSet Shards"); | |
for(var i=0;i<this._rsObjects.length;i++){ | |
print("\tShard ", i); | |
var rs = this._rsObjects[i] | |
var rsStatus = rs.status() | |
for(var j=0;j<rsStatus.members.length;j++){ | |
var member = rsStatus.members[j] | |
print("\t\t",member.name, member.stateStr) | |
} | |
} | |
} | |
# x is an instance of ShardingTest | |
#mikes-MacBook-Pro(mongod-2.5.4-pre-) test> x.prettyPrint() | |
#MONGOS instances | |
# mongos 30999 2.4.1 | |
# mongos 30998 2.4.1 | |
#config servers | |
# config 29000 2.5.4-pre- | |
# config 29001 2.5.4-pre- | |
# config 29002 2.5.4-pre- | |
#Standalone Shards | |
#ReplSet Shards | |
# Shard 0 | |
# mikes-MacBook-Pro.local:31100 PRIMARY | |
# mikes-MacBook-Pro.local:31101 SECONDARY | |
# mikes-MacBook-Pro.local:31102 SECONDARY | |
# Shard 1 | |
# mikes-MacBook-Pro.local:31200 PRIMARY | |
# mikes-MacBook-Pro.local:31201 SECONDARY | |
# mikes-MacBook-Pro.local:31202 SECONDARY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment