大数据平台设置表数据量的监控任务
DB_NAME=${dbname}
TABLE_NAME=${tablename}
NORMAL_COUNT=${normalcount}
MAX_COUNT=${maxcount}
P_DATE=${pdate}
TABLE_ERR_FLAG=${DB_NAME}.${TABLE_NAME}.err
table_counts=$(hive -e "analyze table ${DB_NAME}.${TABLE_NAME} partition(pt='${P_DATE}') compute statistics;
desc formatted ${DB_NAME}.${TABLE_NAME} partition(pt='${P_DATE}')" | grep numRows | awk '{print $2}')
if [ ! ${table_counts} ]; then
table_counts=0
fi
echo "table_counts: $table_counts"
echo "normal_counts: ${NORMAL_COUNT}"
echo "maxcount: ${MAX_COUNT}"
echo "${P_DATE} ${TABLE_NAME}'s count is ${table_counts} , normal_count:${NORMAL_COUNT} , maxcount: ${MAX_COUNT}"
if [ ${table_counts} -gt ${NORMAL_COUNT} ] && [ ${table_counts} -lt ${MAX_COUNT} ] ; then
echo "check success"
else
echo "check error"
exit -1
fi