检查ftp备份数据完整性及短信告警的shell脚本
对远程备份到ftp服务器的数据完整性及是否ftp到该服务器进行了检查,如果没有及时备份到该ftp服务器则脚本会触发短信告警功能模块实现短信的告警,最后由于ftp服务器的空间有限,笔者在征求相关人员已经后制定了90天之前的数据进行删除的策略并在脚本中也实现了该功能。
现将该脚本分享出来,供大家学习参考。
#!/usr/bin/ksh
#---------------------------------------------------------
# scriptname:
# mon the data backup
# version:
# 1.2
# description:
# - if you have "/opt/mon/backup/my.lock",the monitor is unavailability ;
# - if find service error ,send message to admin.
# method:
# author:
# create by fengzhanhai
# notes:
# - the return variant is correct equal 0,error equal 1.
#---------------------------------------------------------
#script conf---------------------------------------------
Mon_Path="/backup/autobk/mon"
Mon_log="$Mon_Path/backup.log"
SMS_Server="your sms ip or fetion robot"
SMS_Send="$Mon_Path/sendsms"
Admin_Mobile="$Mon_Path/youmobilelist"
SMS_From=`hostname`
SMS_Header="Your-Mysql--DataBackup-"
Service_IP="your ftp server"
#check the lock file------------------------------------
getLock()
{
if [ -f "$Mon_Path/$Service_Name.lock" ];then
return 1
else
return 0
fi
}
#writer the message to log--------------------------
logwriter()
{
if [ ! -d `dirname $Mon_log` ]; then
mkdir -p `dirname $Mon_log`
fi
echo `date "+%Y-%m-%d %H:%M:%S"` : $1 >> $Mon_log
}
#send error sms to admin---------------------
sendSmsToAdmin()
{
CurTime=`date "+%Y-%m-%d %H:%M:%S"`
if [ $# -eq 1 ]; then
if [ ! -z "$1" ];then
tmpTime=`date "+%Y%m%d%H%M%S"`
for mobile in `cat $Admin_Mobile`
do
$SMS_Send -h $SMS_Server $mobile "$SMS_Header$1 not update-$tmpTime-$SMS_From"
done
fi
else
logwriter "call sendSmsToAdmin argus error"
fi
}
#check the lock file------------------------------------
getlastfile()
{
find $1 -name "$2`date "+%Y%m%d"`*.$3"|grep $2
if [ $? = 0 ];then
return 0
else
return 1
fi
}
# main ---------------
#检查锁文件
logwriter "backup check begin"
getLock
if [ $? = 0 ];then
#检查当日文件是否存在
getlastfile /eip_backup/autobk/yourdb/mysql yourdata tgz
if [ $? != 0 ];then
logwriter "yourdb not update!"
#发送告警短信
sendSmsToAdmin "yourapp"
fi
logwriter "yourapp check over."
#清理90天前的备份数据
find /eip_backup/autobk/yourdb/mysql -name "yourdb*.tgz" -ctime +90 -print -exec rm {} \;
logwriter "delete yourdb file over."
logwriter "backup check over"
检查ftp备份数据完整性及短信告警的shell脚本的更多相关文章
- zabbix 利用python脚本实现短信告警
一.编写脚本 cd /usr/local/zabbix-4.0.3/share/zabbix/alertscripts vi zabbix_sms.py 内容如下: #!/usr/bin/python ...
- zabbix系列之十——添加短信告警
zabbix添加短信告警 1.查看zabbix-server脚本存放路径: [root@GYQ-Prod-Zabbix ~]# grep AlertScriptsPath /etc/zabbix/za ...
- zabbix配置短信告警
zabbix版本:3.0.7 短信服务商:云片网 首先在云片网添加相应签名和模板 参照格式 签名:xxx告警 模板: [xxx告警]故障:#status# 服务器:#host# 发生:#trigger ...
- zabbix3调用接口发送短信告警
一.需求 之前使用的邮件告警,由于经常会忽略邮件,所以有时候告警查看的并不及时,所以增加短信告警的,以便及时处理. 二.zabbix-server端的配置 # 需要在zabbix-server端打开A ...
- Android备份和添加短信
手机发送成功的,没有成功的,接受的短信都存放在手机自带的数据库中. 现在想要备份一下这个短信,需要访问这个数据库,然后查询所有的短信.就需要内容提供者(短信). 首先要找到内容提供者的uri.
- prometheus grafana graylog 钉钉告警 短信告警 电话告警系统 PrometheusAlert
PrometheusAlert 简介 PrometheusAlert是开源的运维告警中心消息转发系统,支持主流的监控系统Prometheus,日志系统Graylog和数据可视化系统Grafana发出的 ...
- k8s全方位监控 -prometheus实现短信告警接口编写(python)
1.prometheus短信告警接口实现(python)源码如下: import subprocess from flask import Flask from flask import reques ...
- android101 获取、备份、插入短信
package com.itheima.getsms; import java.io.File; import java.io.FileNotFoundException; import java.i ...
- zabbix4.0短信告警配置
#!/usr/bin/env python3 import requests import sys #http://utf8.api.smschinese.cn/?Uid=USERNAME&K ...
随机推荐
- Java获取一个路径下指定后缀名的所有文件
方法一: http://blog.csdn.net/zjx102938/article/details/8114114 import java.io.File; import java.util.Ar ...
- C++ Virtual详解
转自:http://www.cnblogs.com/xd502djj/archive/2010/09/22/1832912.html Virtual是C++ OO机制中很重要的一个关键字.只要是学过C ...
- 结构体数组(C++)
1.定义结构体数组 和定义结构体变量类似,定义结构体数组时只需声明其为数组即可.如: struct Student{ int num; char name[20]; char sex[5]; int ...
- 数据绑定(八)使用Binding的RelativeSource
当一个Binding有明白的数据来源时能够通过为Source或ElementName赋值的办法让Binding与之关联,有的时候因为不能确定Source的对象叫什么名字,但知道它与作为Binding目 ...
- struts2 struts.xml配置文件详解
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN&quo ...
- Android(java)学习笔记211:采用httpclient提交数据(qq登录案例)
1.Apache -Httpclient HttpClient 是 Apache Jakarta Common 下的子项目,可以用来提供高效的.最新的.功能丰富的支持 HTTP 协议的客户端编程工具包 ...
- sizeof strlen strncpy用法总结 结构体实际所占内存大小 以及memset用法
sizeof测类型(数组名除外) strlen测实际长度 strncpy返回指针类型 #include <stdio.h> #include <stdlib.h> #inclu ...
- Form开发中组件控制的几个常用方法
转自:http://oracleseeker.com/2009/09/01/graphical_component_control_in_oracle_ebs_form/ 在Oracle EBS 的F ...
- oracle EBS 基于Host并发程序的开发(转)
参考此编文章 http://www.doc88.com/p-0972680953307.html http://www.cnblogs.com/benio/archive/2011/06/10/207 ...
- Linux C —— 多线程
为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/ShiJiaqi. http://www.cnblogs.com/shijiaqi1066/p/5769417. ...