Script implementation Quick parse from Client server HTTP request

Source: Internet
Author: User

This article is reproduced from https://www.imooc.com/article/14107

first I would like to introduce you to share the usefulness of this script:

When the customer told us that a page http://www.xxx.com a problem, as a PE, our first step is how to do?

In my experience, I will first open my forehead browser, enter http://www.xxx.com, to see the return of the page and the response status of the server. There are several scenarios in which responses can be encountered:

Situation one, if the page appears "Page Cannot connect"

Then I do, ping www.xxx.com to see if there is IP parsing OK, if there is the expected IP return, then another use of this command is to view, the service side to my local side, through the ICMP protocol delay, if rt>300ms, or there is "

Request Timeout, then I'm sure it's my local network to the remote server, there was an exception.

Case two, if the page can open normally, but appears as: Bad gateway or connecttion timeout

Then I need to go to correspondence analysis, status code hint problem

Situation three, if the page can open normally, but the data load is very slow

So this time, I need to analyze the network delay, or whether the backend processing speed is slow.

To deal with this problem, in fact, under Linux we only need to use ping and curl two commands.

Jping's role is to help us quickly locate analysis problems by providing fast and intuitive information about the process in the request URL, including ICMP latency, DNS request speed, TCP handshake time, and so on.

Next, I will share the following jping implementation:

##########################################################################File Name:Jping.sh#Program function:#Author:jeson#Mail:[email protected]#Created Time: 210/25 12:12:42 2016If [$#= = 1];thenif [["$"=~ ^http.*]];then domain_name=$ (Echo$1|awk-F '/' {print$} ') Ping-c 3${domain_name}If [$? = = 0];then response_res= ($ (Curl-o/dev/null-w%{http_code} '%{time_namelookup} '%{time_connect} '%{time_pretransfer} ' '%{time_starttransfer} '%{time_total} '%{size_download} '%{speed_download}${domain_name})) echo"Status code:"${response_res[0]} Echo"DNS resolution TIME:"${response_res[1]}"(s)"Echo"TCP Handshake: $ (echo"${response_res[2]}-${response_res[1]}"|BC) (s)"Echo"Send the first GET request time:"${response_res[3]}"(s)"Echo"The first packet time to receive the server:"${response_res[4]}"(s)"Echo"Time to close the connection from start to server:"${response_res[5]}"(s)"Echo"HTTP request Content Size:"${response_res[6]} " (B) "  "http package Request Speed:  " (b/s)  fi else Domain_name=$1 ping-c 3 ${domain_name} Fielse echo " error:input a URL or domain_name or IP address! "  Exitfi             

 

Script Annotations:

By pinging 1, DNS parsing results of domain names, and RT time of IMCP
Get response status codes for each HTTP request via Curl, DNS resolution time, TCP handshake time, and more

Third, jping implementation mode

I only need to execute jping + URL address via terminal or jping + IP or domain address

1. The way of parameter URL address

$ jping http://www.imoocc.com

PING (115.238.23.253): Data bytes

Bytes from 115.238.23.253:icmp_seq=0 ttl=40 time=37.347 ms

Bytes from 115.238.23.253:icmp_seq=1 ttl=40 time=37.749 ms

Bytes from 115.238.23.253:icmp_seq=2 ttl=40 time=37.788 ms

---www.taobao.com.danuoyi.tbcache.com ping statistics---

3 Packets transmitted, 3 packets received, 0.0% packet loss

Round-trip Min/avg/max/stddev = 37.347/37.628/37.788/0.199 ms

% total% Received% xferd Average speed Time Time current

Dload Upload Total spent

258 258 0 0 444 0--:--:----:--:----:--:--444

Status Code: 302

DNS resolution time: 0.523 (s)

TCP handshake:. 029 (s)

Send first GET request time: 0.552 (s)

First packet received to server time: 0.581 (s)

Time to close the connection from start to server: 0.581 (s)

HTTP request Content Size: 258 (B)

HTTP packet Request speed: 444.000 (b/s)

2. How to parameter IP domain name

Jesondemacbook-air:myjob jeson$ jping www.imoocc.com

PING (115.238.23.253): Data bytes

Bytes from 115.238.23.253:icmp_seq=0 ttl=40 time=38.801 ms

Bytes from 115.238.23.253:icmp_seq=1 ttl=40 time=37.789 ms

Bytes from 115.238.23.253:icmp_seq=2 ttl=40 time=37.044 ms

---www.taobao.com.danuoyi.tbcache.com ping statistics---

3 Packets transmitted, 3 packets received, 0.0% packet loss

Round-trip Min/avg/max/stddev = 37.044/37.878/38.801/0.720 ms

Script implementation Quick parse from Client server HTTP request

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.