airflow script

airflow-1脚本:
*/2 * * * * /bin/sh /hongfeng/script/rsynce_airflow_log.sh >/dev/null 2>&1
*/4 * * * * /bin/sh /hongfeng/script/monitor_scheduler.sh >/dev/null 2>&1

1/ log的rsync_airflow_log.sh
rsync -azuq -e ssh [email protected]:/root/airflow/logs/ /root/airflow/logs/ --exclude 'scheduler' --exclude 'scheduler_failover' --exclude 'dag_processor_manager'
rsync -azuq -e ssh [email protected]:/root/airflow/logs/ /root/airflow/logs/ --exclude 'scheduler' --exclude 'scheduler_failover' --exclude 'dag_processor_manager'
rsync -azuq -e ssh [email protected]:/root/airflow/logs/ /root/airflow/logs/ --exclude 'scheduler' --exclude 'scheduler_failover' --exclude 'dag_processor_manager'

2/ monitor_scheduler.sh
#! /bin/sh

date=$(date +%Y-%m-%d-%H:%M)

file_path=/root/airflow/scheduler.log
check_time=150
file_old_stat="`stat ${file_path}|grep Size`"
sleep ${check_time}
file_new_stat="`stat ${file_path}|grep Size`"
if [[ `echo ${file_old_stat}` == `echo ${file_new_stat}` ]]; then
. /data/venv/bin/activate && supervisorctl restart airflow_scheduler && deactivate
echo "#${date},scheduler service restarted" >>/tmp/test/scheduler_hung.log
fi

3/ status_check.sh
ansible airflow -m shell -a '. /data/venv/bin/activate && supervisorctl status'

. 4 / deploy_git_airflow.sh
ansible Airflow the shell -a -m 'CD / the root / Airflow / DAGs && Git pull'
. 5 / enterprise micro channel alarm (G: \ Documents \ Development \ Python)
. * / 2 * * * * (/ Data / venv / bin / activate && python /root/airflow/airflow_health_monitor.py && deactivate) >> /root/airflow/airflow_health.log 2> & 1 &

Guess you like

Origin www.cnblogs.com/hongfeng2019/p/12191966.html