mongo stats and backup in C++

45 views
Skip to first unread message

Mick

unread,
Sep 20, 2012, 2:56:52 PM9/20/12
to mongod...@googlegroups.com
Are there any C++ commands to gather database stats and perform database backup/restore? 
I know there are plenty in the shell, but couldn't find anything for C++.  
Any help is greatly appreciated :)

David Hows

unread,
Sep 20, 2012, 7:57:22 PM9/20/12
to mongod...@googlegroups.com
Hi Mick,

There are no tools for backup in C++, you would be best looking at the mongodump and mongorestore applications.
Please have a look at our documentation for backup information http://www.mongodb.org/display/DOCS/Backups

As for gathering statistics you can normally run any command within C++ using the runCommand function, but without specifics of what you are looking for i cannot provide you with anything concrete.

As an example here is a short wrapper to get the dbstats of the test database:
BSONObj a = BSON("dbstats" << 1 << "scale" << 1 );
BSONObj ret;
c.runCommand( "test", a, ret);

Cheers,

David

Mick

unread,
Sep 21, 2012, 2:54:59 PM9/21/12
to mongod...@googlegroups.com
Thank you, David, for your helpful and prompt response :)
I'm wondering if you can get mongo stats like average object size (avgObjSize in MongoVUE), dataSize, storageSize, maybe free space?
Thanks again :)

Mick

unread,
Sep 21, 2012, 4:33:15 PM9/21/12
to mongod...@googlegroups.com
Actually, I spoke too soon in my previous post...  I just ran the runCommand and the result has all the information that I need, thank you very much for your help, David :)
 

On Thursday, September 20, 2012 11:56:52 AM UTC-7, Mick wrote:
Reply all
Reply to author
Forward
0 new messages