I want to monitor current connecton pool occupancy using .net mongo driver to produce stats each minute (like 5/MaxConnectionPoolSize is busy). But I can't see any option to do it in my driver (2.8.1). Is it even possible?
I've found some answers for the similar question for js client but sadly can't apply it to my situation.
How to get the number of connections used (and free) to the MongoDB (from a client perspective)?
you can use this command:
db.serverStatus()['connections']
{
"current" : 18,
"available" : 999982,
"totalCreated" : 2175,
"active" : 8,
"exhaustIsMaster" : 6,
"awaitingTopologyChanges" : 6
}
to run it via the driver, you should use: var doc = db.RunCommand<BsonDocument>("{ serverStatus : 1 }");