#!/bin/bash
set +x
LOG_FILE="/var/log/inspect.log"
G_MML_FILE_PATH="/opt/huawei/snas/script/inspect_mml"
source $G_MML_FILE_PATH/CheckItems
CurInspectNum="343"
CurInspectFun="$(GetInspectType $CurInspectNum)"
RESULTFILE="${G_TMP_INSPECT_PATH}tmpResult${CurInspectFun}"
>${RESULTFILE}
isPass=0

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

function checkAndStartQuotaScanProcess()
{
    local lowestCaIdBackIP=$( cat /proc/monc_camap | grep "^CA" | sort -nk 2 | head -1 | awk '{print $4}' )

    ifconfig | grep -w "${lowestCaIdBackIP}"
    if [ $? -ne 0 ]; then
        return
    fi

    # ֻcamapidСĽڵż/opt/huawei/snas/sbin/nas_quota_scan_run.pyǷ
    ps -ef | grep /opt/huawei/snas/sbin/nas_quota_scan_run.py | grep -v grep
    if [ $? -eq 0 ]; then
        echo "INFO:quota scan process is running." >>${RESULTFILE} 2>&1
        return
    fi

    # ˵ûУѲ첻ͨ
    isPass=1
    echo "[ERR]INFO:quota scan process is stopped." >>${RESULTFILE} 2>&1
    LOG "[$LINENO]nas_quotascan_run.sh process is stopped."
    return 
}

# ǰڵ/proc/monc_camapidСģ/opt/huawei/snas/sbin/nas_quota_scan_run.pyǷС
checkAndStartQuotaScanProcess

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