Detect Connections to mongos Instances
To detect if the MongoDB instance that your client is connectedto is mongos, use the isMaster command. When aclient connects to a mongos, isMaster returnsa document with a msg field that holds the stringisdbgrid. For example:
{
"ismaster" : true,
"msg" : "isdbgrid",
"maxBsonObjectSize" : 16777216,
"ok" : 1
}
If the application is instead connected to a mongod, thereturned document does not include the isdbgrid string.