In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to monitor the survival status of the server under linux", the explanation content in the article is simple and clear, easy to learn and understand, please follow the ideas of Xiaobian slowly, together to study and learn "how to monitor the survival status of the server under linux"!
Simple Mail Transfer Protocol (SMTP) is the de facto standard for transferring email over the Internet, SMTP is a relatively simple text-based protocol. One or more recipients of a message are specified above, and the message text is transmitted. SMTP uses TCP port 25. I. Configuration environment [root@ser ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core) #View system environment [root@ser ~]# systemctl stop firewall d #Stop firewall firewall service [root@ser ~]# systemctl disable firewall d #Disable firewall service startup auto-start function [root@ser ~]#firewall cmd--statenot running#View firewall running status, confirm firewall is closed. vi /etc/selinux/config#SELINUX=enforcing#SELINUXTYPE=targetedSELINUX=disabled:wq! #Close selinux, save exit [root@ser ~]# setenforce 0#Temporarily close selinux, restart failure [root@ser ~]# getenforceDisabled#Check selinux status, confirm that it has been closed Second, download software and install perl components related to dependencies [root@ser ~]# yum -y install perl-Net-SSLeay perl-IO-Socket-SSL#Install dependencies [root@ser ~]# wget http: //caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz #Download installation package [root@ser ~]# tar -zxf sendEmail-v1.560.tar.gz#Unzip installation package [root@ser ~]# cd sendEmail-v1.56/[root@ser sendEmail-v1.56]# lsCHANGELOG README README-BR.txt sendEmail sendEmail.pl TODO#Enter directory sendEmail-v1.56/[root@ser sendEmail-v1.56]# cp sendEmail /usr/local/bin/sendEmail[root@ser sendEmail-v1.56]# chown root:root /usr/local/bin/sendEmail[root@ser sendEmail-v1.56]# ll /local/Email/bin/sendusr-rwxr-xr-x 1 root 80183 Jul 31 15: Email 14 /usr/local/bin/sendEmail#Copy sendEmail to the execution directory/usr/local/bin/and grant root user privileges and group privileges. Create script and grant script execution privileges [root@ser ~]# cd[root@ser ~]# pwd/root#return/root[root@ser ~]# vim mail.sh#!/ bin/bashto=$1subject=$2body=$3/usr/local/bin/sendEmail -o tls=auto -f ***@qq.com -t "$to" -s smtp.qq.com-u "$subject" -o message-content-type=html -o message-charset=utf8 -xu ****@qq.com -xp ***** -m "$body"#In the script, -f *****@qq.com represents the sender's mailbox, -s smtp.qq.com represents the smtp server of the email #Tencent qq mailbox is used in this article,# -xu ********@ qq. com indicates the user name of the sender's mailbox, -xp ****** indicates the mail protocol authorization key [root@ser ~]# chmod +x mail.sh#Execute script test to send mail [root @ ser ~]# ./ mail.sh chao.il@qq.com test 123 test From: ** when Time: Thursday, 12 September 2019 3: 50pm (UTC+0:00 London, Dublin, Lisbon time) To: ** 123 #Received test emails 4. Common problems and handling: 1. When testing emails, errors such as invalid SSL_version ****/IO/Socket/SSL.pm line 444 appear. The reason is that the SSL version in sendEmail software is incompatible with perl. By modifying line 1906 of/usr/local/bin/sendEmail file, SSL version is not specified. The original file is if (! IO::Socket::SSL->start_SSL($SERVER, SSL_version=> 'SSLv3 TLSv1')) { Changed to if (! IO::Socket::SSL->start_SSL($SERVER)) {2. When an error such as ERROR => SMTP-AUTH: Authentication to smtp.qq.com:25 failed occurs during email testing, the reason is that the mailbox requires a third-party client to send emails. You must log in with an authorization code. When using account password authentication, the authorization code needs to be logged in to the mailbox settings to find it. Some mail servers need to start POP3 service first. V. Write shell script to monitor server online status [root@ser ~]# vim CheckNetwork.sh #!/ bin/bashtt1=172.20.220.20 #Definition server 1 tt2 =172.20.11.1 #define server 2 while true#while(true) is an infinite loop statement #we must add a judgment inside his loop statement, when he meets what requirements will jump out do ping -c 5 $tt1 >/dev/null #ping command to detect whether the remote machine is alive if [ $? -eq 0 ];then #$in shell script? It refers to the success or failure of the last command execution. 0 if successful and 1 if unsuccessful. #statement if [ $? -eq 0 ] is to judge if the previous command execution of the statement fails to execute the statement in if, otherwise execute the content in else. echo `date +%F-%T` " $tt1 is yes" >> ip_yes.txt #append current time and server IP is yes to ip_yes.txt, where ip_yes.txt is used as the correct log file else echo `date +%F-%T` " $tt1 is Error" >> ip_no.txt #Append the current time and server IP is Error to ip_no.txt, where ip_no.txt is used as the error log file The requested URL/root/mail.sh ******@qq.com was not found on this server. The requested URL/root/mail.sh ******@qq.com was not found on this server. /root/mail.sh ******@sunplusapp.com Server Error `date +%F-%T`---"Ep$tt1 is Error" /root/mail.sh ******@sunplusapp.com Server Error `date +%F-%T`---"Ep$tt1 is Error" #Send mail to the above email address sleep 5 #Sleep for 5 seconds fi ping -c 5 $tt2 >/dev/null if [ $? -eq 0 ];then echo `date +%F-%T` " $tt2 is yes" >> ip_yes.txt else echo `date +%F-%T` " $tt2 is Error" >> ip_no.txt The requested URL/root/mail.sh ******@qq.com was not found on this server. The requested URL/root/mail.sh ******@qq.com was not found on this server. The requested URL/root/mail.sh ******@sunplusapp.com was not found on this server. The requested URL/root/mail.sh ******@sunplusapp.com was not found on this server. sleep 5fi kill -9 `ps aux | grep CheckNetwork | grep -v grep | awk '{print $2}'` #After executing a script, kill the script process to prevent repeated execution of the script. done [root@ser ~]# crontab -l*/15 8-18 * * * /usr/bin/bash /root/CheckNetwork.sh #Set up timed tasks to execute CheckNetwork.sh every 15 minutes from 8:00 to 18:00. (Please set the time according to the demand) The following is the alarm mail message server error From: ** when Time: Thursday, 12 September 2019 4: 45pm (UTC+0:00 London, Dublin, Lisbon time) To: ** 2019-09-12-12:45:19---Yihui 172.20.11.1 is Error Thank you for reading, the above is the content of "how to monitor the survival status of the server under linux", after learning this article, I believe everyone has a deeper understanding of how to monitor the survival status of the server under linux. The specific use situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 210
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.