Ping discovers the shell code of the switch alarm _linux shell

Source: Internet
Author: User
Tags time interval
Copy Code code 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
Todo
count=$ (ping-c $COUNT $myHost | grep ' loss ' | awk-f ', ' {print $} ' | awk-f '% ' ' {print '} ')
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 content for ping.sh to join the crontab to let it run in 10 minutes, where the email program for Mutt

The following are supplementary:

Linux and Solaris are not the same!
Copy Code code as follows:

#!/bin/sh
pingconf= '/opt/monitor/newip '
#File where the log would be stored
Logdir= '/opt/monitor/newlog '
#Define The interval time
Interval= ' 10 '
#Define the alarm process
########################################################
Proc_main ()
{
While read IPAddress
Todo
#ingore any hash signs
Case $IpAddress in
#*);;
*)
Ping-w $IpAddress-C 5 >errtmp$$
# ping $IpAddress-C >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 </dev/null
Play-v 50/opt/monitor/123.au
Fi
Esac
Done < $PingConf
}
##########################################################
# Execute the Proc_main function every the specified time INTERVAL
While ["1"-eq "1"]
Todo

# Execute the Proc_main function
Proc_main
# Suspend execution for INTERVAL seconds
Sleep $INTERVAL
Done
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.