Summary of the invention
The present invention provides a kind of diagnostic method of website visiting failure, comprising:
Web site performance achievement data is obtained, and routine diagnosis is executed according to the achievement data;
The routine diagnosis information obtained according to the routine diagnosis determines whether website visiting succeeds;
If it is determined that the result is that website visiting failure, then further obtain depth diagnostic message data, and according to the depthDiagnostic message data execute depth diagnosis.
Preferably, the routine diagnosis further comprises: obtaining HTTP request status code, and according to the HTTP request shapeState code judges whether the solicited status is normal.
Preferably, the routine diagnosis further comprises: if the solicited status is normal, further obtaining the accessThe performance monitoring data of website, and the web site performance is diagnosed according to the performance monitoring data.
Preferably, the performance monitoring data includes the resource of the Connection Time of TCP, dns resolution time and Website pageThe link information of file.
Preferably, the depth diagnosis further comprises: the network for being directed to terminating machine is executed using public name serverDetection of connectivity, judges whether the terminating machine is successfully accessed internet.
Preferably, the depth diagnosis further comprises: if the terminating machine is successfully accessed internet, according to acquisitionThe reason of dns resolution result tracking parsing failure or the inspection that validity and correctness are executed for the IP address parsed.
Preferably, the depth diagnosis further comprises: if the dns resolution fails, further detecting domain name serviceWhether device is reachable or whether domain name server has service fault.
Preferably, depth diagnosis further comprises: judge the TCP whether successful connection, if successful connection, intoOne step executes HTTP connecting detection;It is on the contrary then further search for TCP connection failure cause.
Preferably, the depth diagnosis further comprises: if the HTTP successful connection, further executing and is directed to websiteThe diagnosis of front end webpage.
According to another aspect of the present invention, a kind of diagnostic system of website visiting failure is also provided, comprising: storage deviceAnd processor;Wherein, for storing computer program, the computer program executes the storage device by the processorWhen, for realizing method as described above.
Compared with the existing technology, the present invention achieves following advantageous effects: network access fault provided by the inventionDiagnostic method and system, the standard Resource Timing of the W3C supported based on modern browser core andNavigation Timing, split source automated test frame Selenium Webdriver is extended, to realize clearDevice of looking at accesses the performance data collection of Web site, the foundation as follow-up diagnosis;The level of fault diagnosis is divided into routine simultaneouslyWith two kinds of depth, carry out relatively simple routine initiating access initial stage to website using acquisition access performance monitoring data and examiningDisconnected, for the website for energy successful access, auxiliary completes the access quality evaluation system of the website;And for access failureWebsite then continues depth diagnosis, further to check the reason of accessing failure with locating websites;Whether routine diagnosisOr depth diagnosis is integrated with multiple network testing tool to realize the comprehensive diagnos to website visiting failure;Utilize the present inventionThe website visiting fault diagnosis method and system of offer can diagnose the reason of user's access web failure, the row of helpIt looks into and determines fault point, to perhaps solve failure in reporting fault in time, restore access as early as possible.
Specific embodiment
In order to which the purpose of the present invention, technical solution and advantage is more clearly understood, below in conjunction with attached drawing, to the present inventionEmbodiment in the diagnostic method of website visiting failure that provides and system be further described.
Inventor conscientiously has studied the factor discovery for influencing website visiting quality, can be from network, server end and front endThree aspects analyze the reason of causing website visiting to fail respectively.
Wherein, network factors refer to that network reason itself causes access to fail, specifically, as link physical failure, DNS takeBusiness device failure or network congestion etc..And cause network congestion basic reason be Internet resources scarcity, i.e. user load is greater thanThe capacity and processing capacity of Internet resources, but show failure embodiment but can be it is various, for example, due to routerCaching deficiency causes the data packet reached frequently to be abandoned;Either because link bandwidth deficiency cause in data transmission procedureBandwidth bottleneck is formd on low speed chain circuit;Either processor speed causes router cpu executing queuing caching, updating road slowlyWhen being operated by table etc., processing speed does not catch up with high-speed link etc..
Server end factor refers to the various parameters for influencing server performance, such as hardware configuration, the I/O performance of serverWith the reference indexs such as bandwidth.For example, bandwidth quality is exactly an important factor for influencing website response time, server end would generally be becauseFor above-mentioned parameter is unable to satisfy demand and overload occurs to refuse to service, website visiting is caused to fail.In addition, serverEnd is also possible to cause website visiting to fail because of physical problem, such as power-off etc..
Front end factor refers to the resource for influencing the front end page of website visiting performance.Usually, front end page optimizesQuality is affected for web site performance, and the user experience of front end even determines whether user can persistently use the websiteFunction.Access performance can be made to decline when for example, JS, CSS or picture resource of the page are excessive and generating excessive HTTP request,Or when the resource of request is not compressed it is also possible that data transmission pressure is larger, and cause the page show it is slow evenTime-out eventually leads to website visiting failure.
In order to which the access performance quickly to website carries out diagnosing and determining failure cause, a kind of inventor's base especially set outIn standard Resource Timing and the Navigation Timing for the W3C that modern browser core is supported, for websiteThe diagnostic method of access fault, the process employs routine diagnosis and depth to diagnose the mode combined, fast and accurately to netAccess quality of standing diagnose and positioning failure reason.It is described in detail below in conjunction with specific embodiment.
The preferred embodiment of the present invention provide website visiting method for diagnosing faults specifically includes the following steps:
S10 routine diagnosis
Fig. 1 is the diagnostic tree schematic diagram of routine diagnosis provided by the invention, as shown in Figure 1, when accessing net by browserWhen standing, routine diagnosis, the execution logic of diagnostic process are carried out to website according to the performance indicator data for obtaining Web site firstIt can gradually be executed from diagnostic tree shown in Fig. 1, specifically includes the following steps:
The diagnosis of S101HTTP solicited status
HTTP request status code is obtained, if the status code is more than or equal to 500, it is concluded that conclusion: server mistake;IfStatus code is more than or equal to 400 and less than 500, it is concluded that conclusion: client request error;If status code be equal to 200, it is concluded thatConclusion: solicited status is normal, can continue to execute the detection of S102.
The diagnosis of S102 web site performance
When solicited status is normal, browser access target website is opened using Selenium WebDriver, and utilizeThe Resource Timing API and Navigation Timing API that W3C is provided gets the performance monitoring number of access websiteAccording to being specifically included further to diagnose web site performance using the data labeled as timingInfo and resourcesInfo:
(1) Connection Time of TCP is calculated using connectStart the and connectEnd field in timingInfo, andIt is compared with preset threshold value, if it exceeds the threshold, then concluding that network failure-TCP connection overlong time.
It is obtained specifically, the Connection Time of TCP can be calculated using following formula:
timingInfo.connectEnd-timingInfo.connectStart
Wherein, timingInfo.connectEnd and timingInfo.connectStartconnectEnd are respectively indicatedThe connection end time point and connection start time point of TCP.
(2) DNS is calculated using domainLookupStart the and domainLookupEnd field in timingInfo to solveThe time is analysed, and is compared with preset threshold value, if it exceeds the threshold, then concluding that network failure-dns resolution time mistakeIt is long.
It is obtained specifically, the dns resolution time can be calculated using following formula:
timingInfo.domainLookupEnd-timingInfo.domainLookupStart
Wherein, timingInfo.domainLookupEnd and timingInfo.domainLookupStart are respectively indicatedThe end time point and start time point of dns resolution.
(3) using the link information of all resource files of the Website page in resourcesInfo, to each resource chainIt connects using Curl command request this document and downloads file, to obtain resource file download time and size.It is every to knowA resource link whether effectively and whether can be downloaded and resource size whether be more than pre-set threshold value etc. synthesis sentenceWhether the resource file that breaks loads success, and provides resource downloading success rate.When resource downloading success rate be lower than threshold value, it is concluded thatThere may be resource load time-out or the conclusions of failure for Website page.
S103 routine diagnosis is completed
If without failure in the diagnosis of above-mentioned S101-S102, it can get the normal conclusion of website visiting, routinely examineIt is disconnected to terminate;If there is Arbitrary Fault in the diagnosis of above-mentioned S101-S102, the depth for continuing starting step S20 is diagnosed.
The diagnosis of S20 depth
Fig. 2 is the diagnostic tree schematic diagram of depth diagnosis provided by the invention, as shown in Fig. 2, when through the routine in step S10When diagnosis obtains website visiting failure, routine diagnosis information can be checked, and to trigger depth diagnosis according to demand, specifically, canIt is executed according to the depth diagnostic message data further obtained and the depth of website visiting failure is diagnosed, the execution of diagnostic processLogic can gradually be executed from diagnostic tree shown in Fig. 2, specifically includes the following steps:
The diagnosis of S201 linking Internet
Using Ping order, net is carried out to common some well-known name servers or well-known Website server and terminating machineThe detection of network connectivity, such as " 114.114.114.114 " and " 8.8.8.8 " etc..If tested name server or well-knownThe test that Website server issues Ping operation is surrounded by response and the relevant informations such as response time for returning to test bag, then illustratesTerminating machine is connected to the network of tested host, and terminating machine has accessed internet, can be continued to execute subsequent depth and be examinedIt is disconnected;Otherwise determine that terminating machine does not access network, thus the reason of further investigation causes this result, such as the event of terminating machine network interface cardBarrier is not allocated to available IP address or place local area network is unstable etc..
If the diagnostic result of S201 determines terminating machine accessed network, further executes and the depth of network is diagnosed.
S202DNS parsing diagnosis
Dns resolution is obtained using Nslookup order as a result, can further track if domain name mapping is returned without resultThe reason of parsing failure, conversely, then the validity to the IP address parsed and correctness carry out subsequent inspection.Specific packetIt includes:
(1) name server is up to diagnosis
If domain name mapping is returned without result, can further judge whether used name server is reachable, specifically,The connectivity of name server used is tested using Ping order, if test display connection, need be to name serverThe no analysis service that can normally provide makees further detection, conversely, then can be determined that failure cause is that dns server is unreachable, fromAnd terminate diagnosis.
(2) name server fault diagnosis
If server is reachable, it can further detect whether the name server has service fault.Specifically, providing oneCommon domain name list parses common domain name therein using the name server, determines that the domain name takes if it can normally parseThe reason of business device can normally provide analysis service, dns resolution is caused to fail may be that website domain name temporarily fails to add or updateInto name server, and terminate to diagnose.If the common domain name in list cannot be successfully parsed, the domain name can be determined thatTemporarily there is service fault in server, terminates diagnosis.
S203TCP connection diagnosis
Whether succeeded using Socket programming judgement and the TCP connection of Website server.Specifically, if TCP connection success,Then further HTTP connection is detected;If TCP connection fails, the reason of further searching for unsuccessfully.
If TCP connection fails, using the connectivity of Ping order test Website server, if connection illustrates that website takesBusiness device does not break down, itself can normally provide service, then knows that the reason of causing TCP connection to fail may be website clothesThe connection of server refusal, diagnosis caused by business device overload etc. terminate.If be not connected to, illustrate to take from terminating machine to websiteThe network link (including Website server itself) of business device has been likely to occur failure, needs to continue to use Traceroute tool and obtainsThe routing link details from terminating machine to Website server are taken, so as to the position of further fault point, and terminate to diagnose.
If TCP connection success, the connection status of diagnosable HTTP.
S204HTTP connection diagnosis
Firstly, obtaining the URL after website jumps, judge whether website makes according to HTTPS or HTTP whether is contained in URLWith HTTPS.Simultaneously using Selenium WebDriver and W3C provide Resource Timing API andNavigation Timing API get access website performance monitoring data, labeled as timingInfo withResourcesInfo specifically includes for use in subsequent diagnosis:
If website has used HTTPS, SSL is determined using the secureConnectionStart field of timingInfoIt shakes hands and whether fails.Specifically, can determine that SSL connection is lost if having the field and its value in timingInfo is 0It loses, terminates diagnosis, the reason of network access failure may be Certificate Revocation etc. at this time;It is on the contrary then think that SSL shakes hands success, continueDetect the connection status of HTTP.
Secondly, initiating HTTP connection request to targeted website and obtaining corresponding returned data, to detect HTTP connectionWhether response is had.
If HTTP request does not respond to, it can get packet loss by sending Ping order to Website server and be averagedThe information such as time delay judge whether that network congestion has occurred.Specifically, obtaining the knot there are packet drop if packet loss is greater than 0By, and, may mainly there be physical circuit failure, equipment fault, virus attack, routing iinformation mistake etc. in the reason of causing packet loss, tieBeam diagnosis;If average delay has been more than pre-set threshold value, it is concluded that time delay is larger, in fact it could happen that the knot of network congestionBy end diagnosis;If above situation is not present, cause HTTP request without response the reason of may be other networks originalCause, such as Website server service quality are bad etc., and terminate to diagnose.
If HTTP request has response, inspection state code.If status code be 200, need to Website page element intoThe finer detection of row;If status code is not equal to 200, corresponding abnormal cause is provided according to error code prompt, for example,404Not Found or 403Forbidden etc., and terminate to diagnose.
The diagnosis of S205 Website front-end webpage
If it is 200 that above-mentioned HTTP request, which has response and its return status code, i.e., when HTTP request is successful, then it can detect websiteThe resource file of front end page.For example, being believed according to the link for the resource file for having Website page all in resourcesInfoBreath, using Curl command request this document and file is downloaded to each resource link, thus obtain resource file download time andSize, and know whether each resource link is effective and whether can be downloaded and whether resource size is more than to presetThe comprehensive descisions such as the threshold value resource files whether load success, and provide resource downloading success rate.When resource downloading success rateLower than threshold value, it is concluded that Website page is there may be the conclusion that resource load is overtime or fails, diagnosis terminates;Conversely, then integratingAll precursor steps, can obtain no catastrophe failure, the normal conclusion of website visiting, and diagnosis terminates.
According to another aspect of the present invention, a kind of system executing above-mentioned network access fault diagnostic method is also provided,The diagnostic system includes data acquisition module, routine diagnosis module and depth diagnostic module.Wherein, acquisition module can be used for obtainingTake the performance indicator data of WEB website and the diagnostic message data for fault diagnosis, and by the performance indicator data of WEB websiteIt is transmitted to routine diagnosis module to be used to execute the routine diagnosis to website visiting quality, and diagnostic message data is transmitted to depthDegree diagnostic module is used to execute the depth diagnosis to website visiting quality.
Specifically, routine diagnosis can be used for executing the diagnosis to HTTP request state and web site performance;Depth diagnosis is availableIn execution to the comprehensive diagnos and trouble spot judging of linking Internet, network itself, server end and webpage front-end.
In one embodiment of the invention, above system can be realized by way of the terminating card realized by Java,Specifically, the plug-in unit can be based on http protocol, the transmission of formula data is interacted using JSON format and plugin manager.
Although to net provided by the invention in the above-described embodiments, using ping, nslookup, tracerouteNetwork access fault diagnostic method is illustrated, but it will be recognized by one of ordinary skill in the art that in addition to the net in above-described embodimentNetwork testing tool, other general networks testing tools with similar functions may be applicable to network access event provided by the inventionHinder diagnostic method.
Although the present invention has been described by means of preferred embodiments, the present invention is not limited to described hereEmbodiment, without departing from the present invention further include made various changes and variation.