سؤال

Is there a way to get the results of

db.serverStatus() 

from casbah to handle them?

I specifically need the connections, network, metrics fields.

Thanks

هل كانت مفيدة؟

المحلول

    import com.mongodb.casbah.Imports._ 

    //connect to MongoDB, testDB is the name of database
    val test = MongoClient()("testDB")
    // run serverStatus command
    val status = test.command("serverStatus")
    // status is an instance of BasicDBObject 
    //retrieving number of available connections
    val availableConnections = status.get("connections").asInstanceOf[BasicDBObject].get("available")  
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top