[Shell] Determine network conditions and add timestamps

Source: Internet
Author: User

A recent need to do a real-time statistical network situation and statistics of the error rate of the script, the following is a stackexchange on the plagiarism, although not fully satisfied, but only can output some information

#!/bin/Bashhost=$1if[-Z $host]; Then    Echo "Usage: ' basename $ ' [HOST]"Exit1fi while:; Doresult=`Ping-W1-C1$host |grep 'bytes from'`    if[$?-gt0]; Then        Echo-E"' date + '%y/%m/%d%h:%m:%s '-host $host is \033[0;31mdown\033[0m"    Else         Echo-E"' date + '%y/%m/%d%h:%m:%s '-host $host is \033[0;32mok\033[0m-' echo $result | cut-d ': '-F 2 '"        Sleep 1# AvoidPingRainfi Done

[Shell] Determine network conditions and add timestamps

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.