该脚本用于zabbix监控达梦dts迁移进程的健康状态,首先查看脚本是否有报错,如果没有就检查日志时间戳,指定时间内有更新视为正常。

format_date=$(date +%s -r /opt/dmdbms/log/dmdts.log)
now_date=$(date +%s)
result=$(tail -n 20 /opt/dmdbms/log/dmdts.log)
result2=$(tail -n 1 /opt/bgtG6NMainSql/runsql_main.log)
if [[ ${result} =~ '失败' ]];then
    echo 'EXECError'
elif [[ ${result2} =~ 'at' ]];then
    echo 'SQLError'
else
    if [ $(($now_date-$format_date)) -gt 600 ];then
        echo 'RunError'
    else
        echo 'Normal'
    fi
fi

推荐python3运行该脚本。