@@ -297,3 +297,150 @@ mongo.command('rs.add(\'mongodb2:27017\')').then(function (data) {
297297// }
298298
299299```
300+
301+
302+ * rs.status()
303+
304+ ``` js
305+
306+ mongo .command (' rs.status()' ).then (function (data ) {
307+ console .log (' data = ' , data);
308+ });
309+
310+
311+ // data = {
312+ // command: 'mongo --host localhost --port 27017 --eval "rs.status()"',
313+ // raw: '["MongoDB shell version: 3.2.0\\nconnecting to: localhost:27017/test\\n{\\n\\t\\"set\\" : \\"mongodb\\",\\n\\t\\"date\\" : ISODate(\\"2015-12-25T07:03:18.365Z\\"),\\n\\t\\"myState\\" : 1,\\n\\t\\"term\\" : NumberLong(1),\\n\\t\\"heartbeatIntervalMillis\\" : NumberLong(2000),\\n\\t\\"members\\" : [\\n\\t\\t{\\n\\t\\t\\t\\"_id\\" : 0,\\n\\t\\t\\t\\"name\\" : \\"mongodb1:27017\\",\\n\\t\\t\\t\\"health\\" : 1,\\n\\t\\t\\t\\"state\\" : 1,\\n\\t\\t\\t\\"stateStr\\" : \\"PRIMARY\\",\\n\\t\\t\\t\\"uptime\\" : 4872,\\n\\t\\t\\t\\"optime\\" : {\\n\\t\\t\\t\\t\\"ts\\" : Timestamp(1451023102, 1),\\n\\t\\t\\t\\t\\"t\\" : NumberLong(1)\\n\\t\\t\\t},\\n\\t\\t\\t\\"optimeDate\\" : ISODate(\\"2015-12-25T05:58:22Z\\"),\\n\\t\\t\\t\\"electionTime\\" : Timestamp(1451022242, 2),\\n\\t\\t\\t\\"electionDate\\" : ISODate(\\"2015-12-25T05:44:02Z\\"),\\n\\t\\t\\t\\"configVersion\\" : 3,\\n\\t\\t\\t\\"self\\" : true\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\"_id\\" : 1,\\n\\t\\t\\t\\"name\\" : \\"mongodb2:27017\\",\\n\\t\\t\\t\\"health\\" : 1,\\n\\t\\t\\t\\"state\\" : 2,\\n\\t\\t\\t\\"stateStr\\" : \\"SECONDARY\\",\\n\\t\\t\\t\\"uptime\\" : 4700,\\n\\t\\t\\t\\"optime\\" : {\\n\\t\\t\\t\\t\\"ts\\" : Timestamp(1451023102, 1),\\n\\t\\t\\t\\t\\"t\\" : NumberLong(1)\\n\\t\\t\\t},\\n\\t\\t\\t\\"optimeDate\\" : ISODate(\\"2015-12-25T05:58:22Z\\"),\\n\\t\\t\\t\\"lastHeartbeat\\" : ISODate(\\"2015-12-25T07:03:17.273Z\\"),\\n\\t\\t\\t\\"lastHeartbeatRecv\\" : ISODate(\\"2015-12-25T07:03:17.601Z\\"),\\n\\t\\t\\t\\"pingMs\\" : NumberLong(0),\\n\\t\\t\\t\\"syncingTo\\" : \\"mongodb1:27017\\",\\n\\t\\t\\t\\"configVersion\\" : 3\\n\\t\\t},\\n\\t\\t{\\n\\t\\t\\t\\"_id\\" : 2,\\n\\t\\t\\t\\"name\\" : \\"mongodb3:27017\\",\\n\\t\\t\\t\\"health\\" : 1,\\n\\t\\t\\t\\"state\\" : 2,\\n\\t\\t\\t\\"stateStr\\" : \\"SECONDARY\\",\\n\\t\\t\\t\\"uptime\\" : 3896,\\n\\t\\t\\t\\"optime\\" : {\\n\\t\\t\\t\\t\\"ts\\" : Timestamp(1451023102, 1),\\n\\t\\t\\t\\t\\"t\\" : NumberLong(1)\\n\\t\\t\\t},\\n\\t\\t\\t\\"optimeDate\\" : ISODate(\\"2015-12-25T05:58:22Z\\"),\\n\\t\\t\\t\\"lastHeartbeat\\" : ISODate(\\"2015-12-25T07:03:17.273Z\\"),\\n\\t\\t\\t\\"lastHeartbeatRecv\\" : ISODate(\\"2015-12-25T07:03:14.084Z\\"),\\n\\t\\t\\t\\"pingMs\\" : NumberLong(0),\\n\\t\\t\\t\\"configVersion\\" : 3\\n\\t\\t}\\n\\t],\\n\\t\\"ok\\" : 1\\n}\\n",""]',
314+ // lines:
315+ // ['MongoDB shell version: 3.2.0',
316+ // 'connecting to: localhost:27017/test',
317+ // '{',
318+ // '\t"set" : "mongodb",',
319+ // '\t"date" : ISODate("2015-12-25T07:03:18.365Z"),',
320+ // '\t"myState" : 1,',
321+ // '\t"term" : NumberLong(1),',
322+ // '\t"heartbeatIntervalMillis" : NumberLong(2000),',
323+ // '\t"members" : [',
324+ // '\t\t{',
325+ // '\t\t\t"_id" : 0,',
326+ // '\t\t\t"name" : "mongodb1:27017",',
327+ // '\t\t\t"health" : 1,',
328+ // '\t\t\t"state" : 1,',
329+ // '\t\t\t"stateStr" : "PRIMARY",',
330+ // '\t\t\t"uptime" : 4872,',
331+ // '\t\t\t"optime" : {',
332+ // '\t\t\t\t"ts" : Timestamp(1451023102, 1),',
333+ // '\t\t\t\t"t" : NumberLong(1)',
334+ // '\t\t\t},',
335+ // '\t\t\t"optimeDate" : ISODate("2015-12-25T05:58:22Z"),',
336+ // '\t\t\t"electionTime" : Timestamp(1451022242, 2),',
337+ // '\t\t\t"electionDate" : ISODate("2015-12-25T05:44:02Z"),',
338+ // '\t\t\t"configVersion" : 3,',
339+ // '\t\t\t"self" : true',
340+ // '\t\t},',
341+ // '\t\t{',
342+ // '\t\t\t"_id" : 1,',
343+ // '\t\t\t"name" : "mongodb2:27017",',
344+ // '\t\t\t"health" : 1,',
345+ // '\t\t\t"state" : 2,',
346+ // '\t\t\t"stateStr" : "SECONDARY",',
347+ // '\t\t\t"uptime" : 4700,',
348+ // '\t\t\t"optime" : {',
349+ // '\t\t\t\t"ts" : Timestamp(1451023102, 1),',
350+ // '\t\t\t\t"t" : NumberLong(1)',
351+ // '\t\t\t},',
352+ // '\t\t\t"optimeDate" : ISODate("2015-12-25T05:58:22Z"),',
353+ // '\t\t\t"lastHeartbeat" : ISODate("2015-12-25T07:03:17.273Z"),',
354+ // '\t\t\t"lastHeartbeatRecv" : ISODate("2015-12-25T07:03:17.601Z"),',
355+ // '\t\t\t"pingMs" : NumberLong(0),',
356+ // '\t\t\t"syncingTo" : "mongodb1:27017",',
357+ // '\t\t\t"configVersion" : 3',
358+ // '\t\t},',
359+ // '\t\t{',
360+ // '\t\t\t"_id" : 2,',
361+ // '\t\t\t"name" : "mongodb3:27017",',
362+ // '\t\t\t"health" : 1,',
363+ // '\t\t\t"state" : 2,',
364+ // '\t\t\t"stateStr" : "SECONDARY",',
365+ // '\t\t\t"uptime" : 3896,',
366+ // '\t\t\t"optime" : {',
367+ // '\t\t\t\t"ts" : Timestamp(1451023102, 1),',
368+ // '\t\t\t\t"t" : NumberLong(1)',
369+ // '\t\t\t},',
370+ // '\t\t\t"optimeDate" : ISODate("2015-12-25T05:58:22Z"),',
371+ // '\t\t\t"lastHeartbeat" : ISODate("2015-12-25T07:03:17.273Z"),',
372+ // '\t\t\t"lastHeartbeatRecv" : ISODate("2015-12-25T07:03:14.084Z"),',
373+ // '\t\t\t"pingMs" : NumberLong(0),',
374+ // '\t\t\t"configVersion" : 3',
375+ // '\t\t}',
376+ // '\t],',
377+ // '\t"ok" : 1',
378+ // '}',
379+ // ''],
380+ // object:
381+ // {
382+ // set: 'mongodb',
383+ // date: { '$date': '2015-12-25T07:03:18.365Z' },
384+ // myState: 1,
385+ // term: { '$numberLong': '1' },
386+ // heartbeatIntervalMillis: { '$numberLong': '2000' },
387+ // members:
388+ // [{
389+ // _id: 0,
390+ // name: 'mongodb1:27017',
391+ // health: 1,
392+ // state: 1,
393+ // stateStr: 'PRIMARY',
394+ // uptime: 4872,
395+ // optime:
396+ // {
397+ // ts: { '$timestamp': { t: 1451023102, i: 1 } },
398+ // t: { '$numberLong': '1' }
399+ // },
400+ // optimeDate: { '$date': '2015-12-25T05:58:22Z' },
401+ // electionTime: { '$timestamp': { t: 1451022242, i: 2 } },
402+ // electionDate: { '$date': '2015-12-25T05:44:02Z' },
403+ // configVersion: 3,
404+ // self: true
405+ // },
406+ // {
407+ // _id: 1,
408+ // name: 'mongodb2:27017',
409+ // health: 1,
410+ // state: 2,
411+ // stateStr: 'SECONDARY',
412+ // uptime: 4700,
413+ // optime:
414+ // {
415+ // ts: { '$timestamp': { t: 1451023102, i: 1 } },
416+ // t: { '$numberLong': '1' }
417+ // },
418+ // optimeDate: { '$date': '2015-12-25T05:58:22Z' },
419+ // lastHeartbeat: { '$date': '2015-12-25T07:03:17.273Z' },
420+ // lastHeartbeatRecv: { '$date': '2015-12-25T07:03:17.601Z' },
421+ // pingMs: { '$numberLong': '0' },
422+ // syncingTo: 'mongodb1:27017',
423+ // configVersion: 3
424+ // },
425+ // {
426+ // _id: 2,
427+ // name: 'mongodb3:27017',
428+ // health: 1,
429+ // state: 2,
430+ // stateStr: 'SECONDARY',
431+ // uptime: 3896,
432+ // optime:
433+ // {
434+ // ts: { '$timestamp': { t: 1451023102, i: 1 } },
435+ // t: { '$numberLong': '1' }
436+ // },
437+ // optimeDate: { '$date': '2015-12-25T05:58:22Z' },
438+ // lastHeartbeat: { '$date': '2015-12-25T07:03:17.273Z' },
439+ // lastHeartbeatRecv: { '$date': '2015-12-25T07:03:14.084Z' },
440+ // pingMs: { '$numberLong': '0' },
441+ // configVersion: 3
442+ // }],
443+ // ok: 1
444+ // }
445+ // }
446+ ```
0 commit comments