|
@@ -26,6 +26,10 @@ if [[ $state == "SECONDARY" ]];then
|
|
date=`mongo --host $myhost --eval 'rs.status().date;' |tail -1`
|
|
date=`mongo --host $myhost --eval 'rs.status().date;' |tail -1`
|
|
dates=`date -d "$date" "+%s"`
|
|
dates=`date -d "$date" "+%s"`
|
|
lastHeartbeat=`mongo --host $myhost --quiet --eval 'var i=0; rs.status().members.forEach( function(myDoc) { if (myDoc.stateStr=="PRIMARY") { print(myDoc.lastHeartbeat); i++;} })' |tail -1`
|
|
lastHeartbeat=`mongo --host $myhost --quiet --eval 'var i=0; rs.status().members.forEach( function(myDoc) { if (myDoc.stateStr=="PRIMARY") { print(myDoc.lastHeartbeat); i++;} })' |tail -1`
|
|
|
|
+ if [[ -z "${lastHeartbeat}" ]]; then
|
|
|
|
+ echo "Zero HartBeat - no PRIMARY !!!"
|
|
|
|
+ exit 1
|
|
|
|
+ fi
|
|
datelh=`date -d "$lastHeartbeat" "+%s"`
|
|
datelh=`date -d "$lastHeartbeat" "+%s"`
|
|
if [[ $(($dates-$datelh)) -le "60" ]]; then
|
|
if [[ $(($dates-$datelh)) -le "60" ]]; then
|
|
echo "0"
|
|
echo "0"
|