Mongo 2.2.2 runCommand and serverStatus

When I run the code below, I get undefined method ‘runCommand’. If I
switch to use the db.serverStatus() method instead, I get the error
undefined method ‘serverStatus’. Not sure what is going on. I’m
relatively new to Ruby. All the Mongo documentation suggests both these
methods exist. I’m trying to get the server status from MongoDb version
3.0. I’m using the mongo 2.2.2 driver version in Ruby.


See ruby code below:

require ‘rubygems’
require ‘mongo’
include Mongo

client =[‘’],
:database => ‘admin’, :collection => ‘system’, :user => ‘somevalue’,
:password => ‘somevalue’)
db = client.database
doc = db.runCommand({serverStatus: 1})
puts doc

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs