We know that db.hostInfo() gives System and OS details of the node we connected to.
Also rs.status or rs.conf() or rs.isMaster() do not provide System or OS info.
If we want to get System and OS details of all the nodes from Primary(without connecting to other nodes), Is it possible ?
Could you please suggest me on how to get System and OS details of all the nodes sitting from Primary.
Note: the above snippet can be run via any member of the replica set. It doesn’t include authentication (you will need to call db.auth() with appropriate credentials), but should be a useful starting point. I used rs.status().members instead of rs.conf().members, because rs.status() includes the self field (no need to open a new connection to the current member) and some additional fields like health and state that might be interesting for logging/monitoring purposes.
For more robust error handling I recommend implementing this using one of the supported MongoDB drivers.
An alternative to rolling your own monitoring solution would be to use MongoDB Cloud Manager (hosted management platform) or MongoDB Ops Manager (on-premises management platform).
Hi @Stennie_X,
Great information and thanks for the update.
I got what I have been looking for.
I modified the following.
i)print([${member._id}]: ${member.host}) as print([${member._id}]: ${member.name});
ii)new Mongo(member.host) as new Mongo(member.name).getDB(“admin”);
and used mdb.auth to get authenticated.