Mail alarm (postfix), mail alarm postfix

Source: Internet
Author: User

Mail alarm (postfix), mail alarm postfix

Postfix is the MTA software developed by Wietse Venema under the ibm gpl protocol. Postfix is an attempt by Wietse Venema to provide alternatives to the most widely used sendmail. In the Internet world, most emails are delivered through sendmail. About 1 million users use sendmail to deliver hundreds of millions of emails each day. This is really a surprising number. Postfix tries to be faster, easier to manage, and safer, while maintaining sufficient compatibility with sendmail.

System: CentOS release 6.5 (Final) x86_64

Since postfix is installed in the system after centos6, you only need to start it:
The configuration is as follows:

Service postfix start // start the chkconfig postfix on service // set the auto-start Mode

Install mailx:

Add the following content to the yum install-y mailx configuration file: vim/etc/mail. rc set from = xxx@xxx.com smtp = smtp.xxx.com // mail server set smtp-auth-user = xxx smtp-auth-password = xxx // user and password set smtp-auth = login

Test:

echo '123'|mail -s "123" xxxx@xx.com

The business needs to monitor whether the host is down and the service status. All I need to use ssh commands to monitor the service by configuring one-way ssh key-free logon.

Ssh batch distribution script:

#! /Bin/bashUser = rootpassWord = 123 port = 2266 function YumBuild () {echo "installing epel source yum repository. Please wait... "cd/etc/yum. repos. d/& \ [-d bak] | mkdir bak ['Find. /*. *-type f | wc-l '-gt 0] & find. /*. *-type f | xargs-I mv {} bak/wget-O/etc/yum. repos. d/epel. repo http://mirrors.aliyun.com/repo/epel-6.repo &>/dev/nullyum-y clean all &>/dev/nullyum makecache &>/dev/null} rpm-q sshpass &>/dev/null | yum- y insta Ll sshpass &>/dev/nullif [$? -Gt 0]; then YumBuild yum-y install sshpass &>/dev/null | (echo "sshpass build error! "& Exit) fi [-d ~ /. Ssh] | mkdir ~ /. Ssh; chmod 700 ~ /. Sshecho "creating key pair..." rm-rf ~ /. Ssh/id_dsa ~ /. Ssh/id_dsa.pubssh-keygen-t dsa-f ~ /. Ssh/id_dsa-P "" &>/dev/nullfor ip in 'cat/root/Pingip.txt 'do ping $ ip-c1 &>/dev/null if [$? -Gt 0]; then echo "$ ip cannot be pinged. Please check network" continue fi sshpass-p "$ passWord" ssh-copy-id-I ~ /. Ssh/id_dsa.pub "-o StrictHostKeyChecking = no-p2266 $ {User} @ $ ip" &>/dev/null echo "$ ip Key Distribution successful" done
Comparison between fping and ping

Fping is different from ping's date data.

1. They use the same ICMP protocol.

2. The detection mechanism is the same as the default ECHO, which is a latency.

3. fping can detect multiple ip addresses at the same time. ping can only manually output inaccessible ip segments.

4. The fping data packet size is 56 bytes, And the ping data packet byte is 48 (all ping data packets are 56 by default ).

5. The default ping interval of fping is 25 milliseconds, and the default ping interval is 1 second.

Email Alert script:

#! /Bin/shif ['which fping | wc-l'-eq 0]; then wget -- limit-rate 500 k http://www.fping.org/dist/fping-3.8.tar.gztar zxvf fping-3.8.tar.gz & cd fping-3.8. /configure & make installfirm-f result.txt cat/root/baojing/Pingip.txt | fping-u> result.txt // Pingip.txt indicates that the ip address of the monitored host-u is ping-failure only. machine while read linedo echo "$ line down" | mail-s "alarm" xxx@qq.comdone <result.txt for line in 'cat/root/baojing/ATSip. t Xt '// ATSip.txt for the service machine sub-IPdowget-SO/dev/null "http://www.baidu.com"-e "http_proxy = $ line" &>/dev/null // wget proxy access if [' echo $? '-Eq 0] & ['ssh-p2266 root @ $ line ps aux | grep/usr/local/tcacheserver/bin/traffic _ | grep-v grep | wc-l '- eq 3] then echo "">/dev/null else echo "$ line ATS is down" | mail-s "alarm" xxx@qq.comfidone

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.