In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to use Shell script to monitor server online status and email alarm". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to use Shell scripts to monitor server online status and email alarm"!
For the server, the online rate is very important, problems can be solved in time, but the system administrator can not always stay next to the computer, through the script monitoring website problems timely notify the administrator through mail, if it is 139mailbox can also be free SMS notification.
Note: sending mail directly through the system is easy to be intercepted. You can use mail to connect to a third party smtp to send mail.
Shell script implementation code:
The code is as follows:
#! / bin/bash
# set-x
While true
Do
List= (www.yisu.com s.jb51.net)
Mail=jmj@jb51.net
Date=$ (date-d "today" + "% Y-%m-%d-%H:%M:%S")
ITunes 0
Id=$ {# list [*]}
While [$I-lt $id]
Do
If ping-C1 ${list [$I]} > / dev/null
Then
Echo $date: server ${list [$I]} can ping.
Else
If curl-m 10 ${list [$I]} > / dev/null
Then
Echo $date: server ${list [$I]} ping is not available and can open a web page.
Else
Echo "Hello, according to the system monitoring server ${list [$I]} can not be accessed and ping is not available, please deal with it in time! time of failure: $date" | mail-s "server ${list [$I]} cannot be connected! time of failure: $date" $mail
Until
Date=$ (date-d "today" + "% Y-%m-%d-%H:%M:%S")
Ping-C1 ${list [$I]} > / dev/null & & echo "Congratulations! server ${list [$I]} has returned to normal, recovery time: $date" | mail-s "server ${list [$I]} has returned to normal! recovery time: $date" $mail
Do
Sleep 5
Done
Fi
Fi
Let iTunes +
Done
Sleep 60
Done
At this point, I believe you have a deeper understanding of "how to use Shell scripts to monitor server online status and email alarm". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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: 0
*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.