Process monitoring method, device, electronic device and computer readable storage medium
By reading Java virtual machine shared files, determining the current status of the target process, solving the problem of low process monitoring efficiency in the existing technology, and efficient monitoring of Java processes and port information is achieved.
Patent Information
- Application Number
- CN202210582916.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-26
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2042-05-26
AI Technical Summary
In the prior art, process monitoring is low efficiency, it is impossible to effectively monitor the creation and destruction of Java processes, and it is impossible to monitor the port information of the process.
By reading Java virtual machine shared files, determine the current status of the target process, including by comparing the current and cached Java virtual machine shared files, identifying new or missing process files, and determining the process startup status based on port information.
It realizes efficient monitoring of the status of the target process without accessing all running processes, reducing resource and performance requirements, and improving monitoring efficiency.
Smart Images

Figure CN114880190B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a process monitoring method, device, electronic device, and computer-readable storage medium. Background Art
[0002] In the prior art, the monitoring method for a process is generally to scan all current processes of the system and monitor the process in a polling manner, which is inefficient. Summary of the invention
[0003] The purpose of the present application is to provide a process monitoring method, device, electronic device and computer-readable storage medium to improve the deficiencies in process monitoring.
[0004] In a first aspect, an embodiment of the present application provides a process monitoring method, comprising: reading a current Java virtual machine shared file, wherein the current Java virtual machine shared file stores the current state of a started process; and determining the current state of a target process based on the current Java virtual machine shared file.
[0005] Optionally, determining the current state of the target process based on the current Java virtual machine shared file includes: comparing the current Java virtual machine shared file with the most recently stored Java virtual machine shared file in the cache to determine the current state of the target process.
[0006] Optionally, determining the current state of the target process based on the current Java virtual machine shared file includes: comparing the current Java virtual machine shared file with the most recently stored Java virtual machine shared file in the cache; if it is determined that the current Java virtual machine shared file has a newly added process file compared to the Java virtual machine shared file in the cache; based on the newly added process file, determining the port address of the target process corresponding to the newly added process file; and determining the current state of the target process based on the port information in the port address.
[0007] Optionally, determining the current state of the target process based on the port information in the port address includes: searching for port information in the port address; if the port information of the target process is found in the port address, determining that the current state of the target process is successful startup.
[0008] Optionally, the method further includes: if the current state of the target process is successful startup, performing instrumentation protection on the target process.
[0009] Optionally, the current state of the process file includes that the process file is missing in the current Java virtual machine shared file, and determining the current state of the target process based on the current Java virtual machine shared file includes: comparing the current Java virtual machine shared file with the most recently stored Java virtual machine shared file in the cache; if it is determined that the current Java virtual machine shared file has a missing process file compared to the Java virtual machine shared file in the cache; if the current state of the process file is missing in the current Java virtual machine shared file, determining that the current state of the target process corresponding to the missing process file is a destroyed state.
[0010] Optionally, the method further includes: if the current state of the target process is a destroyed state, controlling the target process to restart.
[0011] Optionally, applied to an electronic device, the method also includes: determining process information of a currently running process based on the current Java virtual machine shared file; determining a first memory occupied by the currently running process based on the process information; comparing the first memory with the total memory of the electronic device to determine whether there is a memory usage abnormality in the running process; if it is determined that there is a memory usage abnormality in the running process, outputting an alarm prompt for the memory usage abnormality.
[0012] Optionally, the method further includes: when the target process is started, registering with the Java virtual machine shared file to form a process file of the target process in the Java virtual machine shared file.
[0013] In a second aspect, an embodiment of the present application provides a process monitoring device, including: a reading module for reading a current Java virtual machine shared file; and a determination module for determining a current state of a target process based on the current Java virtual machine shared file.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the machine-readable instructions are executed by the processor to perform the steps of the above method.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are executed.
[0016] In the process monitoring method, device, electronic device and computer-readable storage medium of the embodiment of the present application, the state of the target process to be understood can be determined without accessing all running processes. The resource and performance requirements for process monitoring can be reduced, and the monitoring efficiency can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A block diagram of an electronic device provided in an embodiment of the present application;
[0019] Figure 2 A flowchart of a process monitoring method provided in an embodiment of the present application;
[0020] Figure 3 A partial flow chart of a process monitoring method provided in an embodiment of the present application;
[0021] Figure 4 A schematic diagram of the functional modules of a process monitoring device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings in the embodiments of the present application.
[0023] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0024] For the security of Java servers, it is usually necessary to monitor the programs running in the Java servers to increase the understanding of the usage of the Java servers, thereby improving the security of the Java servers. Most of the existing technologies scan all current processes in the system, and then poll and monitor according to specific characters or ports to parse the creation and destruction of Java processes. This processing method has low performance.
[0025] The inventors learned that the tools for monitoring processes include the Linux ps tool, which is used to query all processes and then perform keyword filtering, which is inefficient and cannot monitor the destruction of Java processes. Another tool for monitoring processes is the JVM jps tool, which is used to monitor the creation of Java processes. For example, the JVM jps tool can list the running Java processes, but the JVM jps tool cannot monitor the destruction status of the Java process and cannot monitor the port information of the process.
[0026] Based on the above situation, the present application provides a process monitoring method, which uses the Java sharing mechanism, does not rely on port and character information, can independently check the creation and destruction of Java processes, and can also perform port binding without traversing all processes in the system, which can greatly improve efficiency. The following introduces the process monitoring method and products related to the process monitoring method through some embodiments.
[0027] To facilitate understanding of this embodiment, first, an electronic device that executes the process monitoring method disclosed in the embodiment of the present application is introduced in detail.
[0028] like Figure 1 , which is a block diagram of an electronic device. The electronic device 100 may include a memory 111 and a processor 113. A person skilled in the art may understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the electronic device 100. For example, the electronic device 100 may further include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0029] The memory 111 and the processor 113 are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these elements can be electrically connected to each other via one or more communication buses or signal lines. The processor 113 is used to execute the executable module stored in the memory.
[0030] The memory 111 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 111 is used to store programs, and the processor 113 executes the program after receiving the execution instruction. The method executed by the electronic device 100 defined by the process disclosed in any embodiment of the present application can be applied to the processor 113, or implemented by the processor 113.
[0031] The processor 113 may be an integrated circuit chip with signal processing capability. The processor 113 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or a processor.
[0032] Field Programmable Gate Array, referred to as FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0033] The electronic device 100 in this embodiment can be used to execute each step in each method provided in the embodiments of the present application. The implementation process of the process monitoring method is described below through several embodiments.
[0034] See also Figure 2 , is a flow chart of a process monitoring method provided in an embodiment of the present application. The process monitoring method in this embodiment can be applied to an electronic device, in which each step of the process monitoring method can be implemented by running a monitoring process. Figure 2 The specific process shown is explained below.
[0035] Step 210, read the current Java virtual machine shared file.
[0036] The current Java virtual machine shared file stores the current status of the started process. The process files related to each process can be used to determine the current status of the process. The current status of the process may include a successful startup status, a running status, a destroyed status, etc.
[0037] When any Java process is started, it is registered with the Java Virtual Machine (JVM) shared file to generate a process file related to the Java process in the Java Virtual Machine shared file. The Java Virtual Machine shared file can also be called a JVM shared file.
[0038] In one example, the Java virtual machine shared file may be in the path / tmp / hsperfdata_$username / . The process file related to the Java process generated by the Java virtual machine shared file may be a file with process information, and the process file may be a pid file.
[0039] The status of each process can be determined by the file changes in the Java virtual machine shared file.
[0040] Optionally, the Java virtual machine shared file can be read according to a set time rule. Exemplarily, the set time rule can be every specified time length. The specified time length can be 1s, 2s, 3s, etc., and the specified time length can also be 100ms, 50ms, etc. The specified time length can be set according to actual needs.
[0041] Optionally, the obtained Java virtual machine shared files can be stored in a cache. Exemplarily, the cache can only store the latest obtained Java virtual machine shared files. After obtaining the latest Java virtual machine shared files, the latest Java virtual machine shared files can be used to overwrite the Java virtual machine shared files currently stored in the cache.
[0042] Step 220: Determine the current state of the target process based on the current Java virtual machine shared file.
[0043] The target process may be any process that needs to be monitored, for example, the target process may be a newly started Java process, or may be one or more Java processes currently running.
[0044] In one implementation, the current state of the process file of the target process may be determined based on the current Java virtual machine shared file; and the current state of the target process may be determined based on the current state of the process file of the target process.
[0045] The current state of the process file of the target process can be determined from the current Java virtual machine shared file. The current state of the process file can be: newly added to the Java virtual machine shared file, disappeared from the Java virtual machine shared file, the process file has sent changes, etc. Exemplarily, by comparing the current Java virtual machine shared file with the latest Java virtual machine shared file stored in the cache, the difference between the current Java virtual machine shared file and the latest Java virtual machine shared file stored in the cache can be determined, and the current state of the process file of the target process can be determined based on the difference.
[0046] Exemplarily, if it is determined that the current Java virtual machine shared file has a new process file compared to the latest Java virtual machine shared file stored in the cache, that is, the latest Java virtual machine shared file stored in the cache does not have the process file of the target process, but the current Java virtual machine shared file does have the process file of the target process, the current status of the process file can be determined as being newly added to the current Java virtual machine shared file.
[0047] Exemplarily, if it is determined that the current Java virtual machine shared file has a missing process file compared to the most recent Java virtual machine shared file stored in the cache, that is, the most recent Java virtual machine shared file stored in the cache contains the process file of the target process, but the most recently read current Java virtual machine shared file does not have the process file of the target process, the current status of the process file can also be determined as missing in the current Java virtual machine shared file.
[0048] Exemplarily, the current state of the process file may also be other states besides being added or missing. For example, the process file in the current Java virtual machine shared file has changed compared to the process file in the Java virtual machine shared file that is most recently stored in the cache. For example, some new record files are added to the process file in the current Java virtual machine shared file, or some new records are added to the record file in the process file in the current Java virtual machine shared file.
[0049] Exemplarily, the target process may be a process that needs to be started currently. If the current state of the process file of the target process is newly added to the current Java virtual machine shared file, it can be determined that the current state of the target process is the currently started state.
[0050] Exemplarily, if the current state of the process file includes that the process file is missing in the current Java virtual machine shared file, it can be determined that the current state of the target process is a destroyed state.
[0051] Through the above steps, the state of the target process that needs to be understood can be determined without accessing all running processes, which can reduce the resource and performance requirements for process monitoring and improve monitoring efficiency.
[0052] When a Java process is started, a process file with process information is generated in the Java virtual machine shared file and a request is made to the operating system to open a port to complete the process startup. However, inevitably after the process is started, a new process file is added to the Java virtual machine shared file, but the process fails to successfully apply for the port to be opened, which may also cause the process startup to fail. In order to more accurately determine whether the Java process is successfully started, the port of the target process can be identified.
[0053] In an optional implementation, step 220 may include: step 221 , step 222 , and step 223 .
[0054] Step 221, comparing the current Java virtual machine shared file with the most recently stored Java virtual machine shared file in the cache.
[0055] Step 222, determining the port address of the target process corresponding to the newly added process file.
[0056] The port address of the target process can be determined based on the file name of the process file. In one example, the name of the process file of the target process can be "123", and the port address of the target process can be / proc / 123 / fd. The / proc / 123 / fd directory contains the link of each file opened by the target process.
[0057] Step 223, determining the current state of the target process according to the port information in the port address.
[0058] The port information in the port address determines whether the target process is successfully started. If the target process is successfully started, the port information in the port address can include the port information of the target process.
[0059] Step 223 may be implemented as follows: searching the port address for port information; if the port information of the target process is found in the port address, determining that the current state of the target process is successfully started.
[0060] Exemplarily, the port information can be the target port name. The target port name of the target process can be determined based on the process file, and a search can be conducted to determine whether there is a port with the target port name among the started ports. If so, the current state of the target process is a successful startup state.
[0061] In the above implementation, not only is it checked whether there is a process file of the newly started target process in the Java virtual machine shared file, but it is also checked whether the target process successfully applies to the operating system for port opening, so as to more accurately determine whether the target process is successfully started.
[0062] In order to avoid the target process protection window period being too long, after determining that the target process is successfully started, the target process can be protected. Optionally, if the current state of the target process is successful startup, the process monitoring method of the embodiment of the present application can also include: performing plugging protection on the target process.
[0063] Among them, stub insertion refers to inserting probes into the original program corresponding to the target process on the basis of ensuring the logical integrity of the original program corresponding to the target process. The code segment is inserted at a specific location by collecting information in the code through the probe, thereby collecting dynamic context information when the program is running, so as to achieve protection for the target process.
[0064] The content of the instrumentation may be different depending on the function of the target process. The instrumentation content and the instrumentation function may be designed according to the actual usage scenario.
[0065] The implementation method of the plugging protection can be selected according to the requirements, and the embodiment of the present application is not limited to the implementation method of the plugging protection. For example, the implementation method of the plugging protection can be any method such as AspectJ, ASM or ReDex.
[0066] By performing instrumentation protection on successfully started processes, the protection window period can be reduced, allowing for rapid protection and improving the security of process operation.
[0067] In order to avoid the target process being accidentally destroyed during operation, resulting in the task to be executed being interrupted for too long, if the current state of the target process is a destroyed state, the process monitoring method of the embodiment of the present application may further include: controlling the target process to restart.
[0068] After the target process is controlled to restart, it can be determined whether the target process is successfully restarted through steps 210 to 220, and steps 221 to 223. The determination process of whether the target process is successfully restarted can refer to the description in the previous steps, which will not be repeated here.
[0069] Optionally, if the current state of the target process is a destroyed state, the process monitoring method of the embodiment of the present application may further include: outputting an alarm prompt that the target process is destroyed.
[0070] The target process being destroyed may be in the form of an alarm such as a voice alarm, an animation alarm or a text alarm.
[0071] The content of the alarm prompt of the target process being destroyed may include: the target process is abnormally closed or the target process has an abnormality.
[0072] Before restarting the destroyed target process, it can be determined whether the target process was accidentally destroyed or actively closed by the user. Therefore, it can be determined whether the target process received a shutdown instruction before being destroyed. If a shutdown instruction for the process is received, it is determined that the process is closed normally; if the shutdown instruction for the process is not received, and the process file of the target process in the current Java virtual machine shared file disappears, it is determined that the target process is abnormally destroyed. When it is determined that the target process is abnormally destroyed, the step of controlling the restart of the target process or outputting an alarm prompt that the target process is destroyed is executed.
[0073] By restarting or alarming the abnormally closed process in time, the process can be restarted quickly, which can effectively reduce the situation of task suspension caused by the mistaken destruction of the process. Furthermore, it can also judge whether the process is closed normally, so as to avoid mistakenly restarting the normally closed process.
[0074] As the number of running processes increases, the electronic device may consume too much resources or fail to meet the resources required by the currently running processes. Therefore, the amount of resources required by the currently running processes can also be monitored. Figure 3 As shown, the process monitoring method may further include:
[0075] Step 230, determining the process information of the currently running process according to the current Java virtual machine shared file.
[0076] Exemplarily, the process information of each running process may be determined by reading the content in each process file.
[0077] The process information is determined in the directories contained in the process file, and the directories contained in the process file may include: / proc / pid / cmdline, / proc / pid / cwd, / proc / pid / environ, / proc / pid / exe, / proc / pid / fd / , / proc / pid / mem, / proc / pid / stat and / proc / pid / statm.
[0078] Among them, / proc / pid / cmdline contains the command used to start the process; / proc / pid / cwd contains a link to the current process's working directory; / proc / pid / environ contains a list of available process environment variables; / proc / pid / exe contains links to programs running in the process; / proc / pid / fd / contains links to every file opened by the process; / proc / pid / mem contains the contents of the process in memory; / proc / pid / stat contains status information about the process; / proc / pid / statm contains memory usage information for the process.
[0079] The process information may include memory usage information of the process, contents in the memory, program links running in the process, etc.
[0080] Step 240: Determine the first memory occupied by the currently running process according to the process information.
[0081] The first memory can be obtained by calculating the sum of the memory occupied by all running processes.
[0082] Step 250, comparing the first memory with the total memory of the electronic device to determine whether there is any abnormal memory usage of the running process.
[0083] The upper limit of the process memory ratio can be preset. If the ratio of the first memory occupied by the process to the total memory exceeds the upper limit of the memory ratio, it is determined that the running process has a memory occupancy abnormality. Exemplarily, the upper limit of the memory ratio can be 1 / 10, 1 / 5, 1 / 3, etc.
[0084] Taking the example that the upper limit of the memory usage can be 1 / 5, for example, if the total memory of the electronic device is 8G, and the first memory is 2G, then it can be determined that the running process has memory usage abnormalities; for another example, if the first memory is 1G, then it can be determined that the running process does not have memory usage abnormalities.
[0085] If it is determined that the running process has a memory usage abnormality, step 270 is executed.
[0086] Step 260: Output an alarm prompt indicating abnormal memory usage.
[0087] The alarm prompt of the abnormal memory usage can be in the form of any form of alarm such as voice alarm, animation alarm or text alarm.
[0088] The alarm prompt of abnormal memory usage may include: insufficient memory or high memory usage.
[0089] By monitoring the memory usage of the process, the memory usage can be reminded in time, so that the user can understand the operation of the electronic device and improve the safety of the operation of the electronic device.
[0090] Based on the same application concept, the embodiment of the present application also provides a process monitoring device corresponding to the process monitoring method. Since the principle of solving the problem by the device in the embodiment of the present application is similar to that of the aforementioned process monitoring method embodiment, the implementation of the device in this embodiment can refer to the description in the embodiment of the above method, and the repeated parts will not be repeated.
[0091] See also Figure 4 , is a functional module diagram of a process monitoring device provided in an embodiment of the present application. Each module in the process monitoring device in this embodiment is used to execute each step in the above method embodiment. The process monitoring device includes: a reading module 310 and a determination module 320; wherein the contents of each module are as follows:
[0092] The reading module 310 is used to read the current Java virtual machine shared file;
[0093] The determination module 320 is used to determine the current state of the target process based on the current Java virtual machine shared file.
[0094] In a possible implementation, the determination module 320 is used to compare the current Java virtual machine shared file with the most recently stored Java virtual machine shared file in the cache to determine the current state of the target process.
[0095] In one possible implementation, the determination module 320 is used to: compare the current Java virtual machine shared file with the most recently stored Java virtual machine shared file in the cache; if it is determined that the current Java virtual machine shared file has a newly added process file compared to the Java virtual machine shared file in the cache; based on the newly added process file, determine the port address of the target process corresponding to the newly added process file; and based on the port information in the port address, determine the current state of the target process.
[0096] In a possible implementation, the determination module 320 is further used to: search for port information in the port address; if the port information of the target process is found in the port address, determine that the current state of the target process is successful startup.
[0097] In a possible implementation manner, the process monitoring device in this embodiment may further include: an instrumentation module, which is used to perform instrumentation protection on the target process if the current state of the target process is successful startup.
[0098] In one possible implementation, the determination module 320 is also used to: compare the current Java virtual machine shared file with the most recently stored Java virtual machine shared file in the cache; if it is determined that the current Java virtual machine shared file has a missing process file compared to the Java virtual machine shared file in the cache; if the current state of the process file is missing from the current Java virtual machine shared file, determine that the current state of the target process corresponding to the missing process file is a destroyed state.
[0099] In a possible implementation manner, the process monitoring device in this embodiment may further include: a restart module, which is used to control the target process to restart if the current state of the target process is a destroyed state.
[0100] In one possible implementation, applied to an electronic device, the process monitoring device in this embodiment may also include: a prompt module, used to determine the process information of the currently running process based on the current Java virtual machine shared file; determine the first memory occupied by the currently running process based on the process information; compare the first memory with the total memory of the electronic device to determine whether there is a memory usage abnormality in the running process; if it is determined that the running process has a memory usage abnormality, output an alarm prompt of the memory usage abnormality.
[0101] In a possible implementation manner, the registration module is used to register with the Java virtual machine shared file when the target process is started, so as to form a process file of the target process in the Java virtual machine shared file.
[0102] In addition, an embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the process monitoring method described in the above method embodiment are executed.
[0103] The computer program product of the process monitoring method provided in the embodiment of the present application includes a computer-readable storage medium storing program code, and the instructions included in the program code can be used to execute the steps of the process monitoring method described in the above method embodiment. Please refer to the above method embodiment for details, which will not be repeated here.
[0104] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0105] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0106] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk. It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variation thereof are intended to cover non-exclusive inclusion, so that a process, method, article or apparatus that includes a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or apparatus. In the absence of more restrictions, the elements defined by the sentence "includes..." do not exclude the presence of other identical elements in the process, method, article or apparatus that includes the elements.
[0107] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0108] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A process monitoring method, It is characterized in that include: Reading a current Java virtual machine shared file, wherein the current Java virtual machine shared file stores a current state of a started process; Determining the current state of the target process based on the current Java virtual machine shared file includes: comparing the current Java virtual machine shared file with the most recently stored Java virtual machine shared file in the cache; If it is determined that the current Java virtual machine shared file has a new process file compared to the Java virtual machine shared file in the cache; based on the new process file, determine the port address of the target process corresponding to the new process file; based on the port information in the port address, determine the current state of the target process.
2. The method according to claim 1, It is characterized in that Determining the current state of the target process according to the port information in the port address includes: Searching the port address for port information; If the port information of the target process is searched in the port address, it is determined that the current state of the target process is successful startup.
3. The method according to claim 2, It is characterized in that The method further comprises: If the current state of the target process is successful startup, the target process is instrumented for protection.
4. The method according to claim 1, It is characterized in that The current state of the process file includes that the process file is missing in the current Java virtual machine shared file, and the determining the current state of the target process based on the current Java virtual machine shared file includes: Comparing the current Java virtual machine shared file with the most recently stored Java virtual machine shared file in the cache; If it is determined that the current Java virtual machine shared file has a missing process file compared to the Java virtual machine shared file in the cache; If the current state of the process file is missing from the current Java virtual machine shared file, it is determined that the current state of the target process corresponding to the missing process file is a destroyed state.
5. The method according to claim 4, It is characterized in that The method further comprises: If the current state of the target process is a destroyed state, the target process is controlled to restart.
6. The method according to claim 1, It is characterized in that Applied to electronic equipment, the method further includes: Determine the process information of the currently running process according to the current Java virtual machine shared file; Determine, according to the process information, a first memory occupied by the currently running process; Comparing the first memory with the total memory of the electronic device to determine whether there is an abnormal memory usage of the running process; If it is determined that the running process has abnormal memory usage, an alarm prompt of the abnormal memory usage will be output.
7. The method according to any one of claims 1 to 6, It is characterized in that The method further comprises: When the target process is started, register it with the Java virtual machine shared file so that the Java virtual machine shared file forms the process file of the target process.
8. A process monitoring device, Characterized in that, It includes: A reading module for reading the current Java virtual machine shared file; A determination module for determining the current state of the target process based on the current Java virtual machine shared file; Wherein, the determination module is further configured to compare the current Java virtual machine shared file with the latest stored Java virtual machine shared file in the cache; if it is determined that there is a newly added process file in the current Java virtual machine shared file compared to the Java virtual machine shared file in the cache; according to the newly added process file, determine the port address of the target process corresponding to the newly added process file; according to the port information in the port address, determine the current state of the target process.
9. An electronic device, Characterized in that, It includes: A processor and a memory, the memory stores machine-readable instructions executable by the processor, and when the electronic device runs, the machine-readable instructions are executed by the processor to perform the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, Characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, it performs the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for monitored progress
CN104461830A
Process monitoring method and system, terminal and storage medium
CN111913851A