#!/bin/bash
set +x

CurInspectNum="203"
G_INSPECT_MMLPATH="/opt/huawei/snas/script/inspect_mml"
source $G_INSPECT_MMLPATH/CheckItems
CurInspectFun="$(GetInspectType $CurInspectNum)"
RESULTFILE="/tmp/tmpResult${CurInspectFun}"
>${RESULTFILE}
LOG_FILE="/var/log/inspect.log"

function LOG
{
   time=$(date)
   echo [${time}][$$][$CurInspectFun]$@ >> $LOG_FILE
}

#203. 鿴Ź״̬
checkWatchdogStatus_Async()
{
    InstallPath="/opt/product/deploy/bin/daemon"
    Result1=""
    Result2=""
    isPass=0

    #ļǷ
    file_daemon=$(ls $InstallPath)
    if [ "$file_daemon" == "$InstallPath" ] ;then
        echo "daemon:${InstallPath} is exist." >>${RESULTFILE} 2>&1
    else
        echo "INFO:${InstallPath} is not exist or is not a regular file." >>${RESULTFILE} 2>&1
        isPass=1
    fi

    ExecInfo=$(ps -C daemon | grep daemon)
    if [ "X${ExecInfo}" == "X" ]; then
        echo "INFO:${InstallPath} is not running." >>${RESULTFILE} 2>&1
        LOG "[$LINENO] ${InstallPath} is not running."
        isPass=1
    else
        echo "daemon:${InstallPath} is running."  >>${RESULTFILE} 2>&1
    fi

    echo "${CurInspectFun}_Pass ${isPass}" >>${RESULTFILE} 2>&1
}

checkWatchdogStatus_Async
