Method for extracting and verifying process key information
Patent Information
- Application Number
- CN202310858284.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-13
- Publication Date
- 2025-01-14
AI Technical Summary
[0004]如上所述,进程是一个状态变化的过程,如何判断进程运行过程中是否正常,给网络运维带来了不可预估的工作量,传统的验证往往通过telnet和ssh登录到指定设备上采集一些数据,来验证其进程正常性,全程都需要人为参与,需要登录到设备上查看cpu、mem,查看进程启动时间、启动方式、以及父子进程关系,对数据需要进行人工核对,过度依赖人工,耗时耗力、准确性也无法保证
1、有效解决了传统的系统资源分析过程只监控整机资源的弊端,以及全程需要人工参与,对数据的准确性、实时性校验需要人为核对,过程冗长耗时且过度依赖人工分析等一系列问题。
Smart Images

Figure FT_1
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network communication, and in particular to a method for extracting and verifying key process information. Background Art
[0002] With the rapid development of Internet technology, the Internet is ubiquitous and inseparable in our lives. Stable and reliable communication networks have become the most important infrastructure supporting today's society.
[0003] Communication equipment and servers are basically composed of software, hardware and operating systems. The main task of the operating system is to manage software and hardware resources. When our application runs, it will be loaded into the memory to form a process. The process includes the code and data of the application and the related data structure that maintains the process. Therefore, the underlying communication between networks still relies on the services provided by the process.
[0004] As mentioned above, a process is a process of state change. How to judge whether the process is normal during operation brings unpredictable workload to network operation and maintenance. Traditional verification often logs in to the specified device through telnet and ssh to collect some data to verify the normality of the process. The whole process requires human participation. It is necessary to log in to the device to check the CPU, MEM, process start time, start method, and parent-child process relationship. The data needs to be manually checked. Over-reliance on manual labor is time-consuming and labor-intensive, and accuracy cannot be guaranteed.
[0005] As communication equipment and servers increase in number during the development of communication networks, operation and maintenance personnel face hundreds of machines every day, which brings a lot of workload to them. The inspection process is cumbersome, and the presentation of the results of the collected data is also particularly important. It is extremely important to have accurate and real-time statistical information for all devices and automatic prompts when abnormalities occur in network equipment operation and maintenance. Summary of the invention
[0006] To solve the above problems, the present invention proposes a method for extracting and verifying key process information. The method monitors the software process under the Linux system, extracts process-related information, and also counts the monitoring of the CPU and memory information of the whole machine, and then performs corresponding calculations to obtain accurate values, and compares the difference with the normal value, presents the summary results and prompts abnormal devices, which further facilitates operation and maintenance personnel to monitor important system resources.
[0007] The specific steps are as follows: Step 1: Based on the Linux system operation commands, the detailed information of each process is counted. The statistical information includes child process pid, parent process ppid, start time lstart, run time etime, run command command, total cpu utilization, idle cpu-id, total memory mem, and idle memory mem-id.
[0008] Step 2: Use the ps -eo pid, ppid, comm, lstart, and etime commands to obtain the corresponding process information. Extract the useful processes from the generated information and assign them to the variables that display the results. During this process, compare the pid and ppid values. If pid is greater than ppid and the difference is greater than 1, it means that ppid actively participates in the reset operation of pid, and abnormal is displayed when the final result is presented.
[0009] Step 3: Use the top -n 2 -d 2 command to obtain the device and process usage. Filter the collected data by process name to obtain the CPU usage and mem usage currently occupied by the corresponding process. It is often difficult to find and analyze problems in advance by obtaining the usage information of a single process. In this case, you can obtain the CPU and mem usage of the entire device based on the collected data. Due to the inconsistency of operating systems, the results obtained may be different. Currently, the collected data is classified and counted. For example, when counting the CPU usage and idle rate, the collected data has obvious % characters. After segmentation by %, the value before % is the CPU idle rate. The accurate CPU usage rate can be obtained by subtracting the idle rate from 100. For example, when counting the CPU usage and idle rate, the collected data is represented by numbers and spaces. After segmenting the collected idle rate by character i and then stripping the spaces, the obtained idle rate is calculated by the float function to ensure that it is a floating point number. Then, the accurate CPU usage rate can be obtained by subtracting the idle rate from 100. If the CPU usage rate exceeds 90%, the final result will be displayed as abnormal.
[0010] Step 4: CPU usage has been optimized, and memory usage should also be presented accordingly. If the data collected during mem usage has obvious k representing 1024, then when matching the corresponding memory usage, the field should be matched and stripped, and the corresponding accurate memory usage should be calculated by dividing it by the total memory; if there is no obvious character in the usage, the corresponding value is extracted and directly divided by the total memory to calculate the corresponding usage. If the mem usage exceeds 90%, abnormal will be displayed in the last column of the final presentation result.
[0011] Step 5: At present, based on the collected data, you can intuitively see which machine is abnormal. The data content includes the hostip of the machine, the CPU usage of the whole machine, the CPU usage of the process, the memory usage of the whole machine, the memory usage of the process, the child process id, the parent process id, the child process running time, the parent process running time, the process startup parameters, and the result judgment. If there is corresponding monitoring image software, you can add the acquired numerical type collection items to the corresponding monitoring items, which makes it more convenient to intuitively observe the situation of the entire process of the process.
[0012] Compared with the prior art, the technical solution of the present invention has the following significant beneficial effects: 1. It effectively solves the drawbacks of the traditional system resource analysis process, which only monitors the resources of the entire machine, requires manual participation throughout the process, requires manual verification of the accuracy and real-time verification of the data, and the process is lengthy and time-consuming and overly dependent on manual analysis.
[0013] 2. The data collected by the present invention can be associated with conventional monitoring software on the market and can be used for plotting and displaying by the monitoring software, making it more convenient for operation and maintenance personnel to monitor abnormal processes. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The drawings are not intended to be drawn to scale. In the drawings, each identical or nearly identical component shown in various figures may be represented by the same reference numeral. For clarity, not every component is labeled in every figure. Embodiments of various aspects of the present invention will now be described by way of example and with reference to the accompanying drawings, in which: Figure 1 The present invention provides a flowchart of a method for extracting and verifying key process information. DETAILED DESCRIPTION
[0015] In order to make the purpose and technical solution of the present disclosure more clearly understood, the present disclosure is further elaborated in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0016] The flowchart of a method for extracting and verifying key process information of the present invention is as follows: Figure 1 This method monitors the software process under the Linux system, extracts process-related information, and also counts the monitoring of the CPU and memory information of the entire device, and then performs corresponding calculations to obtain accurate values, and compares the difference with the normal value, presents the summary results and prompts abnormal devices.
[0017] The specific steps are as follows: Step 1: Based on the Linux system operation commands, the detailed information of each process is counted. The statistical information includes child process pid, parent process ppid, start time lstart, run time etime, run command command, total cpu utilization, idle cpu-id, total memory mem, and idle memory mem-id.
[0018] Step 2: Use the ps -eo pid, ppid, comm, lstart, and etime commands to obtain the corresponding process information. Extract the useful processes from the generated information and assign them to the variables that display the results. During this process, compare the pid and ppid values. If pid is greater than ppid and the difference is greater than 1, it means that ppid actively participates in the reset operation of pid, and abnormal is displayed when the final result is presented.
[0019] Step 3: Use the top -n 2 -d 2 command to obtain the device and process usage. Filter the collected data by process name to obtain the CPU usage and mem usage currently occupied by the corresponding process. It is often difficult to find and analyze problems in advance by obtaining the usage information of a single process. In this case, you can obtain the CPU and mem usage of the entire device based on the collected data. Due to the inconsistency of operating systems, the results obtained may be different. Currently, the collected data is classified and counted. For example, when counting the CPU usage and idle rate, the collected data has obvious % characters. After segmentation by %, the value before % is the CPU idle rate. The accurate CPU usage rate can be obtained by subtracting the idle rate from 100. For example, when counting the CPU usage and idle rate, the collected data is represented by numbers and spaces. After segmenting the collected idle rate by character i and then stripping the spaces, the obtained idle rate is calculated by the float function to ensure that it is a floating point number. Then, the accurate CPU usage rate can be obtained by subtracting the idle rate from 100. If the CPU usage rate exceeds 90%, the final result will be displayed as abnormal.
[0020] Step 4: CPU usage has been optimized, and memory usage should also be presented accordingly. If the data collected during mem usage has obvious k representing 1024, then when matching the corresponding memory usage, the field should be matched and stripped, and the corresponding accurate memory usage should be calculated by dividing it by the total memory; if there is no obvious character in the usage, the corresponding value is extracted and directly divided by the total memory to calculate the corresponding usage. If the mem usage exceeds 90%, abnormal will be displayed in the last column of the final presentation result.
[0021] Step 5: At present, based on the collected data, you can intuitively see which machine is abnormal. The data content includes the hostip of the machine, the CPU usage of the whole machine, the CPU usage of the process, the memory usage of the whole machine, the memory usage of the process, the child process id, the parent process id, the child process running time, the parent process running time, the process startup parameters, and the result judgment. If there is corresponding monitoring image software, you can add the acquired numerical type collection items to the corresponding monitoring items, which makes it more convenient to intuitively observe the situation of the entire process of the process.
[0022] Various aspects of the present invention are described in this disclosure with reference to the accompanying drawings, in which many illustrative embodiments are shown. The embodiments of the present disclosure are not necessarily defined to include all aspects of the present invention. It should be understood that the various concepts and embodiments introduced above, as well as those described in more detail below, can be implemented in any of many ways, because the concepts and embodiments disclosed by the present invention are not limited to any implementation. In addition, some aspects disclosed by the present invention can be used alone, or in any appropriate combination with other aspects disclosed by the present invention.
[0023] Although the present invention has been disclosed as above with preferred embodiments, it is not intended to limit the present invention. A person with ordinary knowledge in the technical field to which the present invention belongs may make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be determined by the definition of the claims.
Claims
1. A method for extracting and verifying key process information, characterized in that: The method monitors the software process under the Linux system, extracts process-related information, and also counts the data of the CPU and memory information of the whole device, performs corresponding calculations to obtain accurate values, and compares the differences with normal values, presents summary results and prompts abnormal devices, further facilitating operation and maintenance personnel to monitor important system resources; The specific steps are as follows: Step 1: Count the detailed information of each process based on the Linux system operation command. The statistical information includes child process pid, parent process ppid, start time lstart, run time etime, run command command, total CPU utilization, idle CPU-id, total memory mem, and idle memory mem-id; Step 2: Use the ps -eo pid, ppid, comm, lstart, and etime commands to obtain the corresponding process information. Extract the useful processes from the generated information and assign them to the variables that display the results. During this process, compare the pid and ppid values. If pid is greater than ppid and the difference is greater than 1, it means that ppid actively participates in the reset operation of pid, and abnormal is displayed in the final presentation of the results. Step 3: Use the top -n 2 -d 2 command to obtain the device and process usage. Filter the collected data according to the process name to obtain the CPU usage and mem usage currently occupied by the corresponding process. It is often impossible to find and analyze problems in advance when obtaining the usage information of a single process. In this case, the CPU and mem usage of the entire device can be obtained based on the collected data. Due to inconsistent operating systems, the results obtained may be different. Currently, the collected data is classified and counted. For example, when counting the CPU usage and idle rate, the collected data has obvious % characters. After the % division, the value before % is the CPU idle rate. The accurate CPU usage can be obtained by subtracting the idle rate from 100. If the collected data is represented by numbers and spaces when counting the CPU usage and idle rate, the character i in the collected idle rate is divided and then the spaces are stripped. The obtained idle rate is calculated by the float function to ensure that it is a floating point number. The accurate CPU usage can be obtained by subtracting the idle rate from 100. If the CPU usage exceeds 90%, the final result will be displayed as abnormal. Step 4: CPU usage is optimized, and memory usage should also be presented accordingly; if the data collected during mem usage has obvious k representing 1024, then when matching the corresponding memory usage, the field should be matched and stripped, and then the corresponding accurate memory usage should be calculated by dividing it by the total memory; if there is no obvious character in the usage, the corresponding value is extracted and directly divided by the total memory to calculate the corresponding usage; if the mem usage exceeds 90%, abnormal will be displayed in the last column of the final presentation result; Step 5: At present, based on the collected data, you can intuitively see which machine is abnormal. The data contents are the machine's hostip, the whole machine's CPU usage, the process's CPU usage, the whole machine's memory usage, the process's memory usage, the child process id, the parent process id, the child process running time, the parent process running time, the process startup parameters, and the result judgment; if there is corresponding monitoring image software, you can add the acquired numerical type collection items to the corresponding monitoring items, which makes it more convenient and intuitive to observe the situation of the process during the entire running process.