I am getting no such command error while running stat command as in
db.stat()
in mongo console
But running it from moped gives error
session.command(stat: 1)
failed with error "no such cmd: stat"
The mongo console command is "stats" (not "stat") and is documented here.
http://docs.mongodb.org/manual/reference/method/db.stats/
As detailed,
The db.stats() method is a wrapper around the dbStats database command.
http://docs.mongodb.org/manual/reference/command/dbStats/#dbcmd.dbStats
So here is a test showing usage for moped.
test.rb
require 'moped'
require 'test/unit'
require 'pp'
class MyTest < Test::Unit::TestCase
def setup
@session = Moped::Session.new([ "127.0.0.1:27017" ])
@session.use "test"
end
test "db stats" do
puts "Moped::VERSION:#{Moped::VERSION}"
dbstats = @session.command(dbstats: 1)
assert_equal("test", dbstats["db"])
pp dbstats
end
end
ruby test.rb
Loaded suite test
Started
Moped::VERSION:1.5.2
{"db"=>"test",
"collections"=>3,
"objects"=>5,
"avgObjSize"=>99.2,
"dataSize"=>496,
"storageSize"=>24576,
"numExtents"=>3,
"indexes"=>1,
"indexSize"=>8176,
"fileSize"=>67108864,
"nsSizeMB"=>16,
"dataFileVersion"=>{"major"=>4, "minor"=>5},
"extentFreeList"=>{"num"=>0, "totalSize"=>0},
"ok"=>1.0}
.
Finished in 0.005335 seconds.
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
187.44 tests/s, 187.44 assertions/s