有没有办法获得
的结果db.serverStatus()
来自 casbah 来处理它们?
我特别需要连接,网络,指标字段。
由于
答案 0 :(得分:2)
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")