文章预览
监控 MySQL 主从同步状态是否异常脚本 # !/bin/bash HOST=localhost USER=root PASSWD=123.com IO_SQL_STATUS=$(mysql -h$HOST -u$USER -p$PASSWD -e 'show slave status\G' 2>/dev/null |awk '/Slave_.*_Running:/{print $1$2}') for i in $IO_SQL_STATUS; do THREAD_STATUS_NAME=${i%:*} THREAD_STATUS=${i#*:} if [ "$THREAD_STATUS" != "Yes" ]; then echo "Error: MySQL Master-Slave $THREAD_STATUS_NAME status is $THREAD_STATUS!" |mail -s "Master-Slave Staus" [url=mailto:xxx@163.com]xxx@163.com[/url] fi done 目录文件变化监控和实时文件同步 # !/bin/bash MON_DIR=/opt inotifywait -mqr --format %f -e create $MON_DIR |\ while read files; do rsync -avz /opt /tmp/opt # echo " $(date +'%F %T') create $files " | mail -s "dir monitor" [url=mailto:xxx@163.com]xxx@163.com[/url] done 批量创建 100 用户并设置密码脚本 # !/bin/bash DATE=$@ USER_FILE=user.txt for U
………………………………