Mail alert mechanism in Linux
The alarm mechanism in Linux is a key part of operation and maintenance management. We generally detect problems through monitoring, common monitoring software such as: Zabbix is now in use and ready to use. If we do not monitor the alarm through third-party software, we will need the mail sending function that comes with Linux.
The following alarm configuration for the work, small experience. To share with you the following:
1, check MAILX version information is greater than 12.*, otherwise need to update the installation
2. Add the following changes to the # vim/etc/mail.rc:
Set [email protected] Specify an external mailbox to send mail to
Set smtp=smtp.163.com server domain name format for sending mail: smtp.*
Set Smtp-auth-user=apple account to login to the mailbox (also sender name)
Set SMTP-AUTH-PASSWORD=888AAAAAAA password for the login mailbox (the password for the sender's mailbox)
Set Smtp-auth=login login mode
Send mail
# echo "3333" | Mail-s "6666" [email protected]
Command explanation:
3333: Indicates the content of the message being sent.
6666: Indicates the name of the message being sent.
[email protected] means sending it to that email.
===========================================================================================
Example: Execute the command periodically to send the result message to the specified mailbox
# Vim/root/aa.sql
Select User,password,host from Mysql.user;
# Vim Ning.sh
#!/bin/bash
#
/opt/mysql/bin/mysql-uroot-pning-d mysql-e "Source/root/aa.sql" >>/home/nhl/tmp/a.txt
/bin/mail-s "1" [email protected],[email protected]
# Vim/etc/crontab
0 * * * sh/root/ning.sh
This article is from the "struggling People" blog, please be sure to keep this source http://wodemeng.blog.51cto.com/1384120/1641988
Mail alert configuration in Linux