I'm trying to get the primary currently used by a specific replica set in a shell script.
$ bin/mongo --host rs0/172.17.0.8,172.17.0.9,172.17.0.14 --quiet --eval 'var _s=rs.status(); if (typeof _s.members != "undefined") { _s.members.forEach(function (x) {if (x.stateStr=="PRIMARY") { print(x.name); }})}' 2016-11-22T17:06:58.396+0000 I NETWORK [thread1] Starting new replica set monitor for rs0/172.17.0.14:27017,172.17.0.8:27017,172.17.0.9:27017 2016-11-22T17:06:58.397+0000 I NETWORK [ReplicaSetMonitorWatcher] starting 2016-11-22T17:06:58.400+0000 I NETWORK [thread1] changing hosts to rs0/mongodb-0.mongodb.default.svc.cluster.local:27017 from rs0/172.17.0.14:27017,172.17.0.8:27017,172.17.0.9:27017 mongodb-0.mongodb.default.svc.cluster.local:27017
The info/network messages there shouldn't be there, but they are now mixed with the output from the javascript evaluation. Minimally these messages should be on stderr, so that they can be filtered out easily.
- is duplicated by
-
SERVER-33555 mongo --quiet does not silence initial connection messages
- Closed
-
SERVER-38385 --quiet mongo shell option does not silence output when connecting to Replica Set
- Closed
- is related to
-
SERVER-23810 Don't Print Shell Log Messages to STDOUT When --quiet Is Used
- Closed
-
SERVER-4391 --eval should be affected by the --quiet switch
- Backlog
- links to