script/检查作业成功率/check_job_sucessful.sh

65 lines
2.3 KiB
Bash

#!/bin/bash
#set -x
PRG="$0"
while [ -h "$PRG" ]; do
ls=$(ls -ld "$PRG")
link=$(expr "$ls" : '.*-> \(.*\)$')
if expr "$link" : '.*/.*' >/dev/null; then
PRG="$link"
else
PRG=$(dirname "$PRG")/"$link"
fi
done
PRGDIR=$(dirname "$PRG")
#full path
cd $PRGDIR
ROOT_DIR=$(pwd)
cd - >/dev/null
echo "" >$ROOT_DIR/check_report.txt
# 查询某个策略的成功率
function check_sucessful(){
# 代理信息和策略名
comname=$1
compid=$2
policyname=$3
#查询
recode=`mysql -uunadba -p1223Bc@2008 unary -e "select 1-(tb1.n1/tb2.n2) from ( (select sum(number) as n1 from ( select operdesc,count(*) as number from tbl_jobhistory where policyname='${policyname}' and compid='${compid}' group by operdesc) as tmp1 where tmp1.operdesc like '%失败%') as tb1 right JOIN (select count(*) as n2 from tbl_jobhistory where policyname='${policyname}' and compid='${compid}') tb2 on 1=1);" | tail -1`
#输出结果
echo -e "${comname}" >>$ROOT_DIR/check_report.txt
echo -e "\t ${policyname} 的作业成功率为: ${recode}" >>$ROOT_DIR/check_report.txt
echo -e "\n-----------\n" >>$ROOT_DIR/check_report.txt
}
# 需要检查的代理
# mh
check_sucessful "6.9长期mh_MySQL定时备份_13.167" "811da1a9258bb690d58aaef5aa958027" "长期任务-mysql物理多通道"
check_sucessful "6.9长期mh_OraclePhysical定时备份_29.41" "effbff8590c4c69a33151fa4d4fff2e1" "长期Oracle多通道"
check_sucessful "6.9长期mh_系统定时备份_29.33" "bd22ea57feecb5a7f96e67035c204e02" "长期系统"
# ypy
check_sucessful "6.9长期MySQLCDM_linux_29.48_ypy" "50061b4e4f80fa802067209eb18a232f" "长期"
check_sucessful "6.9长期OracleCDM备份_linux_29.40_ypy" "46117564f229b9b7f407b21aa5d7fa1c" "长期"
check_sucessful "6.9长期分区_WIN_29.47_ypy" "d9f991a83017a2b4ad9161044f5fca8f" "长期"
#zry
check_sucessful "6.9长期定时文件29.49_zry" "b1b4c1d1b276265ae78914f350e29f96" "多通道"
check_sucessful "6.9长期定时文件29.49_zry" "b1b4c1d1b276265ae78914f350e29f96" "普通"
check_sucessful "6.9长期副本文件CDM备份29.42_zry" "55037758a2f200826bff0061d6dbdb91" "文件CDM"
check_sucessful "6.9长期副本文件CDM备份29.42_zry" "55037758a2f200826bff0061d6dbdb91" "218"
echo "开始发送邮件"
#python $ROOT_DIR/SendCheckJobReport.py