When you run rs.printSecondaryReplicationInfo();
then the output is like this:
source: d-mipmdb-cfg-02:27019
syncedTo: Sat Apr 02 2022 20:01:01 GMT+0200 (W. Europe Daylight Time)
0 secs (0 hrs) behind the primary
source: d-mipmdb-cfg-03:27019
syncedTo: Sat Apr 02 2022 20:00:58 GMT+0200 (W. Europe Daylight Time)
3 secs (0 hrs) behind the primary
The documentation says “Use rs.printSecondaryReplicationInfo()
for manual inspection, and rs.status()
in scripts.” but it does not tell me directly where to see this information.
I guess with rs.status()
you get the same information with a script like this:
const members = rs.status().members
const primary = members.filter(x=> x.stateStr == "PRIMARY").shift().optimeDate;
members.filter(x=> x.stateStr == "SECONDARY").map(x=> {return `${x.name} is ${(primary - x.optimeDate)/1000} Seconds behind the primary`});
[
"d-mipmdb-cfg-02:27019 is 2 Seconds behind the primary",
"d-mipmdb-cfg-03:27019 is 3 Seconds behind the primary"
]
Is this correct or do I need to run something else?
Kind Regards
Wernfried