提交代码
This commit is contained in:
parent
234ba9726d
commit
8bf3cb16d7
|
@ -1,2 +1,22 @@
|
|||
用途:
|
||||
检查指定的代理策略的成功率,并将结果发邮件
|
||||
|
||||
使用方法:
|
||||
1. 修改check_job_sucessful.sh脚本
|
||||
1.1 数据库的连接信息
|
||||
1.2 添加要检查的代理和策略
|
||||
check_sucessful "代理机器的名称" "主机ID" "策略名"
|
||||
例如:
|
||||
check_sucessful "6.9长期mh_MySQL定时备份_13.167" "811da1a9258bb690d58aaef5aa958027" "长期任务-mysql物理多通道"
|
||||
|
||||
2. 修改SendCheckJobReport.py,指定收发件人的邮件地址
|
||||
|
||||
3. 将check_job_sucessful.sh和SendCheckJobReport.py上传到服务器
|
||||
|
||||
4. 试运行一下脚本,看是否能正常运行
|
||||
bash check_job_sucessful.sh
|
||||
--会在当前目录中产生一个 check_report.txt 里面保存着所有的检测信息,并会给步骤2中指定的邮箱地址发邮件
|
||||
|
||||
5. 做定时任务,例如每周一和周五的12点运行一次
|
||||
0 12 * * 1,5 bash /home/mh/checkSucess/check_job_sucessful.sh
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
select 1-(tb1.num/tb2.num2) from (select num from (select operdesc,sum(n2)as num from ( select operdesc,count(*) as n2 from tbl_jobhistory where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202311 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202309 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202307 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202304 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202301 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202306 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202303 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202310 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202308 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202305 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202302 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc) a group by a.operdesc) t1 where operdesc like '%失败%') as tb1 right JOIN (select sum(num) as num2 from (select operdesc,sum(n2) as num from ( select operdesc,count(*) as n2 from tbl_jobhistory where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202311 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202309 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202307 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202304 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202301 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202306 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202303 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202310 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202308 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202305 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc UNION ALL select operdesc,count(*) as n2 from tbl_jobhistory_202302 where policyname='长期任务-mysql物理多通道' and compid='811da1a9258bb690d58aaef5aa958027' group by operdesc) b group by b.operdesc) t2) as tb2 on 1=1;
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
|
||||
BLACKCUBE_ROOT=/
|
||||
BLACKCUBE_CONF=/conf
|
||||
|
||||
BASE=`dirname $(pwd)/$0`
|
||||
INCDIR="$BASE/include"
|
||||
RESOURCE="$BASE/resource"
|
||||
|
||||
. $INCDIR/*.sh
|
||||
exec 11>&1 12>&2
|
||||
exec &>>$RUN_LOG
|
||||
##############################
|
||||
|
||||
MYSQLPWD=`grep jdbc.password /opt/bksoft/ubackup/conf/jdbc.properties | cut -c 15-`
|
||||
MYSQLUSER=`grep jdbc.username /opt/bksoft/ubackup/conf/jdbc.properties | cut -c 15-`
|
||||
|
||||
SQL_TABLES="SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='unary' AND TABLE_NAME regexp 'tbl_jobhistory(_2)|^tbl_jobhistory$'"
|
||||
RESULT_TABLES=`mysql -u$MYSQLUSER -p$MYSQLPWD -e "$SQL_TABLES" 2>/dev/null|awk 'NR>1'`
|
||||
for i in $RESULT_TABLES
|
||||
do
|
||||
INFOTABLE="tbl_jobhistory_info"${i:14}
|
||||
TASKIDS=`mysql -u$MYSQLUSER -p$MYSQLPWD -e "select taskid from unary.$i where level=3" 2>/dev/null|awk 'NR>1'`
|
||||
for j in $TASKIDS
|
||||
do
|
||||
INFOSNS=`mysql -u$MYSQLUSER -p$MYSQLPWD -e "select info_sn from unary.$INFOTABLE where taskid='$j'" 2>/dev/null|awk 'NR>1'`
|
||||
mysql -u$MYSQLUSER -p$MYSQLPWD -e "delete from unary.$INFOTABLE where taskid='$j'" 2>/dev/null|awk 'NR>1'
|
||||
mysql -u$MYSQLUSER -p$MYSQLPWD -e "delete from unary.$i where taskid='$j'" 2>/dev/null|awk 'NR>1'
|
||||
done
|
||||
done
|
||||
mysql -u$MYSQLUSER -p$MYSQLPWD -e "delete from unary.tbl_report_alarm where level=3" 2>/dev/null|awk 'NR>1'
|
||||
|
||||
##############################
|
||||
exec 1>&11 11>&-
|
||||
exec 2>&12 12>&-
|
||||
echo success
|
||||
exit 0
|
Loading…
Reference in New Issue