Execution function monitoring method and device, equipment and storage medium

By replacing the system key function with the target key function in the PHP service, and collecting the monitoring data of the core function, the problem of being unable to monitor the entire link of the PHP service in the existing technology is solved, and the efficiency of locating the fault node and the back-end business are improved. stability.

CN118535238APending Publication Date: 2024-08-23GUANGZHOU YIHU NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410491447.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-23
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing technology cannot perform full-link monitoring of the core functions of PHP services, making it difficult to analyze and locate faulty nodes and affecting the stability of back-end services.

Method used

After the process manager is started, the system key function is replaced with the target key function. The target key function is encapsulated by the monitoring function and the system key function. The request received by the process manager is assigned to the PHP interpreter for execution, and the function name is obtained and matched. , call the system key function and monitoring function in the target key function to collect the monitoring data of the core function to achieve seamless access to full-link monitoring.

Benefits of technology

It improves the efficiency of locating faulty nodes, ensures the stability of back-end services, and enables full-link monitoring of PHP services without modifying the PHP service code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535238A
    Figure CN118535238A
Patent Text Reader

Abstract

The invention discloses an execution function monitoring method and device, equipment and a storage medium, and relates to the technical field of computers. The method comprises the steps that after a process manager is started, a system key function is replaced with a target key function, and the target key function is obtained by packaging a monitoring function and the system key function; the request received by the process manager is distributed to a PHP interpreter, the PHP interpreter is used for executing a corresponding PHP script processing request, and a PHP script comprises a plurality of first functions; after the PHP script starts to be executed, obtaining a function name of the first function, and matching the function name of the first function with a function name of a preset second function; and under the condition that the function name of the first function is matched with the function name of a preset second function, calling a system key function in the target key functions to execute the first function, and calling a monitoring function in the target key functions to obtain monitoring data for executing the first function, thereby realizing PHP service seamless access full-link monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an execution function monitoring method, device, equipment and storage medium. Background Art

[0002] With the widespread use of microservice technology, the backend business of game applications has become more and more complex. After the game application architecture has evolved from centralized to distributed, the entire call relationship has also become complex. In order to ensure the operational stability of the backend business, the backend business can be monitored to monitor the faulty nodes of the backend business in real time and maintain the faulty nodes in a timely manner.

[0003] In the prior art, the backend business uses PHP (Hypertext Preprocessor) service, which is a server-side application written in PHP language, which can be used to process requests from clients and return corresponding responses. However, the monitoring method of PHP service is generally to monitor the site through lun extension from the nginx entrance. This monitoring method can only monitor the entrance traffic, and cannot monitor the core functions of PHP service in the whole link. It is difficult to analyze, track and accurately locate the fault nodes of PHP service, and cannot guarantee the stability of backend business. Summary of the invention

[0004] The present application provides an execution function monitoring method, device, equipment and storage medium, so as to obtain the monitoring data of each core function execution during the execution of the PHP script through a pre-buried monitoring function, so as to achieve the purpose of seamless access of the PHP service to the full-link monitoring without modifying the PHP service code, solve the technical problem that the core functions of the PHP service cannot be fully monitored in the prior art, improve the efficiency of locating the faulty nodes, and ensure the stability of the back-end business.

[0005] In a first aspect, the present application provides an execution function monitoring method, comprising:

[0006] After the process manager is started, the system key function is replaced with a target key function, wherein the target key function is obtained by encapsulating the monitoring function and the system key function;

[0007] Assigning the request received by the process manager to a PHP interpreter so as to execute a corresponding PHP script through the PHP interpreter to process the request, wherein the PHP script includes a plurality of first functions;

[0008] After starting to execute the PHP script, obtaining a function name of the first function, and matching the function name of the first function with a preset function name of the second function;

[0009] When the function name of the first function matches the function name of the preset second function, the system key function in the target key function is called to execute the first function, and the monitoring function in the target key function is called to obtain monitoring data of executing the first function.

[0010] In a second aspect, the present application provides an execution function monitoring device, comprising:

[0011] A key function replacement module is configured to replace the system key function with a target key function after the process manager is started, wherein the target key function is obtained by encapsulating the monitoring function and the system key function;

[0012] A request allocation module is configured to allocate the request received by the process manager to the PHP interpreter so as to execute a corresponding PHP script through the PHP interpreter to process the request, wherein the PHP script includes a plurality of first functions;

[0013] A function name matching module is configured to obtain a function name of a first function after starting to execute the PHP script, and match the function name of the first function with a preset function name of a second function;

[0014] The first monitoring module is configured to call the system key function in the target key function to execute the first function when the function name of the first function matches the function name of the preset second function, and to call the monitoring function in the target key function to obtain monitoring data of the execution of the first function.

[0015] In a third aspect, the present application provides an execution function monitoring device, comprising:

[0016] one or more processors;

[0017] A memory stores one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the execution function monitoring method as described in the first aspect.

[0018] In a fourth aspect, the present application provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the execution function monitoring method as described in the first aspect.

[0019] In the present application, after the process manager is started, the system key function is replaced with the target key function, and the target key function is encapsulated by the monitoring function and the system key function; the request received by the process manager is assigned to the PHP interpreter to execute the corresponding PHP script to process the request through the PHP interpreter, and the PHP script includes multiple first functions; after starting to execute the PHP script, the function name of the first function is obtained, and the function name of the first function is matched with the function name of the preset second function; when the function name of the first function matches the function name of the preset second function, the system key function in the target key function is called to execute the first function, and the monitoring function in the target key function is called to obtain the monitoring data of the execution of the first function. Through the above-mentioned technical means, the target key function can replace the system key function that will be called when each function in the PHP service is executed, so as to embed the monitoring function used to collect monitoring data during the execution of the function, so that during the execution of the PHP script, the system key function in the target key function is called before the core function is executed to execute the core function. At the same time, the monitoring data during the execution of the core function is collected through the monitoring function in the target key function. The purpose of seamless access to full-link monitoring of PHP service is achieved without modifying the PHP service code. The technical problem that the core function of PHP service cannot be fully monitored in the prior art is solved, the efficiency of locating faulty nodes is improved, and the stability of back-end business is ensured. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 is a flow chart of an execution function monitoring method provided in an embodiment of the present application;

[0021] Figure 2 It is a schematic diagram of the operation mode of the PHP service provided in the embodiment of the present application;

[0022] Figure 3 This is a flowchart of obtaining monitoring data through a pre-function and a post-function provided in an embodiment of the present application;

[0023] Figure 4 This is a flowchart of obtaining request data through a pre-function and a post-function provided in an embodiment of the present application;

[0024] Figure 5 It is a structural diagram of an execution function monitoring device provided in an embodiment of the present application;

[0025] Figure 6 It is a structural diagram of an execution function monitoring device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical scheme and advantages of the present application clearer, the specific embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. It is understood that the specific embodiments described herein are only used to explain the present application, rather than to limit the present application. It should also be noted that, for the convenience of description, only the part related to the present application but not all the contents are shown in the accompanying drawings. Before discussing the exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow chart describes each operation (or step) as a sequential process, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.

[0027] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0028] In the more common existing implementation methods, the backend business uses PHP (Hypertext Preprocessor) service, which is a server-side application written in PHP language, which can be used to process requests from clients and return corresponding responses. However, the monitoring method of PHP service is generally to monitor the site from the nginx entrance through the lun extension. This monitoring method can only monitor the entrance traffic, and cannot monitor the core functions of the PHP service throughout the link. It is difficult to analyze, track and accurately locate the fault nodes of the PHP service, and cannot guarantee the stability of the backend business.

[0029] To solve the above problems, this embodiment provides an execution function monitoring method, which obtains the monitoring data of each core function execution during the execution of the PHP script through a pre-buried monitoring function, so as to achieve the purpose of seamless access of PHP service to full-link monitoring without modifying the PHP service code, thereby improving the efficiency of locating faulty nodes and ensuring the stability of back-end business.

[0030] The execution function monitoring method provided in this embodiment can be executed by an execution function monitoring device, which can be implemented by software and / or hardware, and can be composed of two or more physical entities or one physical entity. For example, the execution function monitoring device can be a backend server using PHP service.

[0031] The execution function monitoring device is installed with at least one type of operating system, wherein the operating system includes but is not limited to Android system, Linux system and Windows system. The execution function monitoring device can install at least one application based on the operating system, and the application can be an application that comes with the operating system or an application downloaded from a third-party device or server. In this embodiment, the execution function monitoring device has at least an application that can execute the execution function monitoring method, for example, the application can be the PHP service itself.

[0032] For ease of understanding, this embodiment is described by taking the backend server as an example of the execution subject of the function monitoring method.

[0033] Figure 1 A flowchart of an execution function monitoring method provided by an embodiment of the present application is given. Figure 1 , the execution function monitoring method specifically includes:

[0034] S110. After the process manager is started, the system key function is replaced with a target key function, where the target key function is encapsulated by the monitoring function and the system key function.

[0035] Among them, the process manager (FastCGIProcess Manager, FPM) is a PHP FastCGI manager, which is used to manage the PHP FastCGI process pool. FastCGI is a protocol for communication between a web server and a dynamic scripting language. It allows the web server to forward requests to the PHP interpreter running in the background instead of starting a new interpreter process for each request. The PHP interpreter is responsible for parsing and executing PHP scripts. For example, Figure 2 Schematic diagram of the operation mode of the PHP service provided by the embodiment of the present application. Figure 2As shown in the figure, the PHP life cycle is the entire process of the PHP interpreter from startup to end, which covers the module initialization phase, request initialization phase, PHP script execution phase, request closing phase and module closing phase. After the process manager is started, one or more PHP interpreter processes will be created to represent the startup of the PHP interpreter. After the PHP interpreter is started, it will enter the module initialization phase. In the module initialization phase, the PHP interpreter calls the PHP_MINIT_FUNCTION initialization module and performs some necessary variable applications and memory allocations. The web server sends the request to the process manager. After the process manager sends the request to the PHP interpreter through the SAPI interface, the PHP interpreter enters the request initialization phase and calls PHP_RINIT_FUNCTION to initialize the execution environment of the PHP script. Then, it enters the PHP script execution phase, and the PHP interpreter executes the code in the PHP script to process the request. After the PHP script is executed, it enters the request closing phase and calls PHP_RSHUTDOWN_FUNCTION to clean up the request site and release related resources. It should be noted that every time the PHP interpreter receives a request, it will re-enter the request initialization phase, the PHP script execution phase, and the request closing phase. That is, the PHP interpreter processes the received request by looping through the request initialization phase, the PHP script execution phase, and the request closing phase. After the Web server exits or the process manager is shut down, it enters the module closing phase, calls PHP_RINIT_FUNCTION to clean up resources and close the PHP interpreter, and the life cycle of the PHP interpreter ends.

[0036] In this embodiment, the system key function is the key entry called when the PHP interpreter executes each function, that is, the PHP interpreter will call the function execution through the system key function. Exemplarily, when the PHP interpreter is in the module initialization stage, the system key function of the PHP interpreter is replaced with a target key function encapsulated by the monitoring function and the system key function, so that when the PHP interpreter calls the system key function to execute the first function of the PHP script, it can collect the monitoring data of the first function execution through the monitoring function, and achieve the purpose of seamless access to full-link monitoring of the PHP service without modifying the PHP service code. Among them, the monitoring function is a function used to collect monitoring data when the function is executed. The monitoring data includes the execution result and execution time of the first function, as well as the address, path and issuance time of the request, etc.

[0037] In this embodiment, the PHP script includes multiple first functions, and the first function includes a PHP language function and a C language function, that is, the PHP language function is a function written in the PHP language, and the C language function is a function written in the C language, because there are some high-performance scenarios in the PHP service that need to be implemented in the C language. The C language function is loaded into the PHP interpreter in an extended form, that is, the C language function can be regarded as an extended function of the PHP interpreter. The system key function corresponding to the PHP language function is the first system key function, and the first system key function is the ZEND_EXECUTE_EX function, which is a function in the PHP interpreter for executing the opcode of the PHP language function. In the life cycle of PHP, after the PHP script is parsed and compiled corresponding to the opcodes of the multiple first functions included, the opcodes are stored in the op_array structure, and then the PHP interpreter calls the ZEND_EXECUTE_EX function to traverse and execute the opcodes of the PHP language functions in these first functions. In this regard, the first system key function can be replaced with the first target key function, and the first target key function is encapsulated by the monitoring function and the first system key function, so that if the PHP script executes a PHP language function during execution, the ZEND_EXECUTE_EX function in the first target key function can be called to execute the operation code of the PHP language function, and the monitoring function in the first target key function can be called to collect monitoring data during the execution of the PHP language function, thereby realizing full-link monitoring of the PHP language function.

[0038] The system key function corresponding to the C language function is the second system key function, and the second system key function is the ZEND_EXECUTE_INTERNAL function, which is a function in the PHP interpreter for executing the opcode of the corresponding extended C language function. After the PHP script is parsed and compiled corresponding to the opcodes of the multiple first functions included, the opcodes are stored in the op_array structure, and then the PHP interpreter calls the ZEND_EXECUTE_INTERNAL function to traverse and execute the opcodes of the C language functions in these first functions. In this regard, the second system key function can be replaced with the second target key function, and the second target key function is encapsulated by the monitoring function and the second system key function, so that if the PHP script executes the PHP language function during the execution process, the ZEND_EXECUTE_INTERNAL function in the second target key function can be called to execute the opcode of the C language function, and the monitoring function in the second target key function can be called to collect the monitoring data when the C language function is executed, so as to realize the full-link monitoring of the C language function.

[0039] S120. Allocate the request received by the process manager to the PHP interpreter, so as to execute the corresponding PHP script to process the request through the PHP interpreter, where the PHP script includes a plurality of first functions.

[0040] In this embodiment, the request is a request sent by the client to the PHP service through the Web server. Figure 2 , the web server (such as Nginx or Apache) receives the HTTP request from the client, and the web server forwards the request to the process manager through the FastCGI protocol. The process manager selects an available PHP interpreter process from the process pool to handle the request. The process manager sends the request to the selected PHP interpreter through the SAPI interface, and the PHP interpreter loads the PHP script to be executed for the request. After the PHP interpreter completes the execution of the PHP script, it indicates that the request processing is completed, and returns the processing result of the request to the process manager through the SAPI interface. The process manager returns the processing result to the web server through the FastCGI protocol, and the web server sends the processing result to the client.

[0041] After receiving the request transmitted by the SPAI interface, the PHP interpreter enters the request initialization phase to call PHP_RINIT_FUNCTION to initialize the execution environment of the PHP script, and then enters the PHP script execution phase. In the PHP script execution phase, the PHP script is parsed and compiled into operation codes, and the operation codes are executed by the Zend engine in the PHP interpreter, and the first function contained in the PHP script is executed in sequence. After the PHP script is executed, the request closing phase is entered to call PHP_RSHUTDOWN_FUNCTION to clean up the request site and release related resources.

[0042] S130. After starting to execute the PHP script, obtain the function name of the first function, and match the function name of the first function with the preset function name of the second function.

[0043] Among them, the second function can be understood as the core function in the PHP service. Exemplarily, after entering the PHP script execution phase, before each execution of a first function, the PHP interpreter obtains the function name of the first function to be executed, and matches the function name of the first function with the function name of the preset second function to determine whether the first function is the core function in the PHP script, so that when the first function is determined to be the core function, the monitoring function in the target key function is called to obtain the monitoring data when the core function is executed, and when it is determined that the first function is not the core function, the monitoring function is not called. It can be understood that this embodiment only performs full-link monitoring on the core functions in the PHP service, and the remaining less important functions do not need to be monitored, so as to effectively improve the reliability of monitoring. Moreover, the execution time of the monitoring function will also be occupied when the monitoring function is executed. Therefore, executing the monitoring function only when the core function is executed can also improve the execution efficiency of the PHP script, thereby improving the request processing efficiency.

[0044] In this embodiment, before the PHP interpreter executes the first function, the function name of the first function is obtained through the execution data structure. The execution data structure is an EXECUTE_DATA structure, which is used to store the current execution context during the operation code process of the Zend engine of the PHP interpreter executing the PHP script, that is, the EXECUTE_DATA structure contains a lot of information about the first function to be executed, including the class name, function name and parameters. Therefore, the function name of the first function to be executed can be obtained through the function name attribute in the EXECUTE_DATA structure. It should be noted that if the PHP script contains N first functions, it is necessary to access the EXECUTE_DATA structure N times to obtain the function name of the first function executed each time.

[0045] In one embodiment, the second function includes a file transfer function, a redis database interaction function, a redis database interaction extension function, a database access function, and a MySQL database interaction function. Among them, the file transfer function is a CURL function, which is a function used by the PHP interpreter to call the file transfer tool CURL; the redis database interaction function is a PREDIS function, which is a function written in PHP language used by the PHP interpreter to interact with the redis database; the redis database interaction extension function is PHPREDIS, which is an extension function written in C language used by the PHP interpreter to interact with the redis database; the database access function is a PDO (PHP Data Objects) function, which is a function used by the PHP interpreter to unify the access interfaces of various databases; the MySQL database interaction function is MYSQLI, which is an extension function used by the PHP interpreter to interact with the MySQL database. File transfer function, redis database interaction function, redis database interaction extension function, database access function, and MySQL database interaction function are the main functions run by the PHP service when processing requests. They reflect the working status of the PHP service. Therefore, by collecting monitoring data such as the traffic, execution results, and execution time of these functions, the working status of the PHP service can be accurately analyzed through the collected monitoring data, which is conducive to improving the efficiency and accuracy of locating faulty nodes of the PHP service.

[0046] S140. When the function name of the first function matches the function name of the preset second function, call the system key function in the target key function to execute the first function, and call the monitoring function in the target key function to obtain monitoring data of executing the first function.

[0047] Exemplarily, if the function name of the first function matches the function name of the preset second function, it indicates that the first function is the core function to be monitored in the PHP script. At this time, the system key function in the target key function can be called to execute the first function, and the monitoring function in the target key function can be called to obtain the monitoring data of the first function. If the function name of the first function does not match the function name of the preset second function, it indicates that the first function is not the core function to be monitored in the PHP script. At this time, the monitoring function can be skipped, that is, only the system key function in the target key function can be called to execute the first function.

[0048] In this embodiment, the monitoring data mainly includes the address, path and issuance time of the request and the execution result and execution time of the first function. The address, path and issuance time of the request can be obtained before the execution of the first function, and the execution result and execution time of the first function can be obtained after the execution of the first function. In order to conveniently and quickly obtain these monitoring data, the pre-function is encapsulated in the context of the system-critical function in the target critical system, and the post-function is encapsulated in the context of the system-critical function in the target critical system. The monitoring function in the target critical system includes the pre-function and the post-function, so as to obtain the address, path and issuance time of the request and the execution result and execution time of the first function through the pre-function and the post-function respectively. Exemplarily, Figure 3 This is a flow chart of obtaining monitoring data through a pre-function and a post-function provided in an embodiment of the present application. Figure 3 As shown, the step of obtaining monitoring data through the pre-function and the post-function specifically includes S1401-S1403:

[0049] S1401. Call the predecessor function in the target key function to obtain the address, path and issuance time of the request.

[0050] S1402. Call a system key function in a target key function to execute a first function.

[0051] S1403. After the execution of the first function is completed, the post-function in the target key function is called to obtain the execution result and execution time of the first function.

[0052] Exemplarily, if the first function to be executed is the CURL_EXEC function, which is a core function in the PHP service, the pre-function in the target key function is executed to obtain the address, path and issuance time of the currently processed request. After the execution of the pre-function, the system key function in the target key function is called to execute the CURL_EXEC function, wherein the CURL_EXEC function is a PHP language function, that is, the ZEND_EXECUTE_EX function is called to execute the CURL_EXEC function. After the execution of the CURL_EXEC function, the post-function in the target key function is executed to obtain the execution result and execution time of the CURL_EXEC function. This embodiment realizes full-link monitoring of the core function by accurately obtaining the import and export traffic and execution data of the core function through the pre-function and post-function in the target key function that are located in the context of the system key function.

[0053] In one embodiment, reference Figure 2 In the request initialization phase, the PHP interpreter can call the PHP_REQUEST_STARTUP function to prepare the PHP interpreter to process the current request. In the request closing phase, the PHP interpreter can call the PHP_REQUEST_SHUTDOWN function to perform cleanup work at the end of the request. In order to monitor the inlet traffic of each PHP interpreter and the processing results of the request, the address, path and issuance time of the request can be obtained through the pre-function in the target key function before the PHP interpreter executes the PHP_REQUEST_STARTUP function, and the processing result and processing time of the request can be obtained through the post-function in the target key function after executing the PHP_REQUEST_SHUTDOWN function. Exemplarily, Figure 4 This is a flowchart of obtaining request data through a pre-function and a post-function provided by an embodiment of the present application. Figure 4 As shown, the step of obtaining the request data through the pre-function and the post-function specifically includes S1501-S1504:

[0054] S1501. After the PHP interpreter receives the request, it calls the front-end function to obtain the address, path and sending time of the request.

[0055] Exemplarily, the system key function is also the key entry called when the PHP interpreter executes the PHP_REQUEST_STARTUPPHP_REQUEST_STARTUP function. The PHP_REQUEST_STARTUP function is the first step in the request initialization phase, and the PHP interpreter starts executing after receiving the request. Therefore, after receiving the request, that is, before executing the PHP_REQUEST_STARTUP function, the PHP interpreter can obtain the address, path and sending time of the request received by the current PHP interpreter through the preceding function in the target key function that is above the system key function.

[0056] S1502. Call the system key function in the target key function to execute the request initialization function, where the request initialization function is used to prepare the PHP interpreter to process the currently received request.

[0057] The request initialization function is the PHP_REQUEST_STARTUP function, which can initialize global variables, register built-in functions and classes, load extensions, execute request-specific initialization code, and prepare the execution environment. The PHP_REQUEST_STARTUP function is a PHP language function, and the PHP interpreter can call the ZEND_EXECUTE_EX function to execute the PHP_REQUEST_STARTUP function. After executing the PHP_REQUEST_STARTUP function and other request initialization operations, the PHP interpreter enters the PHP script execution phase to execute the PHP script to process the currently received request.

[0058] S1503. After the PHP interpreter completes processing of the request, a request end function is executed through the system key function in the target key function. The request end function is used to clean up and release the resources of the PHP interpreter.

[0059] Among them, the request end function is the PHP_REQUEST_SHUTDOWN function, which can clean up global variables, destroy objects, close extensions, and execute callbacks when the request ends. After the request processing is completed, that is, after the PHP script is executed, the PHP interpreter enters the request closing stage. In the request closing stage, since the PHP_REQUEST_SHUTDOWN function is a PHP language function, the PHP interpreter can call the ZEND_EXECUTE_EX function to execute the PHP_REQUEST_SHUTDOWN function.

[0060] S1504. Call the post-function in the target key function to obtain the requested processing result and processing time.

[0061] Exemplarily, executing the PHP_REQUEST_SHUTDOWN function is the last step in the request closing phase. Calling the PHP_REQUEST_SHUTDOWN function marks the end of the current request processing flow. Therefore, after executing the PHP_REQUEST_SHUTDOWN function, the post-function in the target key function can be called to obtain the processing result and processing time of the request. This embodiment implements full-link monitoring of the import and export traffic of the PHP interpreter and the request processing status by calling the pre-function to obtain the address, path and issuance time of the request before calling the request initialization function, and calling the post-function to obtain the processing result and processing time of the request after calling the request end function.

[0062] Further, after obtaining the monitoring data, the monitoring data is written into a socket file, and the socket file is sent to a monitoring collector via a unix socket, so that the monitoring collector cleans the monitoring data in the socket file, and reports the cleaned monitoring data to the monitoring terminal. Exemplarily, after obtaining the address, path and issuing time of the request, the pre-function pushes the address, path and issuing time of the request to a socket file (sock file). After obtaining the execution result and execution time of the first function, or the processing result and processing time of the request, the post-function pushes the execution result and execution time of the first function or the processing result and processing time of the request to the socket file. The socket file is sent to the monitoring collector via a unix socket, and the monitoring collector cleans the monitoring data in the socket file. The monitoring terminal pulls the cleaned monitoring data from the monitoring collector according to a certain period, and displays the import and export traffic and execution status of each core function at the front end based on the pulled monitoring data. Wherein, the monitoring collector is implemented by an agent (agent server). It should be noted that in the module initialization stage, the socket file will be initialized to avoid uploading the monitoring data collected last time to the monitoring terminal, causing monitoring anomalies, thereby ensuring the reliability of monitoring of the PHP service. This embodiment can efficiently and low-latency transmit the monitoring data to the monitoring terminal through the unix socket, thereby improving the transmission efficiency of the monitoring data and facilitating the real-time monitoring of the PHP service.

[0063] In summary, the execution function monitoring method provided in the embodiment of the present application replaces the system key function with the target key function after the process manager is started, and the target key function is encapsulated by the monitoring function and the system key function; the request received by the process manager is assigned to the PHP interpreter to execute the corresponding PHP script to process the request through the PHP interpreter, and the PHP script includes multiple first functions; after starting to execute the PHP script, the function name of the first function is obtained, and the function name of the first function is matched with the function name of the preset second function; when the function name of the first function matches the function name of the preset second function, the system key function in the target key function is called to execute the first function, and the monitoring function in the target key function is called to obtain monitoring data of the execution of the first function. Through the above-mentioned technical means, the target key function can replace the system key function that will be called when each function in the PHP service is executed, so as to embed the monitoring function used to collect monitoring data during the execution of the function, so that during the execution of the PHP script, the system key function in the target key function is called before the core function is executed to execute the core function. At the same time, the monitoring data during the execution of the core function is collected through the monitoring function in the target key function. The purpose of seamless access to full-link monitoring of PHP service is achieved without modifying the PHP service code. The technical problem that the core function of PHP service cannot be fully monitored in the prior art is solved, the efficiency of locating faulty nodes is improved, and the stability of back-end business is ensured.

[0064] Based on the above embodiments, Figure 5 This is a schematic diagram of the structure of an execution function monitoring device provided in an embodiment of the present application. Figure 5 The execution function monitoring device provided in this embodiment specifically includes: a key function replacement module 21, a request allocation module 22, a function name matching module 23 and a first monitoring module 24.

[0065] The key function replacement module 21 is configured to replace the system key function with the target key function after the process manager is started, and the target key function is obtained by encapsulating the monitoring function and the system key function;

[0066] The request allocation module 22 is configured to allocate the request received by the process manager to the PHP interpreter so as to execute the corresponding PHP script to process the request through the PHP interpreter, wherein the PHP script includes a plurality of first functions;

[0067] The function name matching module 23 is configured to obtain the function name of the first function after starting to execute the PHP script, and match the function name of the first function with the function name of the preset second function;

[0068] The first monitoring module 24 is configured to call the system key function in the target key function to execute the first function and to call the monitoring function in the target key function to obtain monitoring data of the execution of the first function when the function name of the first function matches the function name of the preset second function.

[0069] On the basis of the above embodiment, the first function includes a PHP language function and a C language function, and the C language function is loaded in the PHP interpreter in an extended form; accordingly, the key function replacement module 21 includes: a first replacement unit, configured to replace the first system key function with a first target key function, the first system key function is a function of the opcode for executing the PHP language function in the PHP interpreter, and the first target key function is encapsulated by the monitoring function and the first system key function; a second replacement unit, configured to replace the second system key function with a second target key function, the second system key function is a function of the opcode for executing the corresponding extended C language function in the PHP interpreter, and the second target key function is encapsulated by the monitoring function and the second system key function.

[0070] Based on the above embodiment, the function name matching module includes: a function name acquisition unit, configured to acquire the function name of the first function by executing the data structure before the PHP interpreter executes the first function.

[0071] Based on the above embodiments, the monitoring function includes a pre-function and a post-function, the pre-function is encapsulated above the system key function, and the post-function is encapsulated below the system key function; accordingly, the first monitoring module includes: a first pre-calling unit, configured to call the pre-function in the target key function to obtain the address, path and issuance time of the request; a first key calling unit, configured to call the system key function in the target key function to execute the first function; a first post-calling unit, configured to call the post-function in the target key function after the execution of the first function is completed to obtain the execution result and execution time of the first function.

[0072] On the basis of the above embodiments, the execution function monitoring device also includes a second monitoring module, which includes: a second pre-calling unit, configured to call the pre-function to obtain the address, path and issuance time of the request after the PHP interpreter receives the request; a second key calling unit, configured to call the system key function in the target key function to execute the request initialization function, and the request initialization function is used to prepare the PHP interpreter to process the currently received request; a third key calling unit, configured to execute the request end function through the system key function in the target key function after the PHP interpreter completes the request processing, and the request end function is used to clean up and release the resources of the PHP interpreter; a second post-calling unit, configured to call the post-function in the target key function to obtain the processing result and processing time of the request.

[0073] Based on the above embodiment, the second function includes a file transfer function, a redis database interaction function, a redis database interaction extension function, a database access function, and a MySQL database interaction function.

[0074] On the basis of the above embodiment, the execution function monitoring device also includes: a monitoring data uploading module, which is configured to write the monitoring data into a socket file after calling the monitoring function in the target key function to obtain the monitoring data of executing the first function, and send the socket file to the monitoring collector through the Unix socket, so that the monitoring collector cleans the monitoring data in the socket file and reports the cleaned monitoring data to the monitoring end.

[0075] As mentioned above, the execution function monitoring device provided by the embodiment of the present application replaces the system key function with the target key function after the process manager is started, and the target key function is encapsulated by the monitoring function and the system key function; the request received by the process manager is assigned to the PHP interpreter to execute the corresponding PHP script processing request through the PHP interpreter, and the PHP script includes multiple first functions; after starting to execute the PHP script, the function name of the first function is obtained, and the function name of the first function is matched with the function name of the preset second function; when the function name of the first function matches the function name of the preset second function, the system key function in the target key function is called to execute the first function, and the monitoring function in the target key function is called to obtain the monitoring data of the execution of the first function. Through the above-mentioned technical means, the target key function can replace the system key function that will be called when each function in the PHP service is executed, so as to embed the monitoring function used to collect monitoring data during the execution of the function, so that during the execution of the PHP script, the system key function in the target key function is called before the core function is executed to execute the core function. At the same time, the monitoring data during the execution of the core function is collected through the monitoring function in the target key function. The purpose of seamless access to full-link monitoring of PHP service is achieved without modifying the PHP service code. The technical problem that the core function of PHP service cannot be fully monitored in the prior art is solved, the efficiency of locating faulty nodes is improved, and the stability of back-end business is ensured.

[0076] The execution function monitoring device provided in the embodiment of the present application can be used to execute the execution function monitoring method provided in the above embodiment, and has corresponding functions and beneficial effects.

[0077] Figure 6 is a schematic diagram of a structure of an execution function monitoring device provided in an embodiment of the present application, with reference to Figure 6 , the execution function monitoring device includes: a processor 31, a memory 32, a communication device 33, an input device 34 and an output device 35. The number of processors 31 in the execution function monitoring device can be one or more, and the number of memories 32 in the execution function monitoring device can be one or more. The processor 31, memory 32, communication device 33, input device 34 and output device 35 of the execution function monitoring device can be connected through a bus or other methods.

[0078] The memory 32, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the execution function monitoring method of any embodiment of the present application (for example, the key function replacement module 21, the request allocation module 22, the function name matching module 23 and the first monitoring module 24 in the execution function monitoring device). The memory 32 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application required for at least one function; the storage data area may store data created according to the use of the device, etc. In addition, the memory 32 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.

[0079] The communication device 33 is used for data transmission.

[0080] The processor 31 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 32, that is, implements the above-mentioned execution function monitoring method.

[0081] The input device 34 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 35 may include a display device such as a display screen.

[0082] The execution function monitoring device provided above can be used to execute the execution function monitoring method provided in the above embodiment, and has corresponding functions and beneficial effects.

[0083] An embodiment of the present application also provides a storage medium containing computer executable instructions, which are used to execute an execution function monitoring method when executed by a computer processor. The execution function monitoring method includes: after the process manager is started, replacing the system critical function with a target critical function, wherein the target critical function is encapsulated by the monitoring function and the system critical function; assigning the request received by the process manager to a PHP interpreter to execute the corresponding PHP script processing request through the PHP interpreter, wherein the PHP script includes multiple first functions; after starting to execute the PHP script, obtaining the function name of the first function, and matching the function name of the first function with the function name of a preset second function; when the function name of the first function matches the function name of the preset second function, calling the system critical function in the target critical function to execute the first function, and calling the monitoring function in the target critical function to obtain monitoring data of the execution of the first function.

[0084] Storage medium - any of various types of memory devices or storage devices. The term "storage medium" is intended to include: installation media, such as CD-ROM, floppy disk or tape device; computer system memory or random access memory, such as DRAM, DDR RAM, SRAM, EDO RAM, Rambus RAM, etc.; non-volatile memory, such as flash memory, magnetic media (such as hard disk or optical storage); registers or other similar types of memory elements, etc. Storage media may also include other types of memory or combinations thereof. In addition, the storage medium may be located in the first computer system in which the program is executed, or may be located in a different second computer system, which is connected to the first computer system via a network (such as the Internet). The second computer system can provide program instructions to the first computer for execution. The term "storage medium" may include two or more storage media residing in different locations (for example, in different computer systems connected by a network). The storage medium may store program instructions (for example, embodied as a computer program) that can be executed by one or more processors.

[0085] Of course, the storage medium containing computer executable instructions provided in the embodiment of the present application, whose computer executable instructions are not limited to the above-mentioned execution function monitoring method, can also execute related operations in the execution function monitoring method provided in any embodiment of the present application.

[0086] The execution function monitoring device, storage medium and execution function monitoring equipment provided in the above embodiments can execute the execution function monitoring method provided in any embodiment of the present application. For technical details not described in detail in the above embodiments, please refer to the execution function monitoring method provided in any embodiment of the present application.

[0087] The above are only preferred embodiments of the present application and the technical principles used. The present application is not limited to the specific embodiments herein, and various obvious changes, readjustments and substitutions that can be made by those skilled in the art will not deviate from the protection scope of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present application, and the scope of the present application is determined by the scope of the claims.

Claims

1. A method for monitoring an execution function, It is characterized in that include: After the process manager is started, the system key function is replaced with a target key function, wherein the target key function is obtained by encapsulating the monitoring function and the system key function; Assigning the request received by the process manager to a PHP interpreter so as to execute a corresponding PHP script through the PHP interpreter to process the request, wherein the PHP script includes a plurality of first functions; After starting to execute the PHP script, obtaining a function name of the first function, and matching the function name of the first function with a preset function name of the second function; When the function name of the first function matches the function name of the preset second function, the system key function in the target key function is called to execute the first function, and the monitoring function in the target key function is called to obtain monitoring data of executing the first function.

2. The execution function monitoring method according to claim 1, It is characterized in that The first function includes a PHP language function and a C language function, and the C language function is loaded in the PHP interpreter in an extended form; Accordingly, replacing the system key function with the target key function includes: Replacing a first system key function with a first target key function, wherein the first system key function is a function of an opcode for executing a PHP language function in the PHP interpreter, and the first target key function is obtained by encapsulating a monitoring function and the first system key function; The second system critical function is replaced with a second target critical function, where the second system critical function is a function of the opcode in the PHP interpreter used to execute the corresponding extended C language function, and the second target critical function is encapsulated by the monitoring function and the second system critical function.

3. The execution function monitoring method according to claim 1, wherein the obtaining the function name of the first function, include: Before the PHP interpreter executes the first function, the function name of the first function is obtained by executing the data structure.

4. The execution function monitoring method according to claim 1, It is characterized in that The monitoring function includes a pre-function and a post-function, wherein the pre-function is encapsulated above the system key function, and the post-function is encapsulated below the system key function; Correspondingly, calling a system key function in the target key function to execute the first function, and calling a monitoring function in the target key function to obtain monitoring data of executing the first function, include: Calling the preceding function in the target key function to obtain the address, path and issuing time of the request; Calling a system key function in the target key function to execute the first function; After the execution of the first function is completed, the post-function in the target key function is called to obtain the execution result and execution time of the first function.

5. The execution function monitoring method according to claim 4, It is characterized in that The method further comprises: After the PHP interpreter receives the request, the front function is called to obtain the address, path and sending time of the request; Calling a system key function in the target key function to execute a request initialization function, wherein the request initialization function is used to prepare the PHP interpreter to process a currently received request; After the PHP interpreter completes processing of the request, a request end function is executed through a system key function in the target key function, and the request end function is used to clean up and release resources of the PHP interpreter; The post-function in the target key function is called to obtain the processing result and processing time of the request.

6. The execution function monitoring method according to claim 1, It is characterized in that The second function includes a file transfer function, a redis database interaction function, a redis database interaction extension function, a database access function, and a MySQL database interaction function.

7. The execution function monitoring method according to claim 1, It is characterized in that After calling the monitoring function in the target key function to obtain the monitoring data of executing the first function, the method further includes: The monitoring data is written into a socket file, and the socket file is sent to a monitoring collector via a Unix socket, so that the monitoring collector cleans the monitoring data in the socket file and reports the cleaned monitoring data to a monitoring terminal.

8. An execution function monitoring device, It is characterized in that include: A key function replacement module is configured to replace the system key function with a target key function after the process manager is started, wherein the target key function is obtained by encapsulating the monitoring function and the system key function; A request allocation module is configured to allocate the request received by the process manager to the PHP interpreter so as to execute a corresponding PHP script through the PHP interpreter to process the request, wherein the PHP script includes a plurality of first functions; A function name matching module is configured to obtain a function name of a first function after starting to execute the PHP script, and match the function name of the first function with a preset function name of a second function; The first monitoring module is configured to call the system key function in the target key function to execute the first function when the function name of the first function matches the function name of the preset second function, and to call the monitoring function in the target key function to obtain monitoring data of the execution of the first function.

9. An execution function monitoring device, It is characterized in that include: one or more processors; A memory stores one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the execution function monitoring method as described in any one of claims 1-7.

10. A storage medium containing computer executable instructions, It is characterized in that The computer executable instructions are used to execute the execution function monitoring method as described in any one of claims 1-7 when executed by a computer processor.