[Bugfix][T106][bug-view-792]cpu usage high due to lynq_monitor.sh

Only Configure :No
Affected branch: master
Affected module: monitor
Is it affected on both ZXIC and MTK:only ASR
Self-test: Yes
Doc Update: No

Change-Id: Iadc26b4a11789bcd2b39d4ef5e55a00568c93a0f
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/lynq_monitor.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/lynq_monitor.sh
old mode 100644
new mode 100755
index 72e61c7..b488ea7
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/lynq_monitor.sh
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/lynq_monitor.sh
@@ -1,60 +1,66 @@
 #!/bin/sh
 while true
 do
-    sleep 30
-    ps -ef|grep lynq-sdk-ready |grep -v "grep" > /dev/null
-    if [ $? -ne 0 ]; then
+    sleep 10
+    ps_output=$(ps -A -o stat,pid,args | grep -E "lynq-ril-service|lynq-sdk-ready|autosuspend|lynq-atcid"|grep -v grep|grep -v T)
+    # 检查进程是否存在
+    sdk_output=$(echo "$ps_output" | grep "lynq-sdk-ready")
+    if [ -z "$sdk_output" ]; then
         echo "lynq-sdk-ready no exist" > /dev/kmsg
         sh /etc/init.d/lynq-sdk-ready.sh start
     else
-        ps -A -ostat,pid,comm |grep lynq-sdk-ready| grep Z > /dev/null
-        if [ $? -eq 0 ]; then
+        # 检查是否为僵尸进程
+        if echo "$sdk_output" | grep -q "Z"; then
             echo "lynq-sdk-ready state is Z" > /dev/kmsg
-            pid=$(ps -A -ostat,pid,comm |grep lynq-sdk-ready|grep Z|awk '{print $2}')
+            pid=$(echo "$sdk_output" | awk '/Z/ {print $2}')
             kill -9 $pid
             sh /etc/init.d/lynq-sdk-ready.sh start
         fi
     fi
-
-    ps -ef|grep lynq-atcid |grep -v "grep" > /dev/null
-    if [ $? -ne 0 ]; then
+    sleep 10
+    atcid_output=$(echo "$ps_output" | grep "lynq-atcid")
+    # 检查进程是否存在
+    if [ -z "$atcid_output" ]; then
         echo "lynq-atcid no exist" > /dev/kmsg
         sh /etc/init.d/lynq-atcid.sh start
     else
-        ps -A -ostat,pid,comm |grep lynq-atcid| grep Z > /dev/null
-        if [ $? -eq 0 ]; then
+        # 检查是否为僵尸进程
+        if echo "$atcid_output" | grep -q "Z"; then
             echo "lynq-atcid state is Z" > /dev/kmsg
-            pid=$(ps -A -ostat,pid,comm |grep lynq-atcid|grep Z|awk '{print $2}')
+            pid=$(echo "$atcid_output" | awk '/Z/ {print $2}')
             kill -9 $pid
             sh /etc/init.d/lynq-atcid.sh start
         fi
     fi
-
-    ps -ef|grep lynq-ril-service |grep -v "grep" > /dev/null
-    if [ $? -ne 0 ]; then
+    sleep 10
+    ril_output=$(echo "$ps_output" | grep "lynq-ril-service")
+    # 检查进程是否存在
+    if [ -z "$ril_output" ]; then
         echo "lynq-ril-service no exist" > /dev/kmsg
         sh /etc/init.d/lynq-ril-service.sh start
     else
-        ps -A -ostat,pid,comm |grep lynq-ril-service| grep Z > /dev/null
-        if [ $? -eq 0 ]; then
+        # 检查是否为僵尸进程
+        if echo "$ril_output" | grep -q "Z"; then
             echo "lynq-ril-service state is Z" > /dev/kmsg
-            pid=$(ps -A -ostat,pid,comm |grep lynq-ril-service|grep Z|awk '{print $2}')
+            pid=$(echo "$ril_output" | awk '/Z/ {print $2}')
             kill -9 $pid
             sh /etc/init.d/lynq-ril-service.sh start
         fi
     fi
-
-    ps -ef|grep autosuspend |grep -v "grep" > /dev/null
-    if [ $? -ne 0 ]; then
+    sleep 10
+    suspend_output=$(echo "$ps_output" | grep "autosuspend")
+    # 检查进程是否存在
+    if [ -z "$suspend_output" ]; then
         echo "lynq-autosuspend no exist" > /dev/kmsg
         sh /etc/init.d/lynq-autosuspend.sh start
     else
-        ps -A -ostat,pid,comm |grep autosuspend| grep Z > /dev/null
-        if [ $? -eq 0 ]; then
+        # 检查是否为僵尸进程
+        if echo "$suspend_output" | grep -q "Z"; then
             echo "lynq-autosuspend state is Z" > /dev/kmsg
-            pid=$(ps -A -ostat,pid,comm |grep autosuspend|grep Z|awk '{print $2}')
+            pid=$(echo "$suspend_output" | awk '/Z/ {print $2}')
             kill -9 $pid
             sh /etc/init.d/lynq-autosuspend.sh start
-        fi   
+        fi
     fi
+
 done