1 Star 1 Fork 2

xrkmonitor/mysql 主从同步监控

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
add_crontab.sh 2.28 KB
一键复制 编辑 原始数据 按行查看 历史
木头8486 提交于 4年前 . init add source code
#!/bin/bash
#
# xrkmonitor license
#
# Copyright (c) 2020 by rockdeng
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# 字符云监控(xrkmonitor) 开源版 (c) 2021 by rockdeng
# 当前版本:v1.0
# 使用授权协议: apache license 2.0
#
# 开源版主页:http://open.xrkmonitor.com
# 云版本主页:http://xrkmonitor.com
#
#
# 云版本为开源版提供永久免费告警通道支持,告警通道支持短信、邮件、
# 微信等多种方式,欢迎使用
#
# 监控插件 mysql_slave_check 功能:
# mysql 主从同步监控,主从不同步时会记录错误日志并发送异常告警
#
# 插件开发时间:2021-11-19
# 插件开发人员:官方
# 插件开发人员云账号ID:1
#
# 脚本功能:
# 将插件脚本添加到 crontab 定时执行,默认每分钟执行一次
#
script_path=''
script_name=''
function in_script_path()
{
echo "/" > _tmp
fc=`expr substr "$0" 1 1`
echo "$fc" > _tmp_2
cmp _tmp _tmp_2 > /dev/null 2>&1
if [ $? -eq 0 ];then
cscript=$0
else
cscript=$(pwd)/$0
fi
rm -f _tmp _tmp_2
script_path=`dirname $cscript`
script_name=`basename $cscript`
cd "$script_path"
}
in_script_path
./cron_mysql_slave_check.sh > /dev/null 2>&1
crontab -l > _add_xrk_plugin_check_tmp
grep "${script_path}; \./cron_mysql_slave_check\.sh" _add_xrk_plugin_check_tmp > /dev/null 2>&1
if [ $? -eq 0 ]; then
rm _add_xrk_plugin_check_tmp
echo "already add"
exit 0
fi
curpwd=`pwd`
echo "*/1 * * * * cd ${script_path}; ./cron_mysql_slave_check.sh > /dev/null 2>&1" >> _add_xrk_plugin_check_tmp
crontab _add_xrk_plugin_check_tmp
if [ $? -eq 0 ]; then
rm _add_xrk_plugin_check_tmp
echo "add crontab ok"
exit 0
fi
echo "add to crontab failed"
rm _add_xrk_plugin_check_tmp
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/xrkmonitorcom/mysql_slave_check.git
git@gitee.com:xrkmonitorcom/mysql_slave_check.git
xrkmonitorcom
mysql_slave_check
mysql 主从同步监控
master

搜索帮助