|
@@ -1,3 +1,4 @@
|
|
|
|
+#!/bin/bash
|
|
|
|
|
|
if [[ -n $1 ]]; then
|
|
if [[ -n $1 ]]; then
|
|
myhost=$1
|
|
myhost=$1
|
|
@@ -5,10 +6,7 @@ else
|
|
myhost=localhost:27017
|
|
myhost=localhost:27017
|
|
fi
|
|
fi
|
|
|
|
|
|
-EVAL="var i=0; rs.status().members.forEach( function(myDoc) { if (myDoc.name==\"$myhost\") { print(myDoc.stateStr); i++;} })"
|
|
|
|
-
|
|
|
|
-state=`echo $EVAL | mongo --host $myhost --quiet |tail -1`
|
|
|
|
-
|
|
|
|
|
|
+state=`mongo --host $myhost --quiet --eval 'var i=0; rs.status().members.forEach( function(myDoc) { if (myDoc.self==true) { print(myDoc.stateStr); i++;} })' |tail -1`
|
|
|
|
|
|
if [[ $state == "PRIMARY" ]];then
|
|
if [[ $state == "PRIMARY" ]];then
|
|
echo "0"
|
|
echo "0"
|