CN108134708B - Method and device for monitoring third-party interface - Google Patents

Method and device for monitoring third-party interface Download PDF

Info

Publication number
CN108134708B
CN108134708B CN201611094353.8A CN201611094353A CN108134708B CN 108134708 B CN108134708 B CN 108134708B CN 201611094353 A CN201611094353 A CN 201611094353A CN 108134708 B CN108134708 B CN 108134708B
Authority
CN
China
Prior art keywords
party
state
message
transfer protocol
offline
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201611094353.8A
Other languages
Chinese (zh)
Other versions
CN108134708A (en
Inventor
党春艳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201611094353.8A priority Critical patent/CN108134708B/en
Publication of CN108134708A publication Critical patent/CN108134708A/en
Application granted granted Critical
Publication of CN108134708B publication Critical patent/CN108134708B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/50Testing arrangements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Abstract

The invention relates to a method and a device for monitoring a third-party interface. The method comprises the following steps: the simulated hypertext transfer protocol sends an access request to a third-party network address; receiving a hypertext transfer protocol status code returned in response to the access request; judging whether the hypertext transfer protocol status code is a preset status code; and if the hypertext transfer protocol status code is judged not to be the preset status code, indicating that the third-party interface is failed to call, and sending an alarm message. According to the method and the device for monitoring the third-party interface, the access request is sent to the third-party network address through the analog hypertext transfer protocol, whether the hypertext transfer protocol status code returned in response to the access request is the preset status code or not is judged, if the hypertext transfer protocol status code returned in response to the access request is not the preset status code, the third-party interface is failed to be called, the alarm message is sent, the problem that the third-party interface is failed to be called can be found in time, and the monitoring efficiency is improved.

Description

Method and device for monitoring third-party interface
Technical Field
The present invention relates to the field of computer applications, and in particular, to a method and an apparatus for monitoring a third-party interface.
Background
As more and more third party collaborators join on the service platform, the stability of the third party interface (i.e., the third party collaborator interface) needs to be monitored. Once the third-party interface call fails, the user cannot use the service.
In order to monitor the stability of the third-party interface, a data embedding point is added on a code level in a traditional mode, a user request is monitored in real time, when the user request fails or the time consumption is larger than a given threshold value, the access fails, then the access failure condition is sent to a developer for analysis, and manual analysis is used for checking which interface is failed to call, so that a large amount of time is consumed, and the monitoring efficiency is low.
Disclosure of Invention
Therefore, it is necessary to provide a method and an apparatus for monitoring a third-party interface, which can improve monitoring efficiency, for the problem that the monitoring efficiency of monitoring the stability of the conventional third-party interface is low.
A method of monitoring a third party interface, comprising:
the simulated hypertext transfer protocol sends an access request to a third-party network address;
receiving a hypertext transfer protocol status code returned in response to the access request;
judging whether the hypertext transfer protocol status code is a preset status code;
if the hypertext transfer protocol status code is judged not to be the preset status code, indicating that the third-party interface is failed to call, and sending an alarm message;
and if the hypertext transfer protocol status code is judged to be the preset status code, judging whether a third party corresponding to the third party network address is in an off-line state or a hidden state, and if the third party is in the off-line state or the hidden state, performing on-line operation on the third party.
An apparatus for monitoring a third party interface, comprising:
the request sending module is used for simulating a hypertext transfer protocol to send an access request to a third-party network address;
the receiving module is used for receiving the hypertext transfer protocol status code returned by responding to the access request;
the state code detection module is used for judging whether the hypertext transfer protocol state code is a preset state code;
the alarm sending module is used for sending an alarm message if the hypertext transfer protocol status code is judged not to be the preset status code and indicating that the third-party interface fails to call;
the state judgment module is used for judging whether a third party corresponding to the third party network address is in an off-line state or not if the hypertext transfer protocol state code is judged to be a preset state code;
and the state changing module is used for carrying out online operation on the third party if the third party is in an offline state.
According to the method and the device for monitoring the third-party interface, the access request is sent to the third-party network address through the analog hypertext transfer protocol, whether the hypertext transfer protocol status code returned in response to the access request is the preset status code or not is judged, if the hypertext transfer protocol status code returned in response to the access request is not the preset status code, the calling of the third-party interface is failed, the alarm message is sent, the problem of the calling failure of the third-party interface can be found in time, the monitoring efficiency is improved, and when the hypertext transfer protocol status code is the preset status code and the third party is in an off-line state or a hidden state, the third party is subjected to on.
Drawings
FIG. 1 is a diagram illustrating an exemplary application environment for a method for monitoring third party interfaces in one embodiment;
FIG. 2 is a schematic diagram showing an internal configuration of an electronic apparatus according to an embodiment;
FIG. 3 is a flow diagram of a method for monitoring a third party interface in one embodiment;
FIG. 4 is a flow diagram of a method of monitoring a third party interface in another embodiment;
fig. 5 is a specific flowchart illustrating an offline operation or a hidden operation performed on a third party corresponding to the third party network address in one embodiment;
FIG. 6 is a flowchart illustrating the operation of bringing a third party online in one embodiment;
FIG. 7 is a schematic view of a test frame in one embodiment;
FIG. 8 is a block diagram of an apparatus for monitoring a third party interface in one embodiment;
FIG. 9 is a block diagram showing the structure of an apparatus for monitoring a third party interface according to another embodiment;
fig. 10 is a block diagram showing the structure of a device for monitoring a third-party interface according to another embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
It will be understood that, as used herein, the terms "first," "second," and the like may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another. For example, a first alteration instruction may be referred to as a second alteration instruction, and similarly, a second alteration instruction may be referred to as a first alteration instruction, without departing from the scope of the present invention. Both the first change instruction and the second change instruction are change instructions, but they are not the same change instruction.
Fig. 1 is a schematic application environment of a method for monitoring a third-party interface in an embodiment. As shown in fig. 1, the application environment includes a testing side 110 and an accessed side 120. The testing terminal 110 may simulate HTTP (Hyper Text Transfer Protocol) to send an HTTP access request to the accessed terminal 120, receive an HTTP status code returned in response to the access request, determine whether the HTTP status code is a preset status code, and if not, indicate that the third-party interface call is failed, and send an alarm message. The test end 110 may be an electronic device where test codes are located. The visited end 120 may be a server where a third party network address is located, or the like. The electronic device may be a mobile terminal, a tablet computer, a personal computer, or the like.
Fig. 2 is a schematic diagram of an internal structure of an electronic device in one embodiment. As shown in fig. 2, the electronic device includes a processor, a nonvolatile storage medium, an internal memory, and a network interface, which are connected by a system bus. The device for monitoring the third-party interface is used for realizing a method for monitoring the third-party interface. The processor is used for providing calculation and control capability and supporting the operation of the whole electronic equipment. An internal memory in the electronic device provides an environment for operation of the apparatus for monitoring a third party interface in a non-volatile storage medium, the internal memory having stored therein computer readable instructions which, when executed by the processor, cause the processor to perform a method of monitoring a third party interface. The network interface is used for performing network communication with the server, such as sending an access request to the server, receiving a status code returned by the server, and the like. The electronic device may be a mobile phone, a tablet computer, or a personal digital assistant or a wearable device, etc. Those skilled in the art will appreciate that the architecture shown in fig. 2 is a block diagram of only a portion of the architecture associated with the subject application, and does not constitute a limitation on the electronic devices to which the subject application may be applied, and that a particular electronic device may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
FIG. 3 is a flow diagram of a method for monitoring a third party interface, under an embodiment. As shown in fig. 3, a method for monitoring a third party interface, which is executed on the electronic device in fig. 2, includes steps 302 to 308.
Wherein:
step 302, the simulated hypertext transfer protocol sends an access request to a third party network address.
In this embodiment, the test end sends an access request to a third-party network address through a simulated hypertext transfer protocol. The third party network address refers to the network address of a third party partner accessing the service platform. The service platform refers to a server providing certain specific functions, such as a medical registration platform, a vehicle shaking platform, a driving license examination registration platform and the like. The third-party network address can be a Hospital network address, a Shenzhen license examination registration network address, a Beijing license examination registration network address and the like.
In this embodiment, the access request may be sent to the third-party network address by periodically simulating the hypertext transfer protocol according to the preset interval. The preset interval time can be set according to the requirement, such as one transmission in 5 minutes.
Step 304, receiving the hypertext transfer protocol status code returned in response to the access request.
In this embodiment, the test end receives the hypertext transfer protocol status code returned by the accessed end in response to the access request. The hypertext transfer protocol status code is a numeric code to indicate the hypertext transfer protocol response status of the web server.
Step 306, determining whether the hypertext transfer protocol status code is a preset status code.
In this embodiment, the preset status code is a status code indicating that the third-party interface is successfully called, such as 200, 201, and the like. And the test terminal compares the returned hypertext transfer protocol status code with a preset status code, judges whether the returned hypertext transfer protocol status code is the same as the preset status code, if so, indicates that the calling of the third-party interface is successful, and if not, indicates that the calling of the third-party interface is failed.
Step 308, if the hypertext transfer protocol status code is judged not to be the preset status code, indicating that the third-party interface is failed to call, and sending an alarm message.
In this embodiment, the alarm message may include an alarm time, an alarm content, and an alarm level. The alarm time refers to the time at which the alarm was sent. The alarm content refers to the specific condition of the failure of calling the interface. The alarm level refers to the severity level of the failure to invoke the interface.
The third-party interface is a program interface, and is one of two types of interfaces provided by an operating system for a user, and a programmer requests the operating system to provide services through the program interface in a program.
And if the hypertext transfer protocol status code is judged to be the preset status code, judging whether a third party corresponding to the third party network address is in an off-line state or a hidden state, and if the third party is in the off-line state or the hidden state, performing on-line operation on the third party.
In this embodiment, the offline state refers to a state where the third party is interrupted from accessing the service platform, and the information of the third party cannot be viewed at the user side. The third party information may include a third party identification, a third party network address, and the like. The third party identifier is a string or the like for uniquely identifying the third party. The character string may include one or more of numbers, letters, and characters.
In this embodiment, when the hypertext transfer protocol status code is determined to be the preset status code and the third party corresponding to the third party network address is determined to be in the offline state, the third party is subjected to online operation. The online operation refers to accessing a third party to the service platform, so that the third party is in an online state. The on-line state refers to a state that the third party is in the access service platform, and the information of the third party can be viewed at the user side.
According to the method for monitoring the third-party interface, the access request is sent to the third-party network address through the simulated hypertext transfer protocol, whether the hypertext transfer protocol status code returned in response to the access request is the preset status code or not is judged, if not, the calling of the third-party interface is failed, an alarm message is sent, the problem of the calling failure of the third-party interface can be found in time, the monitoring efficiency is improved, and when the preset status code is adopted, and the third party is in an off-line state or a hidden state, the third party is subjected to on-line operation.
FIG. 4 is a flow diagram of a method for monitoring a third party interface in another embodiment. As shown in fig. 4, a method for monitoring a third party interface, which is executed on the electronic device in fig. 2, includes steps 402 to 418. Wherein:
step 402, the simulated hypertext transfer protocol sends an access request to a third party network address.
In this embodiment, the test end sends an access request to a third-party network address through a simulated hypertext transfer protocol. The third party network address refers to the network address of a third party partner accessing the service platform. The service platform refers to a server providing certain specific functions, such as a medical registration platform, a vehicle shaking platform, a driving license examination registration platform and the like. The third-party network address can be a Hospital network address, a Shenzhen license examination registration network address, a Beijing license examination registration network address and the like.
In this embodiment, the access request may be sent to the third-party network address by periodically simulating the hypertext transfer protocol according to the preset interval. The preset interval time can be set according to the requirement, such as one transmission in 5 minutes.
Step 404, receiving the hypertext transfer protocol status code returned in response to the access request.
In this embodiment, the test end receives the hypertext transfer protocol status code returned by the accessed end in response to the access request. The hypertext transfer protocol status code is a numeric code to indicate the hypertext transfer protocol response status of the web server.
Step 406, determining whether the http status code is a predetermined status code.
In this embodiment, the preset status code is a status code indicating that the third-party interface is successfully called, such as 200, 201, and the like. And the test terminal compares the returned hypertext transfer protocol status code with a preset status code, judges whether the returned hypertext transfer protocol status code is the same as the preset status code, if so, indicates that the calling of the third-party interface is successful, and if not, indicates that the calling of the third-party interface is failed.
Step 408, if it is determined that the hypertext transfer protocol status code is not the preset status code, indicating that the third party interface fails to be called, sending an alarm message, and then executing step 414.
In this embodiment, the alarm message may include an alarm time, an alarm content, and an alarm level. The alarm time refers to the time at which the alarm was sent. The alarm content refers to the specific condition of the failure of calling the interface. The alarm level refers to the severity level of the failure to invoke the interface.
Step 410, if the hypertext transfer protocol status code is determined to be the preset status code, determining whether a third party corresponding to the third party network address is in an offline state, if so, executing step 412, and if not, ending.
In this embodiment, the offline state refers to a state where the third party is interrupted from accessing the service platform, and the information of the third party cannot be viewed at the user side. The third party information may include a third party identification, a third party network address, and the like. The third party identifier is a string or the like for uniquely identifying the third party. The character string may include one or more of numbers, letters, and characters.
In this embodiment, when the hypertext transfer protocol status code is determined to be the preset status code and the third party corresponding to the third party network address is determined to be in the offline state, the third party is subjected to online operation. The online operation refers to accessing a third party to the service platform, so that the third party is in an online state. The on-line state refers to a state that the third party is in the access service platform, and the information of the third party can be viewed at the user side.
And step 412, performing online operation on the third party.
In this embodiment, the third party may be online by modifying a field value indicating a state of the third party in the third party data table, so that the third party is online.
In step 414, the number of times of the third party interface call failure within the preset time is counted, and then step 416 is executed.
In this embodiment, if the third-party interface fails to call once, the statistics is performed once to obtain the statistics times within the preset time. The preset time can be set according to the requirement.
In step 416, it is determined whether the counted number of times is greater than the number threshold, if yes, step 418 is performed, and if not, the process is ended.
In this embodiment, the number threshold may be configured in advance according to needs, such as 10 times.
And 418, performing offline operation or hiding operation on the third party corresponding to the third party network address.
In this embodiment, the offline operation refers to accessing the third party to the service platform by interrupting the access, so that the third party is in an offline state. The hiding operation means that the third party is hidden in the service platform, so that the third party is in a hidden state and the information of the third party cannot be viewed at the user side.
In the method for monitoring the third-party interface in the embodiment, the access request is sent to the third-party network address by simulating the hypertext transfer protocol, whether the hypertext transfer protocol status code returned in response to the access request is the preset status code is judged, if not, the calling of the third-party interface is failed, and an alarm message is sent, so that the problem of the calling failure of the third-party interface can be found in time, and the monitoring efficiency is improved; counting the number of times of calling failure of a third-party interface within preset time, and if the number of times of calling failure exceeds a threshold value of the number of times, performing offline operation or hiding operation on the third party to avoid the follow-up continuous occurrence of the calling failure of the third-party interface; and for the offline third party, if the third party calls the interface normally, the third party is online operated, so that the user can enjoy the service provided by the third party conveniently.
In other embodiments, a method of monitoring a third party interface may include steps 402-408, 414-418.
In an embodiment, the method for monitoring a third party interface further includes: and if the counted times are greater than a time threshold value, generating an offline message for performing offline operation or hiding operation on the third party corresponding to the third party network address, issuing the offline message to a message topic, acquiring the offline message from the message topic, and performing offline operation or hiding operation on the third party according to the offline message.
In this embodiment, the offline operation or the hidden operation is performed on the third party through the message publishing and subscribing model. The message publish-subscribe model includes a message Producer (Producer), a Consumer of the message (Consumer), and a message Topic (Topic). The message producer publishes the message under Topic through publishing operation, and the Consumer acquires the message under Topic through subscribing operation. And if the statistical times are monitored to be greater than the time threshold value by the testing terminal, generating an offline message for performing offline operation or hiding operation on the third party corresponding to the third party network address, and issuing the offline message to a message subject. And after reading the offline message from the message theme, performing offline operation or hiding operation on the third party according to the offline message.
In one embodiment, the offline operation or the hiding operation of the third party includes: the method comprises the steps that a control switch is switched from a first state to a second state, the third party corresponding to the network address of the third party carries out offline operation or hidden operation, the first state represents that the third party is in an online state, and the second state represents that the third party is in an offline state or a hidden state.
In this embodiment, the third party is controlled to be in an online state or an offline state through the switch, and the control mode is simple.
In an embodiment, as shown in fig. 5, the step of performing offline operation or hiding operation on the third party corresponding to the third party network address includes:
step 502, a first state change instruction including a third party identifier is obtained.
In this embodiment, the third party identifier is a character string used for uniquely representing the third party identity. The first state change instruction refers to an instruction for modifying a state.
Step 504, finding the corresponding third party data table according to the third party identifier in the first state change instruction.
In this embodiment, the corresponding relationship between the third party identifier and the third party data table is recorded in the test terminal. And searching the corresponding third-party data table from the corresponding relation between the third-party identification and the third-party data table according to the third-party identification in the first state change instruction.
Step 506, modifying the value of the field for indicating the third party state in the third party data table to be a first preset value, so that the third party is in an offline state or a hidden state.
In this embodiment, the third party can be in the offline state or the hidden state by modifying the first preset value of the field for indicating the third party state in the third party data table. The first preset value can be set according to requirements and is used for indicating that the third party is in an offline state or a hidden state.
In the embodiment, the third party state marked in the third party data table is directly modified through the program to realize the third party offline operation, the manual offline operation is replaced, the automation of the process is realized, and the manpower and material resources are saved.
In one embodiment, the step of sending the alert message includes: and calling the instant messaging application interface to send the alarm message.
In this embodiment, the instant messaging application interface refers to an interface for transmitting an alarm message, to which the test terminal is connected. The warning message can be transmitted in time by calling the instant communication interface to send the warning message.
In one embodiment, the step of sending the alert message includes: the alert message is sent as an email.
In this embodiment, the mailbox address of the alarm message receiver may be preset, and the alarm message may be sent to the mailbox address of the receiver in an email manner.
In one embodiment, the step of sending the alert message includes: and sending the alarm message in a short message mode.
In this embodiment, the mobile communication number of the alarm message receiver may be preset, and the alarm message may be sent to the mobile communication number of the receiver in a short message manner.
In one embodiment, as shown in fig. 6, the step of online operating the third party includes:
step 602, a second state change instruction including a third party identifier is obtained.
In this embodiment, the third party identifier is a character string used for uniquely representing the third party identity. The second state change instruction refers to an instruction for modifying a state.
Step 604, finding out the corresponding third party data table according to the third party identifier in the second state change instruction.
In this embodiment, the corresponding relationship between the third party identifier and the third party data table is recorded in the test terminal. And searching the corresponding third-party data table from the corresponding relation between the third-party identification and the third-party data table according to the third-party identification in the second state change instruction.
Step 606, modifying the value of the field for indicating the third party state in the third party data table to be a second preset value, so that the third party is in an online state.
In this embodiment, the third party can be in the online state by modifying the second preset value of the field for indicating the state of the third party in the third party data table. The second preset value can be set according to needs and is used for indicating that the third party is in an online state.
In the embodiment, the third party state marked in the third party data table is directly modified through the program to realize the online operation of the third party, the manual online operation is replaced, the automation of the process is realized, and the manpower and material resources are saved.
In one embodiment, the third party is brought online, and the method comprises the following steps: and switching the control switch from the second state to the first state, and performing online operation on the third party corresponding to the network address of the third party, wherein the first state represents that the third party is in an online state, and the second state represents that the third party is in an offline state or a hidden state.
A test framework constructed to implement the method of monitoring a third party interface is shown in fig. 7. The test framework includes a control layer, a logic layer, and an interface layer. Wherein, the control layer is mainly used for controlling the third party switch. The control layer can carry out the online operation or the offline operation by modifying the status field of the third-party data table. The logic layer is used for monitoring a plurality of third party interfaces. The logic layer is mainly used for simulating and sending an HTTP request and judging success or failure of calling the third-party interface according to the HTTP return code. The interface layer is mainly used for calling an instant messaging application interface or other application interfaces to send the alarm message. The alarm account and the alarm IP (Internet Protocol) address of the instant messaging application can be set in the interface layer, the instant messaging application interface can be modified, and the instant messaging application interface can be packaged.
The test framework may also include dependency packages. Dependency packages refer to jar packages to be used by programs, such as junit4.1.jar, jython. jar, and the like. junit is used for assertion, and jython is used for invoking python program when written in java language.
Further, the code is put into svn (subversion), and the number of monitoring times is set in Jekins continuous integration (monitoring is run once at a preset interval time). Jekins is an open source software project and aims to provide an open and easy-to-use software platform, so that continuous integration of software becomes possible. Continuous integration is a software development practice, i.e., team development members often integrate their work, by integrating each member at least once per day. Each integration is verified by automated build (including compilation, release, automated testing) to discover integration errors as early as possible. The SVN is an open source version control system. Meanwhile, the construction of projects, reports and software project management of documents can be managed through a Maven project object model.
The parameter information of the third-party interface is described below with reference to a specific application scenario. If the service platform is a medical registration platform, the third party is a doctor 160.
The scheduling information interface parameters for the hospitalization 160 are shown in table 1.
TABLE 1
Figure GDA0002976116080000101
Figure GDA0002976116080000111
The channel number is a character string unique to a channel.
The third party is a microscopical doctor, and the system parameters of the scheduling information interface of the third party are shown in table 2, and the request parameters are shown in table 3.
TABLE 2
Figure GDA0002976116080000112
Figure GDA0002976116080000121
The API (Application Programming Interface) Interface name is a third party scheduling Interface name. appkey refers to the application's unique key.
TABLE 3
Figure GDA0002976116080000122
The interface address of the third party C is http:// jkxapi.91jkj.com: 8082/jkxopenapi/wechatty, and the request parameters are shown in Table 4.
TABLE 4
Figure GDA0002976116080000123
Figure GDA0002976116080000131
And sending a request by an interface of a third party through simulating HTTP, entering in a post mode, filling related parameters and parameter values, and filling the parameters and parameter values of the information header if the information header exists.
And when the acquired HTTP status code is not 200, indicating that the third-party interface is failed to call, and sending an alarm message to a preset receiver. The alert message may be an alert time, alert content, and alert level. The alarm time refers to the time at which the alarm was sent. For example, the alarm time is 2016, 10 months, 20 days, 10 hours, 10 minutes, 10 seconds. The alert content may be that the third party failed to call the interface to obtain the physician shift information for the hospitalization 160. The alarm level (severity level) is high.
For the offline operation, the database may be connected through a program code, and the offline operation on the doctor 160 is realized by operating a third party data table, such as setting the third party data table t _ platform _ host, status to 0(0 represents offline) where platform _ name to "doctor 160".
For the online operation, the database is connected through the program code, and the online operation on the hospitalizing 160 is realized by operating the third party data table, such as setting the third party data table t _ platform _ hospital _ status to 1(1 represents online) where platform _ name to "hospitalizing 160".
FIG. 8 is a block diagram of an apparatus for monitoring a third party interface in one embodiment. As shown in fig. 8, an apparatus 800 for monitoring a third party interface includes a request sending module 802, a receiving module 804, a status code detecting module 806, an alarm sending module 808, a status determining module 810, and a status changing module 812. Wherein:
the request sending module 802 is configured to simulate a hypertext transfer protocol to send an access request to a third-party network address.
In this embodiment, the test end sends an access request to a third-party network address through a simulated hypertext transfer protocol. The third party network address refers to the network address of a third party partner accessing the service platform. The service platform refers to a server providing certain specific functions, such as a medical registration platform, a vehicle shaking platform, a driving license examination registration platform and the like. The third-party network address can be a Hospital network address, a Shenzhen license examination registration network address, a Beijing license examination registration network address and the like.
In this embodiment, the access request may be sent to the third-party network address by periodically simulating the hypertext transfer protocol according to the preset interval. The preset interval time can be set according to the requirement, such as one transmission in 5 minutes.
The receiving module 804 is configured to receive the hypertext transfer protocol status code returned in response to the access request.
In this embodiment, the receiving module 804 of the testing terminal receives the hypertext transfer protocol status code returned by the accessed terminal in response to the access request. The hypertext transfer protocol status code is a numeric code to indicate the hypertext transfer protocol response status of the web server.
The status code detection module 806 is configured to determine whether the http status code is a predetermined status code.
In this embodiment, the preset status code is a status code indicating that the third-party interface is successfully called, such as 200, 201, and the like. The status code detection module 806 of the test end compares the returned hypertext transfer protocol status code with a preset status code, and determines whether the returned hypertext transfer protocol status code is the same as the preset status code, if so, it indicates that the third-party interface is successfully called, and if not, it indicates that the third-party interface is failed to be called.
The alarm sending module 808 is configured to send an alarm message if the hypertext transfer protocol status code is determined not to be the preset status code, which indicates that the third-party interface fails to be invoked.
In this embodiment, the alarm message may include an alarm time, an alarm content, and an alarm level. The alarm time refers to the time at which the alarm was sent. The alarm content refers to the specific condition of the failure of calling the interface. The alarm level refers to the severity level of the failure to invoke the interface.
The status determining module 810 is configured to determine whether a third party corresponding to the third party network address is in an offline state if the hypertext transfer protocol status code is determined to be a preset status code;
the status change module 812 is configured to perform an online operation on the third party if the third party is offline.
In this embodiment, when the hypertext transfer protocol status code is determined to be the preset status code and the third party corresponding to the third party network address is determined to be in the offline state, the third party is subjected to online operation. The online operation refers to accessing a third party to the service platform, so that the third party is in an online state. The on-line state refers to a state that the third party is in the access service platform, and the information of the third party can be viewed at the user side.
And for the offline third party, if the third party calls the interface normally, the third party is online operated, so that the user can enjoy the service provided by the third party conveniently.
According to the device for monitoring the third-party interface, the access request is sent to the third-party network address through the simulated hypertext transfer protocol, whether the hypertext transfer protocol status code returned in response to the access request is the preset status code or not is judged, if not, the failure of calling the third-party interface is indicated, the alarm message is sent, the problem of the failure of calling the third-party interface can be found in time, the monitoring efficiency is improved, and when the preset status code is used, and the third party is in an off-line state or a hidden state, the third party is subjected to on-line operation.
Fig. 9 is a block diagram of an apparatus for monitoring a third party interface according to another embodiment. As shown in fig. 9, an apparatus 800 for monitoring a third party interface includes a statistics module 814 and a times judgment module 816, in addition to a request sending module 802, a receiving module 804, a status code detecting module 806, an alarm sending module 808, a status judgment module 810 and a status changing module 812. Wherein:
the counting module 814 is configured to count the number of times of call failure of the third party interface within a preset time.
In this embodiment, if the third-party interface fails to call once, the statistics is performed once to obtain the statistics times within the preset time. The preset time can be set according to the requirement.
The number determination module 816 is configured to determine whether the counted number is greater than a number threshold.
The status changing module 812 is configured to perform offline operation or hidden operation on the third party corresponding to the third party network address if the counted number of times is greater than the number threshold.
In this embodiment, the offline operation refers to accessing the third party to the service platform by interrupting the access, so that the third party is in an offline state. The hiding operation means that the third party is hidden in the service platform, so that the third party is in a hidden state and the information of the third party cannot be viewed at the user side.
In the device for monitoring the third-party interface in the embodiment, the access request is sent to the third-party network address by simulating the hypertext transfer protocol, whether the hypertext transfer protocol status code returned in response to the access request is the preset status code is judged, if the hypertext transfer protocol status code returned in response to the access request is not the preset status code, the third-party interface is failed to be called, and an alarm message is sent, so that the problem of the calling failure of the third-party interface can be found in time, and the monitoring efficiency is improved; counting the number of times of calling failure of the third-party interface within the preset time, and if the number of times of calling failure exceeds a threshold value of the number of times, performing offline operation or hiding operation on the third party to avoid the follow-up continuous occurrence of the calling failure of the third-party interface.
In one embodiment, the state change module 812 is further configured to obtain a first state change instruction including an identifier of a third party; searching a corresponding third-party data table according to the third-party identification in the first state change instruction; and modifying the value of a field for marking the state of the third party in the third party data table into a first preset value so as to enable the third party to be in an offline state or a hidden state.
In this embodiment, the third party can be in the offline state or the hidden state by modifying the first preset value of the field for indicating the third party state in the third party data table. The first preset value can be set according to requirements and is used for indicating that the third party is in an offline state or a hidden state.
In one embodiment, the alert sending module 808 is further configured to invoke the instant messaging application interface to send an alert message; or sending the alarm message in an e-mail mode or a short message mode.
Fig. 10 is a block diagram showing the structure of a device for monitoring a third-party interface according to another embodiment. As shown in fig. 10, an apparatus 800 for monitoring a third party interface includes a request sending module 802, a receiving module 804, a status code detecting module 806, an alarm sending module 808, a status determining module 810, a status changing module 812, a counting module 814, a frequency determining module 816, and a message generating and publishing module 818. Wherein:
the message generating and publishing module 818 is configured to generate an offline message for performing offline operation or hiding operation on the third party corresponding to the third party network address if the counted number of times is greater than the number threshold, and publish the offline message to the message topic.
The status changing module 812 is further configured to obtain the offline message from the message topic, and perform offline operation or hiding operation on the third party according to the offline message.
In one embodiment, the state changing module 812 is further configured to switch from a first state to a second state through the control switch, and perform offline operation or hidden operation on the third party corresponding to the third party network address, where the first state indicates that the third party is in an online state, and the second state indicates that the third party is in an offline state or a hidden state.
In one embodiment, the state change module 812 is further configured to obtain a second state change instruction including an identifier of a third party; searching a corresponding third-party data table according to the third-party identification in the second state change instruction; and modifying the value of the field for marking the state of the third party in the third party data table into a second preset value so as to enable the third party to be in an online state.
In this embodiment, the third party can be in the online state by modifying the second preset value of the field for indicating the state of the third party in the third party data table. The second preset value can be set according to needs and is used for indicating that the third party is in an online state.
In one embodiment, the state changing module 812 is further configured to switch from a second state to a first state through the control switch, and perform an online operation on the third party corresponding to the network address of the third party, where the first state indicates that the third party is in an online state, and the second state indicates that the third party is in an offline state or a hidden state.
In other embodiments, an apparatus 800 for monitoring a third party interface may include a request sending module 802, a receiving module 804, a status code detecting module 806, an alarm sending module 808, a status determining module 810, a status changing module 812, a counting module 814, a number determining module 816, and a message generating and publishing module 818.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a non-volatile computer-readable storage medium, and can include the processes of the embodiments of the methods described above when the program is executed. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), or the like.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (14)

1. A method of monitoring a third party interface, comprising:
the simulated hypertext transfer protocol sends an access request to a third-party network address;
receiving a hypertext transfer protocol status code returned in response to the access request;
judging whether the hypertext transfer protocol status code is a preset status code;
if the hypertext transfer protocol status code is judged not to be the preset status code, indicating that the third-party interface is failed to call, and sending an alarm message;
if the hypertext transfer protocol status code is judged to be a preset status code, whether a third party corresponding to the third party network address is in an off-line state or a hidden state is judged, and if the third party is in the off-line state or the hidden state, an on-line operation is carried out on the third party; the off-line state refers to a state that the third party is in the interrupted access service platform, and the information of the third party cannot be checked at the user side; the online operation refers to accessing a third party to the service platform, so that the third party is in an online state; the online state refers to a state that a third party is in an access service platform, and information of the third party can be checked at a user side;
counting the calling failure times of the third-party interface within preset time;
judging whether the counted times are greater than a time threshold value or not;
and if the counted times are greater than the time threshold value, performing offline operation or hiding operation on the third party corresponding to the third party network address.
2. The method of claim 1, further comprising:
and if the counted times are greater than a time threshold value, generating an offline message for performing offline operation or hiding operation on the third party corresponding to the third party network address, issuing the offline message to a message topic, acquiring the offline message from the message topic, and performing offline operation or hiding operation on the third party according to the offline message.
3. The method according to claim 1 or 2, wherein the step of performing offline operation or hiding operation on the third party corresponding to the network address of the third party comprises:
acquiring a first state change instruction containing a third party identifier;
searching a corresponding third-party data table according to the third-party identification in the first state change instruction;
and modifying the value of the field for marking the state of the third party in the third party data table into a first preset value so as to enable the third party to be in an offline state or a hidden state.
4. The method according to claim 1 or 2, wherein the step of performing offline operation or hiding operation on the third party corresponding to the third party network address comprises:
the method comprises the steps that a control switch is switched from a first state to a second state, the third party corresponding to the network address of the third party carries out offline operation or hidden operation, the first state represents that the third party is in an online state, and the second state represents that the third party is in an offline state or a hidden state.
5. The method of claim 1, wherein the step of sending an access request to a third party network address using an emulated hypertext transfer protocol comprises:
regularly simulating a hypertext transfer protocol to send an access request to a third-party network address according to a preset interval time;
the step of sending the alert message includes:
calling an instant messaging application interface to send an alarm message;
or sending the alarm message in an e-mail mode or a short message mode.
6. The method of claim 3, wherein the step of bringing the third party online comprises:
acquiring a second state change instruction containing a third party identifier;
searching a corresponding third-party data table according to the third-party identification in the second state change instruction;
and modifying the value of the field for marking the state of the third party in the third party data table into a second preset value so as to enable the third party to be in an online state.
7. An apparatus for monitoring a third party interface, comprising:
the request sending module is used for simulating a hypertext transfer protocol to send an access request to a third-party network address;
the receiving module is used for receiving the hypertext transfer protocol status code returned by responding to the access request;
the state code detection module is used for judging whether the hypertext transfer protocol state code is a preset state code;
the alarm sending module is used for sending an alarm message if the hypertext transfer protocol status code is judged not to be the preset status code and indicating that the third-party interface fails to call;
the state judgment module is used for judging whether a third party corresponding to the third party network address is in an off-line state or not if the hypertext transfer protocol state code is judged to be a preset state code;
the state changing module is used for carrying out online operation on a third party if the third party is in an offline state; the off-line state refers to a state that the third party is in the interrupted access service platform, and the information of the third party cannot be checked at the user side; the online operation means that a third party is accessed to the service platform, so that the third party is in an online state; the online state refers to a state that a third party is in an access service platform, and information of the third party can be checked at a user side;
the counting module is used for counting the calling failure times of the third-party interface within the preset time;
the frequency judging module is used for judging whether the counted frequency is greater than a frequency threshold value;
and the state changing module is further used for performing offline operation or hiding operation on the third party corresponding to the third party network address if the counted times are greater than a time threshold.
8. The apparatus of claim 7, further comprising:
the message generating and issuing module is used for generating an offline message for performing offline operation or hiding operation on the third party corresponding to the third party network address if the counted times are greater than a time threshold value, and issuing the offline message to a message subject;
the state changing module is further configured to obtain the offline message from the message theme, and perform offline operation or hiding operation on the third party according to the offline message.
9. The apparatus according to claim 7 or 8, wherein the status change module is further configured to obtain a first status change instruction including a third party identifier; searching a corresponding third-party data table according to the third-party identification in the first state change instruction; and modifying the value of a field for marking the state of the third party in the third party data table into a first preset value so as to enable the third party to be in an offline state or a hidden state.
10. The device according to claim 7 or 8, wherein the status changing module is further configured to switch from a first status to a second status through a control switch, and perform offline operation or hidden operation on the third party corresponding to the third party network address, where the first status indicates that the third party is on-line, and the second status indicates that the third party is off-line or hidden.
11. The apparatus of claim 7, wherein the request sending module is further configured to periodically simulate the hypertext transfer protocol to send the access request to the third-party network address according to the preset interval;
the alarm sending module is also used for calling the instant messaging application interface to send an alarm message; or sending the alarm message in an e-mail mode or a short message mode.
12. The apparatus of claim 9, wherein the state change module is further configured to obtain a second state change instruction comprising an identifier of a third party; searching a corresponding third-party data table according to the third-party identification in the second state change instruction; and modifying the value of the field for marking the state of the third party in the third party data table into a second preset value so as to enable the third party to be in an online state.
13. A computer-readable storage medium, storing a computer program which, when executed by a processor, causes the processor to carry out the steps of the method according to any one of claims 1 to 6.
14. A computer device comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1 to 6.
CN201611094353.8A 2016-12-01 2016-12-01 Method and device for monitoring third-party interface Active CN108134708B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611094353.8A CN108134708B (en) 2016-12-01 2016-12-01 Method and device for monitoring third-party interface

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611094353.8A CN108134708B (en) 2016-12-01 2016-12-01 Method and device for monitoring third-party interface

Publications (2)

Publication Number Publication Date
CN108134708A CN108134708A (en) 2018-06-08
CN108134708B true CN108134708B (en) 2021-05-25

Family

ID=62388347

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611094353.8A Active CN108134708B (en) 2016-12-01 2016-12-01 Method and device for monitoring third-party interface

Country Status (1)

Country Link
CN (1) CN108134708B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108845912B (en) * 2018-06-11 2019-08-06 掌阅科技股份有限公司 Service interface calls the alarm method of failure and calculates equipment
CN110086658B (en) * 2019-04-11 2022-09-30 平安科技(深圳)有限公司 Interface switching method and device and computer readable storage medium
CN111861062B (en) * 2019-04-30 2023-09-26 北京嘀嘀无限科技发展有限公司 User index management method, device, server and computer readable storage medium
CN110224870B (en) * 2019-06-19 2023-03-24 腾讯云计算(北京)有限责任公司 Interface monitoring method and device, computing equipment and storage medium
CN113114490B (en) * 2021-03-30 2023-10-27 海信集团控股股份有限公司 API call abnormity warning method, device, equipment and medium
CN113282460A (en) * 2021-05-27 2021-08-20 中国联合网络通信集团有限公司 Distributed alarm system, method and device
CN113676509A (en) * 2021-07-06 2021-11-19 北京思特奇信息技术股份有限公司 Active detection method and system for health state of HTTP (hyper text transport protocol) interface
CN115941546A (en) * 2022-11-29 2023-04-07 重庆长安汽车股份有限公司 System interface monitoring method and device, electronic equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101404599A (en) * 2008-11-12 2009-04-08 华为技术有限公司 Network fault detection method, primary device, slave device, control terminal and system
CN103685575A (en) * 2014-01-06 2014-03-26 洪高颖 Website security monitoring method based on cloud architecture
CN104065725A (en) * 2014-06-25 2014-09-24 北京思特奇信息技术股份有限公司 System real-time monitoring method based on hyper text transfer protocol (HTTP) and system
CN104735736A (en) * 2013-12-24 2015-06-24 中国移动通信集团公司 Network access method and user terminal
WO2015089824A1 (en) * 2013-12-20 2015-06-25 华为技术有限公司 Method and apparatus for switching polling and interruption
CN104767653A (en) * 2015-01-29 2015-07-08 小米科技有限责任公司 Method and device for monitoring network interfaces
CN105872090A (en) * 2016-05-27 2016-08-17 四川长虹电器股份有限公司 HTTP communication method based on extension status codes

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101404599A (en) * 2008-11-12 2009-04-08 华为技术有限公司 Network fault detection method, primary device, slave device, control terminal and system
WO2015089824A1 (en) * 2013-12-20 2015-06-25 华为技术有限公司 Method and apparatus for switching polling and interruption
CN104735736A (en) * 2013-12-24 2015-06-24 中国移动通信集团公司 Network access method and user terminal
CN103685575A (en) * 2014-01-06 2014-03-26 洪高颖 Website security monitoring method based on cloud architecture
CN104065725A (en) * 2014-06-25 2014-09-24 北京思特奇信息技术股份有限公司 System real-time monitoring method based on hyper text transfer protocol (HTTP) and system
CN104767653A (en) * 2015-01-29 2015-07-08 小米科技有限责任公司 Method and device for monitoring network interfaces
CN105872090A (en) * 2016-05-27 2016-08-17 四川长虹电器股份有限公司 HTTP communication method based on extension status codes

Also Published As

Publication number Publication date
CN108134708A (en) 2018-06-08

Similar Documents

Publication Publication Date Title
CN108134708B (en) Method and device for monitoring third-party interface
US20200250024A1 (en) High-volume distributed script error handling
CN106294102B (en) Application program testing method, client, server and system
CN108628748B (en) Automatic test management method and automatic test management system
CN105389263B (en) Application software authority monitoring method, system and equipment
CN111611140B (en) Report verification method and device for buried point data, electronic equipment and storage medium
CN115065652B (en) Message reply method and device, storage medium and computer equipment
CN111694644A (en) Message processing method and device based on robot operating system and computer equipment
CN107168844B (en) Performance monitoring method and device
CN112035303B (en) Data testing method and device, computer and readable storage medium
CN113268336A (en) Service acquisition method, device, equipment and readable medium
CN110515855B (en) Simulation control method, server and system for application program
CN116069838A (en) Data processing method, device, computer equipment and storage medium
CN117493188A (en) Interface testing method and device, electronic equipment and storage medium
CN110908708B (en) Code release method, device and system
CN109274533B (en) Web service fault positioning device and method based on rule engine
CN112817816B (en) Embedded point processing method and device, computer equipment and storage medium
CN113901153A (en) Data processing method and related equipment
CN112882948A (en) Stability testing method, device and system for application and storage medium
CN112559348A (en) Test analysis method, system, equipment and medium based on jacoco
EP3345147A1 (en) Device integrity based assessment of a user action associated with an advertisement
CN110048940A (en) Sending method, device, server and the readable storage medium storing program for executing of instant communication message
CN117155890B (en) Method and device for processing applet message and electronic equipment
CN106547679B (en) Script management method and script management platform
CN113778800B (en) Error information processing method, device, system, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant