Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the replica set monitor output

Tags:

mongodb

I have a bash script which tries to monitor the number of documents in a collection by connecting to a replica set.

COUNT=`/bin/mongo --quiet --host $REPLICA_SET policy -u myuser -p mypwd --eval 'db.myColl.count()'`

I was expecting only a number as output, however I got:

Mon Apr 27 13:33:57.716 starting new replica set monitor for replica set xx wit                                                                             h seed of xxx 
Mon Apr 27 13:33:57.719 succes                                                                             sfully connected to seed xx for replica set xx
Mon Apr 27 13:33:57.719 changing hosts to ...  

...

Mon Apr 27 13:33:57.736 [ReplicaSetMonitorWatcher] starting 3043

Could anyone tell me how to disable this bunch of output? Thank you.

like image 947
yuyu33 Avatar asked Apr 27 '15 17:04

yuyu33


People also ask

What is a replica set?

A replica set is a group of mongod instances that maintain the same data set. A replica set contains several data bearing nodes and optionally one arbiter node. Of the data bearing nodes, one and only one member is deemed the primary node, while the other nodes are deemed secondary nodes.


1 Answers

I could not figure how to disable this. As a workaround you could a) tail -1 your output, or b) output a token that's likely to be unique just before your output and then grep it (e.g. in js: print("__myAwesomeOutput__=" + x + ";").

like image 144
coffee_machine Avatar answered Sep 22 '22 01:09

coffee_machine