CN113312243A - Resource monitoring method and system - Google Patents

Resource monitoring method and system Download PDF

Info

Publication number
CN113312243A
CN113312243A CN202110728810.9A CN202110728810A CN113312243A CN 113312243 A CN113312243 A CN 113312243A CN 202110728810 A CN202110728810 A CN 202110728810A CN 113312243 A CN113312243 A CN 113312243A
Authority
CN
China
Prior art keywords
resource
monitoring
information
manager
usage
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
CN202110728810.9A
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.)
Individual
Original Assignee
Individual
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 Individual filed Critical Individual
Priority to CN202110728810.9A priority Critical patent/CN113312243A/en
Publication of CN113312243A publication Critical patent/CN113312243A/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/3006Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is distributed, e.g. networked systems, clusters, multiprocessor systems

Abstract

The embodiment of the invention relates to the technical field of resource management, and particularly discloses a resource monitoring method and system. The method comprises the steps of initializing a resource manager; generating a resource monitoring structure of the resource; performing resource monitoring on resources; the method for generating the resource statistical information and the resource use information after receiving the instruction of updating the resource monitoring information can carry out detailed record aiming at the use condition of a specific resource and further assist business analysis and problem positioning.

Description

Resource monitoring method and system
Technical Field
The invention relates to the technical field of resource management, in particular to a resource monitoring method and system.
Background
In the prior art, a common scheme for monitoring resources is to use a common tool or command provided by a system, for example, on a linux platform, the system provides a top command, so that the use condition of process resources can be grasped. On the windows platform, the system provides a resource manager, and the use condition of the total resource of a certain process can be checked through the resource manager. However, these resource management and monitoring are statistical analyses of the total amount of final use of a certain type of resource (e.g., memory resource), which can provide a certain data analysis for the service, but cannot provide data support for further analysis and positioning of the problem.
Secondly, there are many negative effects in the conventional statistical analysis method of resources. For example, 1) one resource corresponds to one global resource statistical counter, and the counter will often pollute the global space; 2) a plurality of monitoring resources need a plurality of resource monitoring global counters, and the design is cumbersome and complex; 3) when performing resource statistical analysis across modules and threads, the name of a global counter for resource management needs to be remembered, which is a burden for a user; 4) the traditional method only records the generation and release conditions of data, does not relate to the use condition of resources, and cannot provide more detailed information of the use condition of the resources.
Furthermore, although some common tools can be used to analyze the usage of resources, such as analyzing whether resources are leaked or not by using valgrind, such tools are very limited, and firstly, they are generally only used in a test environment, and secondly, because of the complexity of services, service codes or anomalies that have not been run in the test process cannot be identified. Therefore, a tool for providing statistical analysis of resource generation and usage in the whole software life cycle is needed to help us identify the usage of resources.
In summary, a tool for analyzing and managing resources during process runtime is needed to continuously provide refined statistical analysis data of resources, such as how much memory is allocated to a specific resource, how many resources are allocated, how much memory is released, and how much memory is reserved currently. These refined resources will provide data basis for further business analysis and problem analysis.
Disclosure of Invention
In view of the above, the present application provides a resource monitoring method and system, which can solve or at least partially solve the above existing problems.
In order to solve the above technical problems, the technical solution provided by the present invention is a resource monitoring method, including:
initializing a resource manager;
generating a resource monitoring structure of the resource;
performing resource monitoring on resources;
and receiving an instruction for updating the resource monitoring information, and generating resource statistical information and resource use information.
Preferably, the method for initializing the resource manager includes:
acquiring the total resource monitoring number M in the last operation process of the resource manager from the database, wherein if the resource manager operates for the first time, M is equal to 0;
acquiring the total number N of resource monitoring preset by a resource manager;
taking the maximum value of M and N as P, and obtaining the minimum prime number S which is greater than or equal to P;
the HASH table size of the initialization resource manager is S.
Preferably, the method for generating the resource monitoring structure of the resource includes:
if the resource is a composite data structure, inserting a resource monitoring handle into the resource;
if the resource is an independent basic data type, compounding the basic data type of the resource with the resource monitoring handle to form a composite data structure;
the resource monitor handle includes a resource ID parameter and a resource usage ID parameter.
Preferably, the method for monitoring resources includes:
when a resource is created, checking whether the resource registers a resource ID, if not, registering the resource in a resource manager, acquiring the resource ID of the resource, and assigning a resource ID parameter in a resource monitoring structure by using the resource ID;
when the resource is used, checking whether the resource registers a resource use ID, if not, registering the resource in a resource manager, acquiring the resource use ID of the resource, positioning to a corresponding data position in a resource use information one-dimensional array through the resource use ID, updating the resource use information of the resource at the data position, if so, positioning to a corresponding data position in the resource use information one-dimensional array through the resource use ID, and updating the resource use information of the resource at the data position;
when the resource is generated or released, the resource ID corresponding to the resource is found, the corresponding global resource management node is located through the resource ID, and the resource statistical information is updated.
Preferably, the resource is registered in the resource manager, and the method for acquiring the resource ID of the resource includes: the resource ID of the first registered resource is 0, starting from the second registered resource, the resource ID of the registered resource is the resource ID of the last registered resource plus 1, a global resource management node of the resource is generated in the resource manager, and the global resource management node is mounted under a corresponding hash entrance of the resource manager and used for updating the resource statistical information of the resource;
the resource is registered in the resource manager, and the method for acquiring the resource use ID of the resource comprises the following steps: the first resource usage ID registered for each resource is 0, starting from the second registered resource usage ID, the registered resource usage ID is the last registered resource usage ID plus 1, and a resource usage information one-dimensional array of the resource is generated under the global resource management node of the resource and used for updating the resource usage information of the resource, and the resource usage information one-dimensional array of the resource is created when the resource usage ID is applied for registration for the first time.
Preferably, the method for generating resource statistics information and resource usage information includes:
taking a modulus of the resource ID of the resource and the size of the hash table to obtain an entry position of the resource in the hash table, sequentially traversing each global resource management node at the entry position from the entry position until a global resource management node identical to the resource ID of the resource is found, and acquiring resource statistical information of the resource at the global resource management node;
and under the global resource management node, finding a corresponding data position in the resource use information one-dimensional array according to the resource use ID, and acquiring the resource use information of the resource at the data position.
Preferably, the resource monitoring method further includes:
receiving an application for displaying resource monitoring information, and displaying the use information of the resource;
and receiving an application for ending the process of the resource manager, acquiring the total number of the resource monitors in the running process of the resource manager, comparing the total number with the total number of the resource monitors in the last running process stored in the database, taking the maximum value of the total number and the total number, and updating the total number of the resource monitors in the database.
The invention provides a resource management system, comprising:
the manager initialization module is used for initializing the resource manager;
the monitoring structure generating module is used for generating a resource monitoring structure of the resource;
the resource monitoring execution module is used for monitoring resources;
and the monitoring information generation module is used for receiving an instruction of updating the resource monitoring information and generating resource statistical information and resource use information.
Preferably, the resource monitoring execution module includes:
the resource creating management unit is used for checking whether the resource registers the resource ID when the resource is created, if not, registering the resource in the resource manager, acquiring the resource ID of the resource, and assigning the resource ID parameter in the resource monitoring structure by using the resource ID;
the resource usage management unit is used for checking whether the resource registers a resource usage ID when the resource is used, if not, registering the resource in the resource manager, acquiring the resource usage ID of the resource, positioning to a corresponding data position in the resource usage information one-dimensional array through the resource usage ID, updating the resource usage information of the resource at the data position, if so, positioning to a corresponding data position in the resource usage information one-dimensional array through the resource usage ID, and updating the resource usage information of the resource at the data position;
and the resource generation and release management unit is used for finding the resource ID corresponding to the resource when the resource is generated or released, positioning the resource ID to the corresponding global resource management node, and updating the resource statistical information.
The invention also provides a resource monitoring system, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the above-mentioned resource monitoring method.
Compared with the prior art, the beneficial effects of the method are detailed as follows: the method comprises the steps of initializing a resource manager; generating a resource monitoring structure of the resource; performing resource monitoring on resources; the method for generating the resource statistical information and the resource use information after receiving the instruction of updating the resource monitoring information can carry out detailed record aiming at the use condition of a specific resource and further assist business analysis and problem positioning.
Drawings
In order to illustrate the embodiments of the present invention more clearly, the drawings that are needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings can be obtained by those skilled in the art without inventive effort.
Fig. 1 is a schematic flowchart of a resource monitoring method according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a method for initializing a resource manager according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of a method for monitoring a resource according to an embodiment of the present invention;
fig. 4 is a schematic flowchart of another resource monitoring method according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a resource management system according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without any creative work belong to the protection scope of the present invention.
In order to make the technical solutions of the present invention better understood by those skilled in the art, the present invention will be further described in detail with reference to the accompanying drawings and specific embodiments.
As shown in fig. 1, an embodiment of the present invention provides a resource monitoring method, including:
s11: initializing a resource manager;
s12: generating a resource monitoring structure of the resource;
s13: performing resource monitoring on resources;
s14: and receiving an instruction for updating the resource monitoring information, and generating resource statistical information and resource use information.
It should be noted that, as shown in fig. 2, the method for initializing the resource manager in S11 includes:
s111: acquiring the total resource monitoring number M in the last operation process of the resource manager from the database, wherein if the resource manager operates for the first time, M is equal to 0;
s112: acquiring the total number N of resource monitoring preset by a resource manager;
s113: taking the maximum value of M and N as P, and obtaining the minimum prime number S which is greater than or equal to P;
s114: the HASH table size of the initialization resource manager is S.
Specifically, the step of initializing the resource manager includes: 1) the resource manager acquires the number M of resources of the whole system in the last operation process from the database, and if the system is operated for the first time, M is 0; 2) the resource manager obtains the number N of the preset resources in the system, wherein the N value is different according to different application software, and the N value is configured in a configuration file. For example, if the system needs more monitoring resources, N is set as a large point; 3) selecting a maximum value P in M and N, and upwards taking a minimum prime number S which is greater than or equal to P; 4) the HASH table of the resource manager is initialized with S.
Specifically, S is the size of the HASH table. When the resource is positioned, firstly, the module is taken according to the resource ID and S, the HASH bucket entry position where the resource is located is positioned, and then a list (namely, a traversal linked list) mode is used for searching the global resource management node of the resource. The global resource management node of the resource manages all information related to the resource ID.
The method for generating the resource monitoring structure of the resource at S12 includes:
if the resource is a composite data structure, inserting a resource monitoring handle into the resource;
if the resource is an independent basic data type, compounding the basic data type of the resource with the resource monitoring handle to form a composite data structure;
the resource monitor handle includes a resource ID parameter and a resource usage ID parameter.
Specifically, before performing resource monitoring, a composite process of the resource monitoring structure needs to be completed. For example: the original resource is struct { inta; to monitor the resource, inserting a resource handle struct { handle xxx into the resource; inta; }; if the resource is an independent basic data type, integrating the resource and the basic data type to form a composite data structure, for example, if the monitored resource is an intope, and if the monitored resource is a scope, using struct { handlexx; intpeople; and (4) forming a composite structure. The purpose of compounding is to make the structure of the resource carry a feature code so as to locate the management node of the resource subsequently. Specifically, the resource handle comprises a resource ID and a resource use ID, and after the resource handle is inserted, the resource has a monitored basic condition, and cross-thread monitoring is realized, namely after the resource is generated, the resource is transmitted to another thread, and the other thread can access the global management node of the resource through the resource handle carried by the resource, so that the cross-thread resource monitoring is realized.
It should be noted that, as shown in fig. 3, the method for monitoring resources by S13 includes:
s131: when a resource is created, checking whether the resource registers a resource ID, if not, registering the resource in a resource manager, acquiring the resource ID of the resource, and assigning a resource ID parameter in a resource monitoring structure by using the resource ID;
s132: when the resource is used, checking whether the resource registers a resource use ID, if not, registering the resource in a resource manager, acquiring the resource use ID of the resource, positioning to a corresponding data position in a resource use information one-dimensional array through the resource use ID, updating the resource use information of the resource at the data position, if so, positioning to a corresponding data position in the resource use information one-dimensional array through the resource use ID, and updating the resource use information of the resource at the data position;
s133: when the resource is generated or released, the resource ID corresponding to the resource is found, the corresponding global resource management node is located through the resource ID, and the resource statistical information is updated.
It should be noted that, during the operation of the system, whether the resource is registered with the resource ID is dynamically checked. The resource is registered in the resource manager, and the method for acquiring the resource ID of the resource comprises the following steps: the resource ID of the first registered resource is 0, starting from the second registered resource, the resource ID of the registered resource is the resource ID of the last registered resource plus 1, a global resource management node of the resource is generated in the resource manager, and the global resource management node is mounted under a corresponding hash entrance of the resource manager and used for updating the resource statistical information of the resource;
when a monitored resource is used, it is necessary to check whether or not the resource use ID is registered. If not, registering in the resource manager, and acquiring the resource use ID of the resource comprises the following steps: the first resource usage ID registered for each resource is 0, starting from the second registered resource usage ID, the registered resource usage ID is the last registered resource usage ID plus 1, and a resource usage information one-dimensional array of the resource is generated under the global resource management node of the resource and used for updating the resource usage information of the resource, and the resource usage information one-dimensional array of the resource is created when the resource usage ID is applied for registration for the first time.
Specifically, some resources do not need to record the use condition, find the global management node, and update the statistical information. For the condition that the resource use needs to be monitored, the resource use ID is needed to be reused to find the resource use information one-dimensional array, and the local statistical information is updated. For example, the memory resource is concerned about generation and release, and the use is not concerned, so that only the generation information of the resource needs to be updated. If the resource is a lock resource, not only the generation information of the resource but also the use information needs to be concerned.
The method for generating the resource statistics information and the resource usage information includes:
taking a modulus of the resource ID of the resource and the size of the hash table to obtain an entry position of the resource in the hash table, sequentially traversing each global resource management node at the entry position from the entry position until a global resource management node identical to the resource ID of the resource is found, and acquiring resource statistical information of the resource at the global resource management node;
and under the global resource management node, finding a corresponding data position in the resource use information one-dimensional array according to the resource use ID, and acquiring the resource use information of the resource at the data position.
Specifically, the detailed process of monitoring the resource includes: after a certain resource object applies for a certain resource to monitor successfully, the resource object is monitored:
A. firstly checking whether the resource is registered, specifically, setting an unregistered status code in an initial state, updating the status code after the resource is registered, and finding that the status code is a registered status to indicate that the resource is registered when the code moves to the state again;
B. if not, entering a registration link C;
C. registering the resource ID, specifically, the resource ID is increased progressively from 0 and is globally unique, in the registering process, the resource ID of the first registered resource is 0, and in the registering process, the resource ID of the resource is the resource ID +1 of the last registered resource from the second registered resource;
D. in the registration process, a globally increased unique resource ID is obtained, and a global resource management node of the resource is generated in a resource manager so as to count the resource use condition of the resource; in the process of registering resources, a global resource management node is generated and mounted under a HASH bucket, and the node is mounted with the statistical information of resource IDs, namely the number information of the generated resources.
E. When the resource is used, under the global resource management node, a resource usage information one-dimensional array is generated for managing the resource usage information of the resource, the resource usage information is in one-to-one correspondence with the resource usage ID, that is, the subscript position of the resource in the resource usage information one-dimensional array is located through the resource usage ID. The global resource management node manages all information of the resource, including resource creation information, statistical information, and resource usage information, which is local usage information of the resource, because there are multiple locations where one resource is used.
F. When the monitored resource is used, checking whether the resource use ID is registered, if not, entering G, otherwise, entering H. The resource usage ID is corresponding to local resource usage information, and the usage of each local resource is represented by a number unique to the resource, that is, the resource usage ID is an indication of a position of an element in a one-dimensional array of the resource usage information. Here, in the initial state, an unregistered status code is set, and after the resource usage ID is registered, the status code is updated, and when the code goes to this, the status code is found to be a registered status, indicating that the resource usage ID has been registered.
G. The resource usage ID is registered. The resource usage ID is incremented from 0, in a certain resource registration process, the resource usage ID registered for the first time is 0, and from the second time of registration, the resource usage ID registered for the resource is the last resource usage ID +1 registered under the resource.
H. And updating the resource statistical information of the resource. For example, there is a resource whose resource ID is 5, and the HASH table size S of the resource manager is set to 11 by calculation. 1) Locating the entry location of the resource in the HASH table, 5% 11, which is the location of the 5 th bucket; 2) searching a global resource management node with a resource ID of 5 from the position downwards in sequence; 3) after finding, updating the resource statistical information of the resource ID;
I. the local use information under the resource use ID is updated. For example, the resource usage information of the resource is managed by using a resource usage information one-dimensional array, for example, the resource ID is 5, the resource usage ID is 2, and the resource usage information array is dynamically increased, where the length is set to 3, 1) first, we search for a resource global resource management node, and traverse 2) in a hash-list manner according to the above example, and then find the global resource management node, under the node, there is a management structure of the resource usage ID, and directly use the resource usage ID (2), and implement quick access by using the resource usage information one-dimensional array subscript, and 3) update the resource usage information at the position.
It should be noted that, as shown in fig. 4, the present invention further provides another resource monitoring method, and on the basis of the foregoing embodiment, the resource monitoring method further includes:
s15: receiving an application for displaying resource monitoring information, and displaying the use information of the resource;
specifically, a corresponding command is input in the command line, the resource monitoring command is analyzed and executed, corresponding resource use information is displayed, and the resource use condition used in the process is shown.
S16: and receiving an application for ending the process of the resource manager, acquiring the total number of the resource monitors in the running process of the resource manager, comparing the total number with the total number of the resource monitors in the last running process stored in the database, taking the maximum value of the total number and the total number, and updating the total number of the resource monitors in the database.
Specifically, the number of resources counted in the counting process is as follows: and the maximum value of the resource ID is +1, because the resource ID is from 0, the resource ID is compared with the number of the resources stored in the database in the last operation process, the maximum value of the resource ID and the number of the resources is selected, and the statistical number of the resources in the database is updated. Namely, a process ending instruction is received, the current resource quantity is counted, and a data record is generated and solidified into a database.
In the following, a resource monitoring method of the present application is exemplified, and in example 1, a multi-threaded program (resource a) needs to monitor a lock, which needs to be used in multiple threads. The first time an instruction is received to update the monitoring information of the lock resource, the software comprises the following processing steps:
(1) to monitor a lock, the data structures of the lock are composited to form a composite data structure. eg, assuming the lock is mutex; the composite data structure after compositing is:
struct
{
id;
uid;
mutex;
};
(2) initializing the lock resource, and creating related information of the resource including a resource ID when the lock resource is initialized;
(3) supposing that a resource A is locked firstly, checking whether the current use ID of the lock is not set after the locking is successful, if not, registering the use ID, assigning a value to the uid by using the use ID of the resource, and carrying out +1 operation on a resource use manager of the lock;
(4) and after the operation of the resource A is finished, unlocking the lock resource, before unlocking, finding the lock resource by using the resource ID, and finding the resource use manager using the lock by using the uid to perform-1 operation.
Receiving an instruction for updating the monitoring information of the lock resource for the second time: (1) the resource id and the resource use id are registered, the assigned uid is directly used for finding the corresponding data position in the resource use information one-dimensional array, and then data is operated, namely +1 operation is carried out on the resource use manager; (2) the same applies to the third locking and the fourth and later locking; (3) and finally, acquiring statistical information in the period of time through a resource monitoring program, namely finishing the monitoring of the lock.
Example 2, there is one memory resource (resource B) released at the same time of resource application, and then there is only one resource usage id.
Receiving a monitoring information instruction for updating the resource B for the first time, wherein the software processing steps comprise: (1) first apply for a resource, here pointed to by g _ hcfktest _ memory _ arrar1[ ival ]; (2) and after the resource application is successful, the resource is monitored. Firstly, checking whether the memory resource is registered, if not, registering the resource in the resource manager, acquiring a resource ID, assigning a resource ID value in a memory composite structure pointed by g _ hcfktest _ memory _ array 1[ ival ] as the resource ID, and carrying out +1 on a counter; (3) before releasing the resource, the resource ID is used to find the registration information of the resource, the counter-1 is added, and then the resource is released.
Receiving the instruction for updating the monitoring information of the resource B from the second time to the nth time: (1) when the resource is reallocated for the second time, because the resource is already registered, the registered resource ID is directly copied to the ID field in the memory composite structure. (2) The third allocation and the fourth allocation are similar.
The basic idea of the invention is to adopt encapsulation, namely to encapsulate the relevant handle of the resource statistics and the resource itself in a structural body for transmission and resolution, wherein the resource relevant handle comprises a resource ID (global unique ID) and a resource use ID (counting from 0 and subordinate to the resource ID, which indicates the use condition of the resource).
The advantages of the invention are as follows: 1) while the traditional resource management describes the total amount of resource usage (result amount), the resource management in the present application adopts the fine management of resources (both result analysis and process and usage analysis), which is a beneficial supplement for monitoring system resources. 2) The allocation and the use condition of resources are mastered in detail, and data support can be provided for problem analysis and positioning. 3) The allocation and the use condition of resources are mastered in detail, and data support is provided for service analysis, problem positioning, algorithm improvement and performance optimization. 4) And (3) analyzing the data of the combined result: whether the service has problems or not can be roughly judged, and meanwhile, the problems of leakage of various resources and handles can be identified. 5) The data monitored by the resource does not pollute the global namespace.
As shown in fig. 5, the present invention further provides a resource management system, including:
a manager initializing module 21, configured to initialize a resource manager;
a monitoring structure generating module 22, configured to generate a resource monitoring structure of a resource;
a resource monitoring execution module 23, configured to perform resource monitoring on a resource;
and the monitoring information generating module 24 is configured to receive an instruction for updating the resource monitoring information, and generate resource statistics information and resource usage information.
It should be noted that the resource monitoring execution module 23 includes:
the resource creating management unit is used for checking whether the resource registers the resource ID when the resource is created, if not, registering the resource in the resource manager, acquiring the resource ID of the resource, and assigning the resource ID parameter in the resource monitoring structure by using the resource ID;
the resource usage management unit is used for checking whether the resource registers a resource usage ID when the resource is used, if not, registering the resource in the resource manager, acquiring the resource usage ID of the resource, positioning to a corresponding data position in the resource usage information one-dimensional array through the resource usage ID, updating the resource usage information of the resource at the data position, if so, positioning to a corresponding data position in the resource usage information one-dimensional array through the resource usage ID, and updating the resource usage information of the resource at the data position;
and the resource generation and release management unit is used for finding the resource ID corresponding to the resource when the resource is generated or released, positioning the resource ID to the corresponding global resource management node, and updating the resource statistical information.
An embodiment of the present invention further provides a resource monitoring system, including: a memory for storing a computer program; a processor for executing a computer program to implement the steps of the resource monitoring method described above.
For the description of the features in the embodiment corresponding to fig. 5, reference may be made to the related description of the embodiments corresponding to fig. 1 to fig. 4, which is not repeated here.
The resource monitoring method and system provided by the embodiment of the invention are described in detail above. The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

Claims (10)

1. A method for resource monitoring, comprising:
initializing a resource manager;
generating a resource monitoring structure of the resource;
performing resource monitoring on resources;
and receiving an instruction for updating the resource monitoring information, and generating resource statistical information and resource use information.
2. The method for monitoring resources of claim 1, wherein the method for initializing the resource manager comprises:
acquiring the total resource monitoring number M in the last operation process of the resource manager from the database, wherein if the resource manager operates for the first time, M is equal to 0;
acquiring the total number N of resource monitoring preset by a resource manager;
taking the maximum value of M and N as P, and obtaining the minimum prime number S which is greater than or equal to P;
the HASH table size of the initialization resource manager is S.
3. The method of claim 1, wherein the method of generating the resource monitoring structure of the resource comprises:
if the resource is a composite data structure, inserting a resource monitoring handle into the resource;
if the resource is an independent basic data type, compounding the basic data type of the resource with the resource monitoring handle to form a composite data structure;
the resource monitor handle includes a resource ID parameter and a resource usage ID parameter.
4. The method for monitoring resources according to claim 1, wherein the method for monitoring resources comprises:
when a resource is created, checking whether the resource registers a resource ID, if not, registering the resource in a resource manager, acquiring the resource ID of the resource, and assigning a resource ID parameter in a resource monitoring structure by using the resource ID;
when the resource is used, checking whether the resource registers a resource use ID, if not, registering the resource in a resource manager, acquiring the resource use ID of the resource, positioning to a corresponding data position in a resource use information one-dimensional array through the resource use ID, updating the resource use information of the resource at the data position, if so, positioning to a corresponding data position in the resource use information one-dimensional array through the resource use ID, and updating the resource use information of the resource at the data position;
when the resource is generated or released, the resource ID corresponding to the resource is found, the corresponding global resource management node is located through the resource ID, and the resource statistical information is updated.
5. The method of claim 4, wherein the resource is registered in a resource manager, and the method of obtaining the resource ID of the resource comprises: the resource ID of the first registered resource is 0, starting from the second registered resource, the resource ID of the registered resource is the resource ID of the last registered resource plus 1, a global resource management node of the resource is generated in the resource manager, and the global resource management node is mounted under a corresponding hash entrance of the resource manager and used for updating the resource statistical information of the resource;
the resource is registered in the resource manager, and the method for acquiring the resource use ID of the resource comprises the following steps: the first resource usage ID registered for each resource is 0, starting from the second registered resource usage ID, the registered resource usage ID is the last registered resource usage ID plus 1, and a resource usage information one-dimensional array of the resource is generated under the global resource management node of the resource and used for updating the resource usage information of the resource, and the resource usage information one-dimensional array of the resource is created when the resource usage ID is applied for registration for the first time.
6. The method of claim 1, wherein the method of generating resource statistics and resource usage information comprises:
taking a modulus of the resource ID of the resource and the size of the hash table to obtain an entry position of the resource in the hash table, sequentially traversing each global resource management node at the entry position from the entry position until a global resource management node identical to the resource ID of the resource is found, and acquiring resource statistical information of the resource at the global resource management node;
and under the global resource management node, finding a corresponding data position in the resource use information one-dimensional array according to the resource use ID, and acquiring the resource use information of the resource at the data position.
7. The resource monitoring method of claim 1, further comprising:
receiving an application for displaying resource monitoring information, and displaying the use information of the resource;
and receiving an application for ending the process of the resource manager, acquiring the total number of the resource monitors in the running process of the resource manager, comparing the total number with the total number of the resource monitors in the last running process stored in the database, taking the maximum value of the total number and the total number, and updating the total number of the resource monitors in the database.
8. A resource management system, comprising:
the manager initialization module is used for initializing the resource manager;
the monitoring structure generating module is used for generating a resource monitoring structure of the resource;
the resource monitoring execution module is used for monitoring resources;
and the monitoring information generation module is used for receiving an instruction of updating the resource monitoring information and generating resource statistical information and resource use information.
9. The resource management system of claim 8, wherein the resource monitoring execution module comprises:
the resource creating management unit is used for checking whether the resource registers the resource ID when the resource is created, if not, registering the resource in the resource manager, acquiring the resource ID of the resource, and assigning the resource ID parameter in the resource monitoring structure by using the resource ID;
the resource usage management unit is used for checking whether the resource registers a resource usage ID when the resource is used, if not, registering the resource in the resource manager, acquiring the resource usage ID of the resource, positioning to a corresponding data position in the resource usage information one-dimensional array through the resource usage ID, updating the resource usage information of the resource at the data position, if so, positioning to a corresponding data position in the resource usage information one-dimensional array through the resource usage ID, and updating the resource usage information of the resource at the data position;
and the resource generation and release management unit is used for finding the resource ID corresponding to the resource when the resource is generated or released, positioning the resource ID to the corresponding global resource management node, and updating the resource statistical information.
10. A resource monitoring system, comprising:
a memory for storing a computer program;
a processor for executing the computer program to carry out the steps of the resource monitoring method according to any one of claims 1 to 7.
CN202110728810.9A 2021-06-29 2021-06-29 Resource monitoring method and system Pending CN113312243A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110728810.9A CN113312243A (en) 2021-06-29 2021-06-29 Resource monitoring method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110728810.9A CN113312243A (en) 2021-06-29 2021-06-29 Resource monitoring method and system

Publications (1)

Publication Number Publication Date
CN113312243A true CN113312243A (en) 2021-08-27

Family

ID=77380792

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110728810.9A Pending CN113312243A (en) 2021-06-29 2021-06-29 Resource monitoring method and system

Country Status (1)

Country Link
CN (1) CN113312243A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6799208B1 (en) * 2000-05-02 2004-09-28 Microsoft Corporation Resource manager architecture
KR20080088041A (en) * 2007-03-28 2008-10-02 삼성전자주식회사 Resource management system and method for applications and threads in java virtual machine
CN101378353A (en) * 2007-08-27 2009-03-04 华为技术有限公司 User resource orientation method as well as communication system and relevant equipment
JP2012230598A (en) * 2011-04-27 2012-11-22 Nec Corp Resource management system, data update method and program
CN106658348A (en) * 2015-10-28 2017-05-10 西安中兴新软件有限责任公司 Method and device for managing monitoring resources and CSE
CN110708113A (en) * 2019-10-14 2020-01-17 中国人民解放军32039部队 Task scheduling center platform and relay satellite ground station network resource management method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6799208B1 (en) * 2000-05-02 2004-09-28 Microsoft Corporation Resource manager architecture
KR20080088041A (en) * 2007-03-28 2008-10-02 삼성전자주식회사 Resource management system and method for applications and threads in java virtual machine
CN101378353A (en) * 2007-08-27 2009-03-04 华为技术有限公司 User resource orientation method as well as communication system and relevant equipment
JP2012230598A (en) * 2011-04-27 2012-11-22 Nec Corp Resource management system, data update method and program
CN106658348A (en) * 2015-10-28 2017-05-10 西安中兴新软件有限责任公司 Method and device for managing monitoring resources and CSE
CN110708113A (en) * 2019-10-14 2020-01-17 中国人民解放军32039部队 Task scheduling center platform and relay satellite ground station network resource management method

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
张楠: "移动云环境下资源协同管理与分配机制研究", 中国博士学位论文全文数据库信息科技辑, 15 August 2018 (2018-08-15), pages 139 - 6 *
蒋漪涟;: "云计算资源管理系统的研究与实现", 微型电脑应用, no. 08, 20 August 2013 (2013-08-20), pages 56 - 59 *
郭方墩;张立臣;: "分布式实时系统面向方面的QoS监控模型", 计算机时代, no. 02, 2 February 2010 (2010-02-02), pages 21 - 22 *

Similar Documents

Publication Publication Date Title
US8151248B1 (en) Method and system for software defect management
US20050015752A1 (en) Static analysis based error reduction for software applications
US7552447B2 (en) System and method for using root cause analysis to generate a representation of resource dependencies
US7792950B2 (en) Coverage analysis of program code that accesses a database
US7870169B2 (en) Method for enabling traceability and recovery from errors during migration of software applications
JP2018026114A (en) Application profiling job management system, program, and method
US7293142B1 (en) Memory leak detection system and method using contingency analysis
EP2572294B1 (en) System and method for sql performance assurance services
US8214809B2 (en) Grid-enabled ANT compatible with both stand-alone and grid-based computing systems
US20150199252A1 (en) Correlation analysis of performance metrices
WO2014120192A1 (en) Error developer association
CN106886474B (en) Method and system for suspect detection of memory
US20200104246A1 (en) Continuous automation with test suite engine
US20170277466A1 (en) In-memory data analytic system that provides an integrated tracking mechanism for explicit memory resources
CN108710571A (en) A kind of method and apparatus generating automatic test code
KR101830936B1 (en) Performance Improving System Based Web for Database and Application
US8166077B2 (en) Mapping a class, method, package, and/or pattern to a component
Peiris et al. Automatically detecting" excessive dynamic memory allocations" software performance anti-pattern
CN113312243A (en) Resource monitoring method and system
Wong et al. An approach towards developing an algorithm for software application error analysis
Arias et al. Analyzing the actual execution of a large software-intensive system for determining dependencies
CN113688134B (en) Visual variable management method, system and equipment based on multidimensional data
CN110674024A (en) Electronic equipment integration test system and method thereof
Liu A general framework to detect design patterns by combining static and dynamic analysis techniques
CN113987044A (en) Asset data import processing method and device and electronic equipment

Legal Events

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