Just putting this here since I was struggling with the same for a while:
Here is how you can do it in python3
Tested on mongo version 4.0 and pymongo version 3.11.4
client = pymongo.MongoClient("mongodb://mongodb0.example.com:27017")
admin_db = client.get_database("admin")
milliseconds_running = 10000
query = [
Unfortunately a multitude of the articles on this subject tend to generalize away the specific key facts that actually matter when making a decision on this matter, which has led to a lot of misinformation and confusion.
First and foremost, there is nothing that makes a NoSQL database system faster when it comes to reading and writing data, no matter how ...
Excerpt from - https://docs.mongodb.com/database-tools/
Starting with MongoDB 4.4, the MongoDB Database Tools are now released separately from the MongoDB Server and use their own versioning, with an initial version of 100.0.0.
Previously, these tools were released alongside the MongoDB Server and used matching versioning.
Here's the link to download -
A one-liner would be this one:
mongo "mongodb://username:password@localhost:27018/admin?authSource=admin" --quiet --norc --eval "rs.status().members.filter( x => x.name == db.hello().me ).shift().health"
Function db.hello().me returns the server+port you are currently connected to. Replace this expression if you like to query other ...
cfg = rs.conf()
member.priority = 100
else if (/xyz/.test(member.host))
member.priority = 10
else if (member.host == '10.12.13.14')
member.priority = 0;