Step1. install Sendmail to send an email
# Yum-y install sendmail
#/Etc/init. d/sendmail start
# Chkconfig Sendmail on
Step2. install the email client
# Yum-y install mutt
2.1 Add the sender information as follows:
# Vim/etc/muttrc
Set charset = "UTF-8" # Set email Encoding
Set envelope_from = Yes
Set rfc2047_parameters = yes # solve the attachment garbled Problem
Set realname = "alarm" # sender alias
Set use_from = yes # specify whether to display aliases
Set [email protected] # sender address
Step3.ping host status script
# Vim ping. Sh
#! /Bin/bash # date = 'date + % F _ % H: % m' log =/root/ping-Monitor/ping. logip =/root/ping-Monitor/ip.txt clean = 'cat $ log | WC-l' for I in $ (cat $ IP ); do ping-C 2 $ I &>/dev/null if [$? -EQ 0]; then Echo "$ date $ I host Ping is success. ">>$ log else echo-e" Date: $ date \ nhost: $ I \ nproblem: Ping is failed, please check!!! "| Mutt-s" ping "[email protected] om fidone # If there are more than 30 log files, clear if [$ clean-ge 30]; then ECHO ""> $ log fi
Step 4. Add a Task Scheduler
# Crontab-e
*/1 */bin/bash/root/ping-Monitor/ping. Sh
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/43/CD/wKiom1Pc5tGgS_cyAADZ5gFH80w097.jpg "Title =" qq 40802212359.jpg "alt =" wkiom1pc5tggs_cyaadz5gfh80w097.jpg "/>
This article is from the "Penguin" blog, please be sure to keep this http://golab.blog.51cto.com/7876557/1534285