Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How run mongo command "rs.status" from c# driver

I have a Replica Set, and i want to get rs.status() to analyze it. How can i run commands like rs.status() from C# driver ?

like image 854
irmorteza Avatar asked Nov 30 '13 05:11

irmorteza


1 Answers

I am not really familiar with C#, but you can use C#'s runCommand method, keeping in mind that rs.Status is a wrapper around replSetGetStatus database command. Which means you can run it with db.runCommand({ replSetGetStatus: 1 })

P.S. incorporating irmorteza's comment:

var database = mongoServer.GetDatabase("admin"); 
var res = database.RunCommand("replSetGetStatus");
like image 142
Salvador Dali Avatar answered Oct 21 '22 06:10

Salvador Dali