Linux发送监控指标到内部邮箱

本文发布时间: 2019-Mar-22
数据库的健康监控是个非常重要的工作,重要的指标\KPI监控结果会有专门的采集、监控、告警系统来做相关事情。而一些不是非常重要的或者还在设计和调试阶段的相关指标,我只是想发送到我自己邮箱,本文就针对在服务器上配置邮件发送监控数据的过程说明。服务器版本为RHEL 6.2:[pg@gtlions ~]# cat /etc/issueRed Hat Enterprise Linux Server release 6.2 (Santiago)Kernel \r on an \m停用相关服务器:[root@gtlions etc]# service sendmail stop[root@gtlions etc]# service postfix stop [root@gtlions etc]# service sendmail statussendmail 已停sm-client 已停[root@gtlions etc]# service postfix statusmaster 已停接下来的步骤比较重要,默认情况下服务器使用的SMTP并没办法发送邮件到企业组织内部邮箱,对此需要配置企业组织的邮箱信息:[root@gtlions etc]# tail /etc/mail.rc# For Linux and BSD, this should be set.set bsdcompat set from=[发送人邮箱地址]set smtp=[smtp服务器地址]set smtp-auth-user=[邮箱用户名]set smtp-auth-password=[邮箱密码]set smtp-auth=login手工测试发送邮件:[root@gtlions etc]# echo hello world |mail -s "test" [email protected][root@gtlions etc]# python dbcheck.py >dbcheck.txt;cat dbcheck.txt|mail -s dbcheck [email protected][root@gtlions etc]# python dbcheck.py >dbcheck.txt;mail -s dbcheck [email protected]<dhcheck.txt[root@gtlions etc]# python dbcheck.py|mail -s dbcheck [email protected]发送邮件shell脚本:[pg@gtlions]$ cat /home/pg/PycharmProjects/dbcheck.sh#!/bin/sh . /etc/profile. ~/.bash_profilepython /home/pg/PycharmProjects/dbcheck.py|mail -s "dbcheck `date +%F' '%T`" [email protected]设置定时调度任务,CRON调用shell脚本:[pg@gtlions]$ crontab -l*/1 * * * * sh /home/pg/PycharmProjects/dbcheck.sh 1>>/home/pg/check.log 2>&1-EOF-


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:10pm
栏目列表