Hi. I want to get the results of sh.status() but using the ruby mongo driver. Specifically I need to see the shard keys for each collection, not just the hosts for each shard.
I’m looking for something similar to the output of running sh.status() on a mongos:
The first 3 give only the hosts of the shards and the 4th only collection data, but not the shard keys of the collections. I’ve also tried getting the contents of the config.databases collection, that doesn’t include the shard keys either.
All we’re doing here is querying the config.collections collection and formatting the results. If you wanted to show chunk details, as you iterate over each sharded collection above you could query the config.chunks collection to collect the necessary information.