yum install msmtp -y
1 step
yum install msmtp -y
2 step
# cat ~/.msmtprc
# Set default values for all following accounts.
defaults
auth on
tls on
tls_starttls on
#tls_trust_file /etc/ssl/certs/ca-certificates.crt
tls_trust_file /etc/ssl/certs/ca-bundle.crt
# The account you will use
#account qqmail
account default
host smtp.exmail.qq.com
port 587
from f@f.com
user f@f.com
password 123456
logfile ~/.msmtp.log
3 step
[root@vm172-31-0-25 ~]# cat /usr/local/src/monitor_mongod.sh
#!/bin/bash
# 获取系统 IP 地址
ip_address=$(hostname -I | awk '{print $1}')
# 目标邮件地址(多个地址用逗号分隔)
email="a@a.com,b@b.com"
# 发送邮件的标题
subject="Mongod Process Alert on ip_address"
# 创建一个临时文件用于存放邮件内容
temp_mail=$(mktemp)
# 检查 mongod 进程是否存在
if ! pgrep -x "mongos" > /dev/null
#if ! pgrep -x "aaaa" > /dev/null
then
# 如果进程不存在,准备邮件内容
{
echo "From: monitor@a.com"
echo "To: subject"
echo ""
echo "temp_mail"
# 发送邮件
while IFS=',' read -ra ADDR; do
for i in "i" < "email"
fi
# 删除临时文件
rm -f "$temp_mail"
4 step
# crontab -l
*/10 * * * * /usr/local/src/monitor_mongod.sh 1>/dev/null 2>/dev/null
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2023-06-05 centos7部署minio