#!/bin/bash
set +x

CurInspectNum="203"
G_INSPECT_MMLPATH="/opt/huawei/snas/script/inspect_mml"
source $G_INSPECT_MMLPATH/CheckItems
CurInspectFun="$(GetInspectType $CurInspectNum)"
RESULTFILE="${G_TMP_INSPECT_PATH}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
        Result1="INFO:${InstallPath} is exist."
    else
        Result1="INFO:${InstallPath} is not exist or is not a regular file."
        ErrInfoCommon "$Result1" "${RESULTFILE}"
        LOG "[$LINENO] $Result1"
        isPass=1
    fi

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

    LOG "[$LINENO]INFO:$Result1 $Result2"
    echo "$Result1" >>${RESULTFILE} 2>&1
    echo "$Result2" >>${RESULTFILE} 2>&1
    echo "${CurInspectFun}_Pass ${isPass}" >>${RESULTFILE} 2>&1
}

checkWatchdogStatus_Async
