stanley-king 3 gadi atpakaļ
vecāks
revīzija
b3637fd932
1 mainītis faili ar 14 papildinājumiem un 20 dzēšanām
  1. 14 20
      util/purge.sh

+ 14 - 20
util/purge.sh

@@ -28,30 +28,24 @@ else
 fi
 
 function slave_running() {
-    ra=`mysql -uroot -pXTZ@shop@951688 --host=$1 -e "show slave status\G; " | grep Slave_IO_Running:`
-    rb=`mysql -uroot -pXTZ@shop@951688 --host=$1 -e "show slave status\G; " | grep Slave_SQL_Running:`
+    ra=`mysql -uroot -pXTZ@shop@951688 --host=$1 -e "show slave status\G; " | grep Slave_IO_Running: | awk '{print $2}'`
+    rb=`mysql -uroot -pXTZ@shop@951688 --host=$1 -e "show slave status\G; " | grep Slave_SQL_Running: | awk '{print $2}'`
 
-    echo $ra
-
-    a=${ra#*:}
-    b=${rb#*:}
-
-    echo $a
-
-    a=`echo $a | xargs`
-    b=`echo $b | xargs`
+    for a in ${ra[@]}
+    do
+        if [[ $a != 'Yes' ]];then
+            return 0
+        fi
+    done
 
-    for x in ${a[@]}
+    for b in ${rb[@]}
     do
-      echo $x
+        if [[ $b != 'Yes' ]];then
+            return 0
+        fi
     done
 
-    if [[ $a == 'Yes' &&  $b == 'Yes' ]];then
-        return 1
-    else
-      echo $a,$b
-      return 0
-    fi
+    return 1
 }
 
 function slave_behind_match() {
@@ -69,7 +63,7 @@ function slave_behind_match() {
     fi
 }
 
-ra=`mysql -uroot -pXTZ@shop@951688 --host=172.26.80.8 -e "show slave status\G; " | grep Slave_IO_Running:`
+#ra=`mysql -uroot -pXTZ@shop@951688 --host=172.26.80.8 -e "show slave status\G; " | grep Slave_IO_Running: | awk '{print $2}'`
 
 #master = '172.26.80.10'
 slave_hosts=(${XYZ_SLAVE_HOSTS//:/ })