tar zxvf heirloom-mailx_12.5.orig.tar.gz
cd heirloom-mailx-12.5/
make && make install UCBINSTALL=/usr/bin/install
cp /etc/nail.rc /etc/nail.rc.bak
vim /etc/nail.rc
set from=xxx@126.com 发送邮箱
set smtp=smtp.126.com 发送邮箱smtp地址
set smtp-auth-user=xxx@126.com 接收邮箱
set smtp-auth-password=xxx 邮箱密码
set smtp-auth=login
echo 123 | mailx -v -s "zabbix test mail" xxx@126.com
com
-bash: echp: command not found
Resolving host smtp.126.com . . . done.
Connecting to 220.181.15.111:25 . . . connected.
220 126.com Anti-spam GT for Coremail System (126com[20140526])
>>> EHLO vm172-18-0-18.ksc.com
250-mail
250-PIPELINING
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-coremail 1Uxr2xKj7kG0xkI17xGrU7I0s8FY2U3Uj8Cz28x1UUUUU7Ic2I0Y2UFhQBZHUCa0xDrUUUUj
250-STARTTLS
250 8BITMIME
>>> AUTH LOGIN
334 dXNlcm5hbWU6
>>> d3loMTk4NzI1QDEyNi5jb20=
334 UGFzc3dvcmQ6
>>> V1lIMTk4NzI1IUAj
235 Authentication successful
>>> MAIL FROM:<wyh198725@126.com>
250 Mail OK
>>> RCPT TO:<wyh198725@126.com>
250 Mail OK
>>> DATA
354 End data with <CR><LF>.<CR><LF>
>>> .
250 Mail OK queued as smtp1,C8mowABnDOoAivZZ4IC0AQ--.8734S2 1509329409
>>> QUIT
221 Bye
touch /root/health_crm.sh
touch /tmp/health_crm/health_crm.log
vim /root/health_crm.sh
#!/bin/bash
set i=10
while true
do
let "i=i+10"
response=`curl --silent http://xx.com/ -i|egrep "HTTP/1.1" |awk -F ' ' '{print $2}'`
code=`curl --silent http://xxx.com/ >> /tmp/health_tomcat/health_crm.log`
if [ $response != 200 ]
then
echo "$response" |mail -s "your website is not ok now!" xx@xx.com
else
curl --silent http://xx.com/ >> /tmp/health_crm/health_crm.log
sleep 300
fi
done
#done
crontab -e
5 * * * * root /bin/sh /root/health_crm.sh
service crond restart && service ntpd restart
来源:oschina
链接:https://my.oschina.net/u/4343506/blog/4300607