azkaban任务执行情况检查

azkaban任务执行情况检查

密码与ip处自行替换

#!/bin/sh
today=$(date +%Y%m%d)
dir=/opt/scripts
sql="SELECT
        CASE
WHEN STATUS = 50 THEN
        'success'
WHEN STATUS = 70 THEN
        'failed'
WHEN STATUS = 30 THEN
        'running'
END AS STATUS,

FROM_UNIXTIME(left(start_time, 10) ,'%Y-%m-%d %h:%m:%s') as start,
FROM_UNIXTIME(left(end_time, 10),'%Y-%m-%d %h:%m:%s') as end,

CONCAT((end_time - start_time)/60000, '分钟')  as time

FROM
        azkaban.execution_flows
ORDER BY
        start_time DESC
LIMIT 8;"
/usr/bin/mysql -uroot -p'xxxxxx' -e "$sql">$dir/result.txt
/usr/bin/paste $dir/scheduling.txt $dir/result.txt 1>$dir/azkaban${today}.txt
/bin/sh $dir/push_azkaban.sh

-----------------------------------------------

#!/bin/sh
today=$(date +%Y%m%d)
expect <<!
spawn scp  /opt/scripts/azkaban${today}.txt root@192.168.0.1:/opt/ubas_rcmd_check/
expect {
        "(yes/no)?"
        {
                send "yes\n"
                expect "*assword:" {send "xxxxxx\n"}
        }
        "*assword:"
        {
                send "xxxxxx\n"
        }
}
expect "100%"
expect eof

你可能感兴趣的:(Shell)