CN115048263A - Method and device for monitoring process liveness - Google Patents

Method and device for monitoring process liveness Download PDF

Info

Publication number
CN115048263A
CN115048263A CN202210614695.7A CN202210614695A CN115048263A CN 115048263 A CN115048263 A CN 115048263A CN 202210614695 A CN202210614695 A CN 202210614695A CN 115048263 A CN115048263 A CN 115048263A
Authority
CN
China
Prior art keywords
monitoring
system resource
task
liveness
monitored process
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210614695.7A
Other languages
Chinese (zh)
Inventor
胡海
周平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guiyang Longmaster Information and Technology Co ltd
Original Assignee
Guiyang Longmaster Information and Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guiyang Longmaster Information and Technology Co ltd filed Critical Guiyang Longmaster Information and Technology Co ltd
Priority to CN202210614695.7A priority Critical patent/CN115048263A/en
Publication of CN115048263A publication Critical patent/CN115048263A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs

Abstract

The invention discloses a method for monitoring process liveness, which comprises the following steps: allocating system resources, determining system resource information, and notifying the monitored process of the system resource information; starting a monitoring task; scheduling a monitoring task and monitoring a monitored process; and acquiring and outputting a monitoring result of the monitoring task. According to the technical scheme, the monitoring program can be operated on the equipment for operating the monitored process in a single-machine application scene, the requirement on equipment resource load is low, the state is stable, and the method is a light-weight, resource-saving, rapid and efficient technical scheme.

Description

Method and device for monitoring process liveness
Technical Field
The invention relates to the field of computer application, in particular to a method and a device for monitoring process liveness.
Background
In the field of computers, the running conditions of some more important programs are often required to be monitored, and if the running abnormality is found, the processing can be carried out in time. It is a common practice to actively report the liveness of a monitored process to a monitoring process by sending a liveness flag, such as a heartbeat packet, to the monitoring process by the monitored process. The monitored terminal sends heartbeat packets to the monitoring process in a circulating mode with a fixed small sending period, and the monitoring process checks whether the heartbeat packets sent by the monitored process are received in a period or not with a fixed large checking period. If no heartbeat packet is received within a check period, the monitored process is considered "not alive". However, the heartbeat verification method has a certain instability, and if the process sending the heartbeat packet cannot send the heartbeat packet in time due to factors such as high computer load, the monitoring process may not receive the heartbeat packet in a verification period, and then the monitored process is judged to be not alive. For such a situation, an improved method is to increase the check period, which can reduce the possibility of misjudging that the monitored process does not survive to some extent, but this also causes delay of the check, so that the monitoring process cannot timely find out that the monitored process has exited. Especially, the monitored process does not relate to network communication, namely, the monitoring and monitored processes are on the same computer, and if the layout architecture of the heartbeat package is adopted, the load of the system is increased.
Therefore, a lightweight process monitoring scheme is needed that stably operates on a single machine, timely acquires the survival status of a given process, and does not cause additional burden.
Disclosure of Invention
In order to achieve the above object, the present application provides a method for monitoring process liveness, comprising the following steps:
allocating system resources, determining system resource information, and informing the monitored process of corresponding system resource information; wherein, the system resource includes: file resources, socket resources, and other monopolizable system resources.
Starting a monitoring task;
scheduling a monitoring task and monitoring a monitored process;
and acquiring and outputting a monitoring result of the monitoring task.
And starting the monitoring task comprises obtaining a result that the monitored process monopolizes the system resource, and if the occupation is successful, executing the scheduling monitoring task.
Wherein, the scheduling monitoring task comprises: determining a time for executing the monitoring task; determining a mode for executing the monitoring task, wherein the mode comprises the following steps: and initiating the operation of monopolizing the system resource, acquiring an operation result, and outputting the liveness of the monitored process according to the operation result.
Further, outputting the monitored process liveness according to the operation result comprises liveness judgment: and if the operation result is failure, judging that the monitored process is alive.
In another aspect, the present application provides an apparatus for monitoring process liveness, including:
the system resource allocation unit is used for determining system resource information and informing the monitored process of the corresponding system resource information;
the monitoring task starting unit is used for starting the monitoring task;
the monitoring task scheduling unit is used for scheduling the monitoring tasks and monitoring the monitored process according to a plan;
and the result output unit is used for outputting the monitoring result of the monitoring process.
The monitoring task starting unit comprises a resource state obtaining module used for obtaining the result of the monitored process monopolizing the system resource, and if the result is successful occupation, the monitoring task scheduling unit is informed.
Further, the monitoring task scheduling unit includes:
the task time control module is used for determining the time for executing the monitoring task;
the task execution control module is used for determining a mode for executing the monitoring task, and the mode comprises the following steps: and initiating the operation of exclusive system resources, obtaining an operation result, and outputting the liveness state of the monitored process according to the operation result.
Further, the system resources include: file resources, socket resources, and other monopolizable system resources.
Further, the task execution control module comprises a result logic judger for judging the liveness of the monitored process, and the liveness judgment is as follows: and if the operation of the exclusive system resource fails, judging that the monitored process is alive.
According to the invention, the monitoring program can be operated on the single-machine application scene, namely on the equipment for operating the monitored process, the requirement on the equipment resource load is low, the state is stable, and the method is a light-weight, resource-saving, rapid and efficient technical scheme.
Drawings
FIG. 1 is a diagram of method steps provided in accordance with an embodiment of the present invention to monitor process liveness;
FIG. 2 is a timing diagram of a method for monitoring process liveness according to an embodiment of the present invention;
fig. 3 is a diagram of an apparatus for monitoring process liveness according to an embodiment of the present invention.
Detailed Description
The following detailed description of specific embodiments of the present invention is provided in conjunction with the accompanying drawings.
In some applications today, it is desirable to monitor the monitored process directly on its machine, for example: on a mobile phone, the iOS screen recording extension application and the screen recording main application need to monitor each other to determine whether the other side is alive. The scheme for monitoring the process liveness is suitable for the application scene of the single machine, has less requirements on equipment resource load and stable state, and is a light-weight technical scheme for saving resources.
The basic idea of the application is to judge the survival of the process by the monitored process and the exclusive occupation state of the monitoring process to an idle system resource.
Fig. 1 is a flowchart of a method for monitoring process liveness according to an embodiment of the present invention, as shown in the figure, including the following steps:
step S110: allocating system resources, determining system resource information, and notifying the monitored process of the system resource information;
in this step, the resource to be exclusively occupied is defined as a system resource, and the type of the system resource may be selected differently according to the operating environment, and generally includes: file resources, socket resources, operating system databases, and the like.
The system resource needs to be satisfied with the condition that it is idle before the monitoring is performed, and there is a unique identifier, such as a file name and a socket ID.
In the present application, the manner in which the monitoring process transmits messages to the monitored process, for example, notifying related system resource information, may be through a system database, such as the nseserdefaults database of the iOS system.
Step S120: starting a monitoring task;
the step includes obtaining the result of exclusive occupying system resource by the monitored process, if the occupation is successful, the dispatching monitoring task can be executed.
The simplest way to obtain the result that the monitored process has the system resource exclusive is implemented by the database of the operating system, for example, after the monitored process succeeds in system resource, the identification bit is set in the field specified by the database of the operating system, and the monitoring process reads the identification bit to obtain the result.
Step S130: scheduling a monitoring task and monitoring a monitored process;
the content of the schedule includes two aspects: the time and manner of performing the monitoring task is determined.
In brief, the step is to make the monitoring process periodically determine the presence of the monitored process, manage the monitoring time period in time control, for example, set the monitoring frequency, and periodically execute the monitoring task by using a timer.
In the solution of the present application, the basis for finding whether the monitored process is alive is to determine whether the resources occupied by the monitored process have been released, so the manner of executing the monitoring task is as follows: and the monitoring process initiates an operation of monopolizing system resources and outputs the liveness of the monitored process according to an operation result. For example, according to step S110, the monitored process is notified to open a specified file in a write manner, and the monitoring process is executed to open the file in a write manner in this step; or the monitored process is notified to bind a random socket, if the port number of the socket is 8000, in this step, the monitoring process is executed to monitor and bind the socket port 8000.
Step S140: and acquiring a monitoring result of the monitoring task.
In step S130, the monitoring process initiates an operation of monopolizing the system resource, and in this step, an execution result of the operation is obtained. If the resource is successfully occupied, the system resource is released, namely the monitored process is finished, and if the resource is unsuccessfully occupied, the system resource is still occupied by the monitored process, namely the monitored process is alive.
In this way, whether the monitored process is alive can be accurately judged by whether the preemption of the system resources is successful or not: if the monitored process exits or is killed by the system, the system resource which is monopolized before is returned, so that the monitoring process can timely and successfully preempt the system resource, and further know that the monitored process is finished; otherwise, if the monitoring process cannot seize the system resource all the time, it can be determined that the monitored process is still alive. And the monitoring delay of the method does not exceed one timing period at most.
It should be noted that, considering that after the monitored process releases the system resource occupied by the monitored process, the system resource has the possibility of being preempted by the third-party application, in the execution process of the method of the present application, a random system resource should be selected first to reduce the possibility of being preempted by other applications; in addition, the polling period of the monitoring process also needs to be set to be short enough, so that the situation that the monitoring process judges that the monitored process still survives due to the fact that the monitoring process finds that the resource is preempted by other applications before being released is further avoided.
In the method timing diagram of fig. 2, the steps of the present application are shown in detail among the monitoring process, the system resource, and the monitored process:
the monitoring process determines the system resource through step S211, and notifies the monitored process of the system resource information through step S212, and the monitored process does not need to periodically execute the heartbeat packet, and only needs to initiate an exclusive binding to the resource once, and notify the monitoring process.
After the monitoring process obtains the system resource occupied by the monitored process, the monitoring task is started in step S221, where the monitoring task includes initiating a task of monopolizing the resource to the system resource, and the task of executing the monopolizing the resource includes setting a time period and initiating an operation of monopolizing the resource according to the time period. In step S231, the survival status of the monitored process is determined by the result of each exclusive binding.
In the method, for the monitored process, only one time of occupying appointed resources, such as files, sockets and the like, is needed, and the resources are not occupied by adopting a timer and the like, so that the method has little resource occupation; for the monitoring process, a communication protocol is not required to be defined, and the state of the appointed monitoring process can be judged only by initiating the occupation of the existing system resources. The bound resource can be a socket, an empty file and the like, and no additional burden is generated on the system. Therefore, the method belongs to a lightweight, efficient and stable scheme for monitoring process liveness.
FIG. 3 provides a block diagram of an apparatus for monitoring process liveness, as shown, comprising:
p310: the system resource allocation unit is used for determining system resource information and informing the monitored process of the corresponding system resource information; the system resources in the present application include commonly used idle system resources, such as file resources, socket resources, and the like.
And the monitored process receives the system resource information, initiates exclusive operation on the resource, and notifies the monitoring process after the exclusive operation is completed.
P320: the monitoring task starting unit is used for starting the monitoring task;
the monitoring task starting unit comprises a resource state obtaining module used for obtaining the result that the monitored process monopolizes the system resource, if the result is successful occupation, the monitored process informs the monitoring task scheduling unit, and the informing content can be the system resource information and the binding result. The manner of notification may be through some resource of the system, such as the NSUserDefaults database of the iOS system.
P330: the monitoring task scheduling unit is used for scheduling the monitoring task and monitoring the monitored process according to a plan;
the monitoring task scheduling unit comprises:
p331: the task time control module is used for determining the time for executing the monitoring task; the time is mainly controlled by monitoring periods, and each monitoring delay does not exceed one timing period at most.
P332: the task execution control module is used for determining a mode for executing the monitoring task, and the mode comprises the following steps: and initiating an operation for monopolizing the system resource, obtaining the result of the monopolizing operation, and outputting the liveness state of the monitored process according to the operation result.
The task execution control module includes P335: and the result logic judger is used for judging the liveness of the monitored process, and the liveness judgment comprises the following steps: and if the operation of the exclusive system resource fails, judging that the monitored process is alive.
P340: and the result output unit is used for outputting the monitoring result of the monitoring process, and the result is output to an application scene for use, such as a management terminal and the like.
The monitoring process liveness scheme provided by the invention can realize the monitoring of the process in the application scene of a single machine, has less requirement on equipment resource load and stable state, and is a light-weight and resource-saving monitoring realization scheme.
The above disclosure is only for a few specific embodiments of the present invention, but the present invention is not limited thereto, and any variations that can be made by those skilled in the art are intended to fall within the scope of the present invention.

Claims (10)

1. A method for monitoring process liveness, comprising the steps of:
allocating system resources, determining the system resource information, and informing a monitored process of the system resource information;
starting a monitoring task;
scheduling a monitoring task, and monitoring the monitored process;
and acquiring and outputting a monitoring result of the monitoring task.
2. The method according to claim 1, wherein the starting of the monitoring task includes obtaining a result that the monitored process monopolizes the system resource information, and if the occupation is successful, the scheduling of the monitoring task is performed.
3. The method of monitoring process liveness as recited in claim 2, wherein said scheduling a monitoring task comprises:
determining the time for executing the monitoring task;
determining a manner of executing a monitoring task, the manner comprising: and initiating an operation of monopolizing the system resource information, acquiring the operation result, and outputting the liveness of the monitored process according to the operation result.
4. The method of claim 1, wherein the system resource is an exclusionable system resource, and comprises: file resources, socket resources.
5. The method of claim 3, wherein outputting the monitored process liveliness according to the operation result comprises: and if the operation result is failure, judging that the monitored process is alive.
6. An apparatus for monitoring process liveness, comprising the steps of:
the system resource allocation unit is used for determining system resource information and informing a monitored process of the system resource information;
the monitoring task starting unit is used for starting a monitoring task;
the monitoring task scheduling unit is used for scheduling a monitoring task and monitoring the monitored process according to a plan;
and the result output unit is used for outputting the monitoring result of the monitoring process.
7. The apparatus for monitoring process liveness according to claim 6, wherein the monitor task starting unit includes a resource status obtaining module, configured to obtain a result that the monitored process monopolizes the system resource information, and notify the monitor task scheduling unit if the result is successful in occupation.
8. The apparatus for monitoring process liveness according to claim 7, wherein the monitor task scheduling unit comprises:
the task time control module is used for determining the time for executing the monitoring task;
the task execution control module is used for determining a mode for executing the monitoring task, and the mode comprises the following steps: and initiating an operation for monopolizing the system resource information, obtaining the operation result, and outputting the liveness state of the monitored process according to the operation result.
9. The apparatus for monitoring process liveness according to claim 6, wherein the system resource is an exclusionable system resource, comprising: file resources, socket resources.
10. The apparatus for monitoring process liveness as recited in claim 8, wherein the control module for performing according to tasks comprises a result logic judger for judging the liveness of the monitored process, the judging of the liveness comprising: and if the operation of monopolizing the system resource information fails, judging that the monitored process is alive.
CN202210614695.7A 2022-06-01 2022-06-01 Method and device for monitoring process liveness Pending CN115048263A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210614695.7A CN115048263A (en) 2022-06-01 2022-06-01 Method and device for monitoring process liveness

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210614695.7A CN115048263A (en) 2022-06-01 2022-06-01 Method and device for monitoring process liveness

Publications (1)

Publication Number Publication Date
CN115048263A true CN115048263A (en) 2022-09-13

Family

ID=83158593

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210614695.7A Pending CN115048263A (en) 2022-06-01 2022-06-01 Method and device for monitoring process liveness

Country Status (1)

Country Link
CN (1) CN115048263A (en)

Similar Documents

Publication Publication Date Title
CN107688496B (en) Task distributed processing method and device, storage medium and server
CN111782360B (en) Distributed task scheduling method and device
JP4571216B2 (en) Device management system and set value setting method in the system
CN112910937A (en) Object scheduling method and device in container cluster, server and container cluster
CN110333916B (en) Request message processing method, device, computer system and readable storage medium
CN111586140A (en) Data interaction method and server
CN107862040B (en) Method and device for updating data in cache of application instance and cluster
CN110413398B (en) Task scheduling method and device, computer equipment and storage medium
CN115048263A (en) Method and device for monitoring process liveness
CN117056080A (en) Distribution method and device of computing resources, computer equipment and storage medium
CN108255515B (en) Method and device for realizing timer service
CN112685145A (en) Task management method and device and computer equipment
CN115712572A (en) Task testing method and device, storage medium and electronic device
CN115643276A (en) Data transmission method, device, system and computer readable storage medium
CN113448744B (en) Application program selection method and device
CN115220993A (en) Process monitoring method, device, vehicle and storage medium
CN113504953A (en) Task scheduling method and device of comprehensive service platform
CN114374684B (en) Shell command optimization method and system
CN111917620B (en) MCU service processing method, device, electronic equipment and storage medium
CN111309467A (en) Task distribution method and device, electronic equipment and storage medium
CN111858043B (en) Service request processing method and device, storage medium and electronic device
CN112104506B (en) Networking method, networking device, server and readable storage medium
CN113163511B (en) Information processing method and device, network element, terminal and readable storage medium
CN109766172B (en) Asynchronous task scheduling method and device
CN111796906A (en) Container management method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication