In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to achieve the shell of ping discovery and swap alarm", which is easy to understand and clear. I hope it can help you solve your doubts. Here, let me lead you to study and learn "how to realize the shell of ping discovery and swap alarm".
The code is as follows:
#! / bin/bash
PING= `which ping`
DATE= `date +% Y% m% d% H% M`
TAIL= `which tail`
LOG=./ping$DATE.log
HOSTS= "selboo.com.cn 221.130.191.97"
COUNT=200
For myHost in $HOSTS
Do
Count=$ (ping-c $COUNT $myHost | grep 'loss' | awk-Flowers' {print $3}'| awk-F "%"'{print $1}')
If [$count-ge 10]; then
/ bin/echo selboo | mutt-s "$myHost pingispacketloss > 10% $DATE" root@selboo.com.cn
Fi
Done
Exit 0
Copy the above to add ping.sh to crontab and let it run once every 10 minutes, and the email program is mutt.
The following is a supplement:
Linux's and solaris's are not the same!
The code is as follows:
#! / bin/sh
PingConf='/opt/monitor/newIp'
# File where the log will be stored
LogDir='/opt/monitor/newLog'
# Define the interval time
INTERVAL='10'
# Define the alarm process
# # #
Proc_main ()
{
While read IpAddress
Do
# ingore any hash signs
Case $IpAddress in
# *)
*)
Ping-w 20$ IpAddress-c 5 > errtmp$$
# ping $IpAddress-c 10 > errtmp$$
If [$? = 0]; then
Rm errtmp$$
Else
Rm errtmp$$
ErrTime= `date +% Y/%m/%d/%H:%M:% s`
# echo "$ErrTime": "" $IpAddress "" cann't be connected "> > $LogDir
Echo "$ErrTime": "" $IpAddress "" cann't be connected
"> > $LogDir
Sleep 1
Cp / opt/monitor/newLog / opt/OV/www/htdocs/PingLog/new.html
Sleep 1
# mail-s "$IpAddress" Cantreach-c my email
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.