发送统计邮件shell脚本
#!/bin/bash
#作者:Presley
#时间:2018.07.16
#监控阿里云aaa库的py_weixin_product_close_rating_info 和 py_weixin_product_open_rating_info两个表当天记录条数和前一天记录条数
source /etc/profile #加载系统环境变量
source ~/.bash_profile #加载用户环境变量
set -o nounset #引用未初始化变量时退出
user="aaa"
port="3306"
password="aaa"
database="aaa"
today="$(date +%Y-%m-%d)"
yesterday="$(date +%Y-%m-%d --date="-1 day")"
host="aaa"
send_mail_name=("lipingchang@pystandard.com" "weijiyao@pystandard.com" "songchuwen@pystandard.com" "linfumei@pystandard.com" "denglei@pystandard.com")
#表py_weixin_product_close_rating_info当天数据条数sql
sql_tableclose_today_count="select count(*) from py_weixin_product_close_rating_info where report_date='${today}';"
#表py_weixin_product_close_rating_info前一天数据条数sql
sql_tableclose_yesterday_count="select count(*) from py_weixin_product_close_rating_info where report_date='${yesterday}';"
#表py_weixin_product_open_rating_info当天数据条数统计sql
sql_tableopen_today_count="select count(*) from py_weixin_product_open_rating_info where report_date='${today}';"
#表py_weixin_product_open_rating_info前一天数据统计条数sql
sql_tableopen_yesterday_count="select count(*) from py_weixin_product_open_rating_info where report_date='${yesterday}';"
mysqlconn="/application/mysql/bin/mysql -u${user} -p${password} -h${host} -P${port} -D${database} -e"
#将当天和前一天的记录条数统计
num_close_today=$(${mysqlconn} "${sql_tableclose_today_count}" 2>/dev/null | sed '1d')
num_close_yesterday=$(${mysqlconn} "${sql_tableclose_yesterday_count}" 2>/dev/null | sed '1d')
#将当天和前一天的记录条数统计
num_open_today=$(${mysqlconn} "${sql_tableopen_today_count}" 2>/dev/null | sed '1d')
num_open_yesterday=$(${mysqlconn} "${sql_tableopen_yesterday_count}" 2>/dev/null | sed '1d')
function send_mail()
{
echo "1、封闭式表:
${today}日 统计记录条数为: ${num_close_today} 条;
${yesterday}日 统计记录条数为: ${num_close_yesterday} 条。
2、开放式表:
${today}日 统计记录条数为: ${num_open_today} 条;
${yesterday}日 统计记录条数为: ${num_open_yesterday} 条。" | mail -s "表记录统计结果" $1
}
#发送邮件
for name in ${send_mail_name[@]}
do
send_mail $name
done
发送统计邮件shell脚本的更多相关文章
- zabbix 4.2 发送警告邮件Python脚本
#!/usr/bin/env python#-*- coding: UTF-8 -*-import os,sysimport getoptimport smtplibfrom email.MIMETe ...
- 【python】脚本连续发送QQ邮件
今天习得用python写一个连续发送QQ邮件的脚本,经过测试,成功给国内外的服务器发送邮件,包括QQ邮箱.163邮箱.google邮箱,香港科技大学的邮箱和爱丁堡大学的邮箱.一下逐步解答相关技巧. 首 ...
- shell脚本安装部署反向代理 监控进程 计划任务
1.编写脚本自动部署反向代理.web.nfs: 要求: I.部署nginx反向代理三个web服务,调度算法使用加权轮询: 反向代理服务器脚本配置脚本 #!/bin/bash #安装eple和nginx ...
- zabbix邮件告警之 通过shell脚本发送告警
说明:本文讲如何通过shell脚本实现zabbix发送告警邮件,共有5步1.设置mailx账号:是配置mailx的发信账号2.zabbix服务器端编写邮件发送脚本:是增加zabbix的告警方式,增加通 ...
- [linux] shell脚本编程-统计日志文件中的设备号发通知邮件
1.日志文件列表 比如:/data1/logs/2019/08/15/ 10.1.1.1.log.gz 10.1.1.2.log.gz 2.统计日志中的某关键字shell脚本 zcat *.gz|gr ...
- Git学习-->如何通过Shell脚本实现 监控Gitlab备份整个过程并且通过邮件通知得到备份结果?
一.背景 Git学习–>如何通过Shell脚本自动定时将Gitlab备份文件复制到远程服务器? http://blog.csdn.net/ouyang_peng/article/details/ ...
- shell脚本编程学习笔记(三)编写邮件报警脚本
一.shell编写邮件报警脚本 1.POSTFIX邮件服务器准备 a.首先卸载服务器上自带的sendmail rpm -qa sendmail* //查看安装的sendmail rpm -e send ...
- shell脚本实现网站日志分析统计
如何用shell脚本分析与统计每天的访问日志,并发送到电子邮箱,以方便每天了解网站情况.今天脚本小编为大家介绍一款不错的shell脚本,可以实现如上功能. 本脚本统计了:1.总访问量2.总带宽3.独立 ...
- 利用shell脚本统计文件中出现次数最多的IP
比如有如下文件test.txt 1 134.102.173.43 2 134.102.173.43 3 134.102.171.42 4 134.102.170.9 要统计出现次数最多的IP可 ...
随机推荐
- MT【76】直线系
解答 :答案是3,4.
- Spoj 8372 Triple Sums
题意:给你n个数字,对于任意s,s满足\(s=u_i+u_j+u_k,i<j<k\),要求出所有的s和对应满足条件的i,j,k的方案数 Solution: 构造一个函数:\(A(x)=\s ...
- Java Socket/HttpURLConnection读取HTTP网页
以读取百度的http网页为例.如果知道了IP地址和端口,然后新建一个Socket,就直接去读百度的首页,根本没反应,原因是www.baidu.com是以http协议传输的,而现在要以Socket原始的 ...
- bzoj千题计划266:bzoj4872: [六省联考2017]分手是祝愿
http://www.lydsy.com/JudgeOnline/problem.php?id=4872 一种最优解是 从大到小灯有亮的就灭掉 最优解是唯一的,且关灯的顺序没有影响 最优解 对每个开关 ...
- 何凯文每日一句打卡||DAY14
- [整理]ASP.NET MVC 5
1.入门 1.1官方资料 http://www.asp.net/mvc/overview/getting-started/introduction/getting-started 疑问: startu ...
- MYSQL查询重复记录的方法
select * from hengtu_demandpush a where (a.did,a.mid) in (select did,mid from hengtu_demandpush grou ...
- JSBinding+Bridge.NET:Inspector拖变量支持
之前的文档说了,JSB的设计是不允许gameObject上挂逻辑脚本的.原因很简单,在Js工程中根本就不存在C#形式的逻辑脚本,如果在Cs工程中挂上了,到了Js工程这边,直接Missing. 实际在使 ...
- jsp前端验证(非常好用)
1.在jsp页面中引入<script type="text/javascript" src="${ctxStatic}/js/valid.js">& ...
- Zookeeper笔记之四字命令
Zookeeper支持一些命令用来获取服务的状态和相关信息,因为这些命令都是四个字母的,所以一般称为四字命令. 四字命令可以使用telnet或者nc向服务器提交,使用下面这个脚本可以当做是一个简易的客 ...