#!/bin/sh
set +x
G_MML_FILE_PATH="/opt/huawei/snas/script/inspect_mml"
source $G_MML_FILE_PATH/CheckItems
CurInspectNum="244"
CurInspectFun="$(GetInspectType $CurInspectNum)"
RESULTFILE="/tmp/tmpResult${CurInspectFun}"
LOG_FILE="/var/log/inspect.log"

>${RESULTFILE}

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

function CheckDelTask
{
    local isPass=0
    local productVersion=$(grep ProductVersion /opt/huawei/deploy/package/version |awk -F= '{print $2}')
    local rmbg_data="---"
    #获取节点存储类型
    local node_service_type=$(egrep '[[]|^'node_service_type'=' /opt/huawei/snas/etc/snas.ini | tr -d '\n' | grep -Po '(?<=[[]'NODE'[]]'node_service_type'=)[0-9]+')
    if [ "${node_service_type}" != "1" ];then
        recycle_switch="Not dfs node"
        LOG "node_service_type :${node_service_type}.Does not involve"
    else
        #MmlBatch 988 "mds cfg show" | grep recycle_switch  为0表示关闭，1打开
        recycle_switch_CfgVal=$(/usr/local/bin/MmlBatch 988 "mds cfg show" | grep recycle_switch |awk -F"|" '{print $6}' | sed 's/^ *//g'| sed 's/ *$//g')
        if [ "X${recycle_switch_CfgVal}" = "X1" ];then
            recycle_switch="ON"
        else
            isPass=1
            recycle_switch="OFF"
        fi
    fi
    if [ "$productVersion" != "V300R006C00SPC200" ];then
        LOCAL_BACK_IP=$(GetLocalIp)
        #V3R6C20-7.X 在bjmserver节点执行MmlBatch 4100 'manager get job 119'查看State(1)为running状态
        local isBjmServer=$(cat /proc/monc_jmmap | grep "active manager ip" | grep -w "${LOCAL_BACK_IP}")
        if [ "X${isBjmServer}" != "X" ];then
            local rmbg_data_State=$(/usr/local/bin/MmlBatch 4100 'manager get job 119' |grep -w rmbg_data |awk '{print $5}')
            if [ "X${rmbg_data_State}" = "X(1)" ];then
                rmbg_data="Running"
            else
                isPass=1
                rmbg_data="Not Running"
            fi
        fi
    fi
    echo "recycle_switch:${recycle_switch}||rmbg_data:${rmbg_data}" >>${RESULTFILE} 2>&1
    echo "${CurInspectFun}_Pass ${isPass}" >>${RESULTFILE} 2>&1
}

CheckDelTask
exit 0
