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.
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.
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 + ";")
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With