A multi-server resource monitoring method, device and computer equipment
By acquiring and marking process information on multiple servers and monitoring their resource occupation, the problem of inability to monitor the resource occupation of multiple servers in the prior art is solved, and precise monitoring and allocation of logical project resources is achieved, and network load is reduced.
Patent Information
- Application Number
- CN202010977151.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-16
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2040-09-16
AI Technical Summary
The prior art cannot effectively monitor the resource usage of specific processes corresponding to multiple servers, and cannot achieve accurate monitoring and resource allocation of multiple server resources in a logical project.
By obtaining the process information of the target project on each server, performing process marking, obtaining the resource occupation information of each process on the server, and monitoring it based on this information, including obtaining the server's characteristic information, connecting to the server, sending early warning information and Resource occupation analysis is performed according to the preset trigger level.
It realizes accurate monitoring of the resource usage of multiple servers, meets users' statistical needs for target projects, and can make more accurate resource decisions and allocations, reducing network load.
Smart Images

Figure CN112084094B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer applications, and in particular to a multi-server resource monitoring method, device and computer equipment. Background Art
[0002] Project monitoring is centered around the project implementation plan, tracking progress, cost, quality, and resources, understanding the current status of each work in order to make appropriate resource allocation and progress adjustments, and record the actual progress.
[0003] In the related art, the monitoring of project resources is aimed at the CPU resources and memory resources of the entire server, or at a certain process of a certain machine. There is no monitoring service for monitoring specific processes corresponding to multiple servers. It is impossible to implement data resource statistics for specific processes corresponding to multiple servers at the same time, and it is impossible to understand the resource occupancy in a logical project. Therefore, it is urgent to propose a multi-server resource monitoring method to realize the monitoring of the occupancy of multiple server resources by a logical project, so as to make more accurate resource decisions and achieve accurate allocation of used resources. Summary of the invention
[0004] Therefore, the technical problem to be solved by the present invention is to overcome the defect in the prior art that it is not possible to monitor the occupancy of multiple server resources by a logical project, thereby providing a multi-server resource monitoring method, device and computer equipment.
[0005] According to the first aspect, an embodiment of the present invention discloses a multi-server resource monitoring method, wherein the multiple servers simultaneously run at least one target project, comprising the following steps: obtaining process information of a process running on each server of any target project; marking each process according to the process information of each process; obtaining resource occupancy information of each process on the server according to the process marking result; and monitoring the resource occupancy of the target project according to the resource occupancy information of each process on the server.
[0006] Optionally, before obtaining the resource occupancy information of each process on the server based on the process marking result, the method also includes: obtaining characteristic information of the server corresponding to each process; and connecting to the server corresponding to each process based on the characteristic information of the server corresponding to each process.
[0007] Optionally, connecting to the server corresponding to each process according to the characteristic information of the server corresponding to each process includes: connecting to the server corresponding to each process at a target time interval.
[0008] Optionally, the method further comprises: issuing an alarm message when any server corresponding to the process cannot be connected.
[0009] Optionally, the characteristic information of the server includes the server type, and the resource usage information of the server includes any one or more of CPU resources, memory resources and hard disk resources; the method also includes: according to the server type, selecting a corresponding target acquisition instruction to acquire the resource usage information of the corresponding server.
[0010] Optionally, a preset trigger level is obtained, where the preset trigger level is determined according to a preset trigger threshold and a trigger rule; and warning information is sent according to the trigger level, resource information occupied by the target project, and resource occupation information of the server.
[0011] According to the second aspect, an embodiment of the present invention further discloses a multi-server resource monitoring device, wherein the multiple servers simultaneously run at least one target project, including: a first acquisition module, used to obtain process information of a process running on each server of any target project; a marking module, used to mark each process according to the process information of each process; a resource occupancy information acquisition module, used to obtain resource occupancy information of each process on the server where it is located according to the process marking result; and a monitoring module, used to monitor the resource occupancy of the target project according to the resource occupancy information of each process on the server where it is located.
[0012] Optionally, the device further includes: a second acquisition module, used to acquire characteristic information of the server corresponding to each process; and a connection module, used to connect to the server corresponding to each process according to the characteristic information of the server corresponding to each process.
[0013] According to the third aspect, an embodiment of the present invention also discloses a computer device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor performs the steps of the multi-server resource monitoring method as described in the first aspect or any optional embodiment of the first aspect.
[0014] According to a fourth aspect, an embodiment of the present invention further discloses a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the multi-server resource monitoring method as described in the first aspect or any optional implementation manner of the first aspect.
[0015] The technical solution of the present invention has the following advantages:
[0016] The multi-server resource monitoring method and device provided by the present invention obtains the process information of the process running on each server of any target project, marks each process according to the process information of each process, obtains the resource occupation information of each process on the server according to the process marking result, and obtains the resource occupation situation of the target project according to the resource occupation information of each process on the server. The present invention facilitates monitoring the resource occupation situation of each project by marking each process of the target project, and can meet the statistical needs of users for each target project. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A flowchart of a specific example of a multi-server resource monitoring method according to an embodiment of the present invention;
[0019] Figure 2 A schematic block diagram of a specific example of a multi-server resource monitoring device according to an embodiment of the present invention;
[0020] Figure 3 FIG. 4 is a specific example diagram of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0021] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0022] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0023] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, it can also be the internal connection of two components, it can be a wireless connection, or it can be a wired connection. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0024] In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0025] The embodiment of the present invention discloses a multi-server resource monitoring method, wherein multiple servers simultaneously run at least one target project, such as Figure 1 As shown, the following steps are included:
[0026] S11: Obtain process information of a process running on each server for any target project.
[0027] Exemplarily, the process information is information that can characterize the process, for example: / data / java / Application, the process information indicates that there is a java project under the data directory, and the main function is Application.
[0028] The process information of each process of the target project can be actively provided by each process leader, or can be actively obtained by opening a transmission channel of each server and connecting to the server corresponding to each process. The method for obtaining process information in the embodiment of the present invention is not specifically limited, and those skilled in the art can set it according to actual conditions.
[0029] S12: Mark each process according to the process information of each process.
[0030] Exemplarily, marking each process according to the process information of each process may be marking each process according to the intersection principle according to the process information of each process.
[0031] For project A, there are processes a and b. Process a has rules I, II, and III; process b has rules IV and V. Among them, there are multiple rules in a process, which are used to accurately mark the process. For example, process a is in the / data directory, with a java project and the main function is Application. Then rule I is: / data; rule II is java; rule III is Application, then take the intersection of rules I, II, and III to mark process a. For another example, process b is a process running jdk11 in the / sonarqube directory. Then rule IV is / sonarqube, rule V is jdk11, and take the intersection of rules IV and V to mark process b.
[0032] S13: Obtain resource usage information of each process according to the process marking result.
[0033] Exemplarily, according to the process marking result, the resource usage information of each process can be obtained by running the command: ps aux|grep I|grep II|..., where I and II represent different rules respectively, and the process that satisfies both I and II matching is found from the corresponding server, and then the resource usage information of the process corresponding to I and II is obtained.
[0034] S14: Based on the resource occupation information of each process on the server, the resource occupation of the target project is monitored.
[0035] Exemplarily, monitoring the project resources of the target project may include displaying indicators related to the target project, such as CPU occupancy, memory occupancy, hard disk occupancy, etc., on a page in the form of a chart or table.
[0036] According to the resource usage information of each process, the project resources of the target project are monitored. For example, the memory usage of the first process is 1000MB, the memory usage of the second process is 1500MB, and the target project A includes the first process and the second process, then the memory usage of the target project A is 2500MB.
[0037] The multi-server resource monitoring method provided by the present invention obtains the process information of the process running on each server of any target project; processes each process according to the process information of each process; obtains the resource occupation information of each process on the server according to the process marking result; obtains the resource occupation situation of the target project according to the resource occupation information of each process on the server. The present invention facilitates monitoring the resource occupation situation of each project by process marking each process of the target project, and can meet the statistical needs of users for each target project.
[0038] As an optional implementation of the present invention, before step S13, the multi-server resource monitoring method further includes:
[0039] First, obtain the characteristic information of the server corresponding to each process.
[0040] Exemplarily, the characteristic information of the server may include a custom name of the server (the name is unique), an IP address connected to the server SSH, a port number connected to the server SSH, a type of server, and a user name connected to the server SSH. The embodiment of the present invention does not limit the characteristic information of the server, and those skilled in the art may set it according to actual conditions. The method for obtaining the characteristic information of the server corresponding to each process is the same as the method for obtaining the process information described above, and will not be repeated here.
[0041] Secondly, the server corresponding to each process is connected according to the characteristic information of the server corresponding to each process.
[0042] Exemplarily, connecting to the server corresponding to each process according to the characteristic information of the server corresponding to each process can be to determine which server it is according to the custom name of the server corresponding to each process, enter the corresponding IP address to connect, and then enter the corresponding user name to obtain relevant resource information.
[0043] As an optional implementation of the present invention, the multi-server resource monitoring method further includes:
[0044] According to the process marking results of each project, the resource usage information of the unknown process is obtained.
[0045] For example, the reverse command of the above rule is run to filter the marked processes, and only the unmarked processes, i.e., unknown processes, are displayed on the page at the same time. The resource occupation information of the unknown processes on the server can be monitored.
[0046] As an optional implementation manner of the present invention, connecting the server corresponding to each process according to the characteristic information of the server corresponding to each process includes:
[0047] Connect to the server corresponding to each process according to the target time interval.
[0048] Exemplarily, after configuring the characteristic information of the server, each server is connected periodically to obtain the relevant resource information of each process. The target time interval may be one week, and the embodiment of the present invention does not specifically limit the target time interval, and those skilled in the art may set it according to actual conditions.
[0049] The present invention monitors the resource occupancy of each process by setting a target time interval, without real-time monitoring, thereby reducing network resource occupancy and lowering network load.
[0050] As an optional implementation of the present invention, the multi-server resource monitoring method further includes: when it is impossible to connect to the server corresponding to any process, issuing an alarm message.
[0051] For example, a connection time can be set, such as 30 seconds. When the connection time exceeds and the server corresponding to any process cannot be connected, the server is considered to have failed and an alarm message is issued. The alarm message can be notified to the relevant person in charge via DingTalk or by email. The embodiment of the present invention does not limit the sending method of the alarm message, and those skilled in the art can set it according to actual conditions.
[0052] As an optional implementation of the present invention, the characteristic information of the server includes the server type, and the resource usage information of the server includes any one or more of CPU resources, memory resources, and hard disk resources; the multi-server resource monitoring method also includes:
[0053] According to the server type, a corresponding target acquisition instruction is selected to acquire the resource occupancy information of the corresponding server.
[0054] Exemplarily, the server type may include: Linux, Mac. When the server type is Linux, the command for obtaining CPU resources is iostat, and specifically, the CPU usage and idle rate can be obtained according to the command; the command for obtaining memory resources is free-m, and specifically, the total memory, memory usage and memory idle rate can be obtained according to the command; the command for obtaining hard disk resources is df, and specifically, the virtual hard disk space can be filtered out according to the command to obtain the real hard disk space, hard disk usage and hard disk idle rate.
[0055] When the server type is Mac, the method for obtaining CPU resources is the same as that when the server type is Linux, and will not be repeated here; the command for obtaining memory resources is vm_stat, specifically, the total memory, memory usage and memory idle rate can be obtained according to this command; the command for obtaining hard disk resources is df-1, specifically, the virtual hard disk space can be filtered out according to this command to obtain the real hard disk space, hard disk usage and hard disk idle rate.
[0056] The resource usage information of the server can also be presented on the page in a visual form, such as a chart, table, etc. The visualization content may include CPU usage, CPU idle rate, memory usage, memory idle rate, total memory, hard disk usage, hard disk idle rate, total hard disk, and whether the server is online.
[0057] The embodiment of the present invention simultaneously monitors the resource usage of each server, and timely adjusts the number of servers and the servers corresponding to each process based on the resource usage of each process, so as to make more accurate resource decisions for different projects and achieve accurate resource allocation.
[0058] As an optional implementation of the present invention, the multi-server resource monitoring method further includes:
[0059] First, a preset trigger level is obtained, where the preset trigger level is determined according to a preset trigger threshold and a trigger rule.
[0060] Exemplarily, the preset trigger levels include: normal level (INFO), warning level (WARN), and error level (ERROR). The preset trigger threshold can be set in advance by the user according to the target project and each specific process. The trigger threshold can take any value from 0% to 100%, which is the proportion of CPU resources, memory resources or hard disk resources to the total machine resources. There are two types of trigger rules, one is a greater than symbol and the other is a less than symbol. The preset trigger level is determined according to the preset trigger threshold and the trigger rule. For example, when the CPU accounts for more than 90% of the total machine resources, the trigger level is ERROR, when the CPU accounts for more than 70% of the total machine resources, the trigger level is WARN, and when the CPU accounts for more than 50% of the total machine resources, the trigger level is INFO.
[0061] Secondly, early warning information is sent based on the trigger level, resource information occupied by the target project, and resource occupancy information of the server.
[0062] Exemplarily, different trigger levels correspond to different sending times. For example, when the trigger level is INFO, a warning message is sent once within an hour; when the trigger level is WARN, a warning message is sent once within half an hour; when the trigger level is ERROR, a warning message is sent as long as the trigger level is reached. The embodiment of the present invention does not specifically limit the sending time, and those skilled in the art can set it according to actual conditions. The sending method of the warning message is the same as the above-mentioned alarm message, and will not be repeated here.
[0063] The embodiment of the present invention also discloses a multi-server resource monitoring device, wherein the multi-servers simultaneously run at least one target project, such as Figure 2 As shown, including:
[0064] The first acquisition module 21 acquires the process information of a process of any target project running on each server; the specific implementation method is shown in the relevant description of step S11 in the embodiment, which will not be repeated here.
[0065] The marking module 22 is used to mark each process according to the process information of each process; the specific implementation method can be found in the relevant description of step S12 in the embodiment, which will not be repeated here.
[0066] The resource occupancy information obtaining module 23 is used to obtain the resource occupancy information of each process according to the process marking result; the specific implementation method is shown in the relevant description of step S13 in the embodiment, which will not be repeated here.
[0067] The monitoring module 24 is used to monitor the resource occupation of the target project according to the resource occupation information of each process on the server. The specific implementation method is described in the relevant description of step S14 in the embodiment, which will not be repeated here.
[0068] The multi-server resource monitoring device provided by the present invention obtains the process information of the process running on each server of any target project; processes each process according to the process information of each process; obtains the resource occupation information of each process on the server according to the process marking result; obtains the resource occupation situation of the target project according to the resource occupation information of each process on the server. The present invention facilitates monitoring the resource occupation situation of each project by process marking each process of the target project, and can meet the statistical needs of users for each target project.
[0069] As an optional implementation of the present invention, the multi-server resource monitoring device further includes:
[0070] The second acquisition module is used to obtain the characteristic information of the server corresponding to each process; the specific implementation method is shown in the corresponding steps in the embodiment, which will not be repeated here.
[0071] The connection module is used to connect to the server corresponding to each process according to the characteristic information of the server corresponding to each process. The specific implementation method is shown in the corresponding steps of the embodiment, which will not be repeated here.
[0072] As an optional implementation of the present invention, the multi-server resource monitoring device further includes:
[0073] The resource occupation information acquisition module of the unknown process is used to obtain the resource occupation information of the unknown process according to the process marking result of each project. The specific implementation method is shown in the corresponding steps of the embodiment, which will not be repeated here.
[0074] As an optional embodiment of the present invention, the connection module includes:
[0075] The connection submodule is used to connect to the server corresponding to each process according to the target time interval; the specific implementation method can be found in the corresponding steps in the embodiment, which will not be repeated here.
[0076] As an optional implementation of the present invention, the multi-server resource monitoring device further includes:
[0077] The alarm module is used to issue an alarm message when the server corresponding to any process cannot be connected. The specific implementation method is shown in the corresponding steps of the embodiment, which will not be repeated here.
[0078] As an optional implementation of the present invention, the characteristic information of the server includes the server type, and the resource occupation information of the server includes any one or more of CPU resources, memory resources and hard disk resources; the multi-server resource monitoring device also includes:
[0079] The selection module is used to select the corresponding target acquisition instruction according to the server type to acquire the resource occupation information of the corresponding server. The specific implementation method is shown in the corresponding steps of the embodiment, which will not be repeated here.
[0080] As an optional implementation of the present invention, the multi-server resource monitoring device further includes:
[0081] The preset trigger level acquisition module is used to obtain the preset trigger level, which is determined according to the preset trigger threshold and trigger rules; the specific implementation method can be found in the corresponding steps in the embodiment, which will not be repeated here.
[0082] The sending module is used to send warning information according to the trigger level, the resource information occupied by the target project and the resource occupation information of the server. The specific implementation method is shown in the corresponding steps of the embodiment, which will not be repeated here.
[0083] The embodiment of the present invention also provides a computer device, such as Figure 3 As shown, the computer device may include a processor 31 and a memory 32, wherein the processor 31 and the memory 32 may be connected via a bus or other means. Figure 3 The example of connecting through bus is taken in the following.
[0084] The processor 31 may be a central processing unit (CPU). The processor 31 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0085] The memory 32 is a non-transitory computer-readable storage medium that can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as program instructions / modules corresponding to the multi-server resource monitoring method in the embodiment of the present invention (for example, Figure 2 The processor 31 executes various functional applications and data processing of the processor by running the non-transient software programs, instructions and modules stored in the memory 32, that is, the multi-server resource monitoring method in the above method embodiment is implemented.
[0086] The memory 32 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store data created by the processor 31, etc. In addition, the memory 32 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 32 may optionally include a memory remotely arranged relative to the processor 31, and these remote memories may be connected to the processor 31 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0087] The one or more modules are stored in the memory 32 and when executed by the processor 31, perform the following steps: Figure 1 The multi-server resource monitoring method in the illustrated embodiment.
[0088] For details of the above computer equipment, please refer to Figure 1 The corresponding related descriptions and effects in the illustrated embodiments can be understood and will not be repeated here.
[0089] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above-mentioned types of memory.
[0090] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for monitoring multi-server resources, wherein the multi-servers simultaneously run at least one target project, characterized in that: The steps include: Get the process information of any target project running on each server; Marking each process according to the process information of each process; According to the process marking results, the resource usage information of each process on the server is obtained; Monitoring resource occupancy of the target project according to resource occupancy information of each process on the server; The process information includes: process rules; The process marking each process according to the process information of each process includes: process marking each process according to the intersection principle based on the intersection of the process rules of each process.
2. The method according to claim 1, characterized in that: Before obtaining the resource occupation information of each process on the server according to the process marking result, the method further includes: Obtaining characteristic information of the server corresponding to each process; The server corresponding to each process is connected according to the characteristic information of the server corresponding to each process.
3. The method according to claim 2, characterized in that The connecting to the server corresponding to each process according to the characteristic information of the server corresponding to each process includes: connecting to the server corresponding to each process according to a target time interval.
4. The method according to claim 2 or 3, characterized in that: The method further comprises: when it is impossible to connect to a server corresponding to any of the processes, issuing an alarm message.
5. The method according to claim 2 or 3, characterized in that: The characteristic information of the server includes the server type, and the resource usage information of the server includes any one or more of CPU resources, memory resources and hard disk resources; the method further includes: According to the server type, a corresponding target acquisition instruction is selected to acquire resource occupancy information of the corresponding server.
6. The method according to claim 5, characterized in that The method further comprises: Obtaining a preset trigger level, where the preset trigger level is determined according to a preset trigger threshold and a trigger rule; The warning information is sent according to the preset trigger level, the resource information occupied by the target project and the resource occupation information of the server.
7. A multi-server resource monitoring device, wherein the multi-servers simultaneously run at least one target project, characterized in that: include: A first acquisition module is used to acquire process information of a process running on each server of any target project; A marking module, used for marking each process according to the process information of each process; The resource occupancy information acquisition module is used to obtain the resource occupancy information of each process on the server according to the process marking result; A monitoring module, used to monitor the resource occupancy of the target project according to the resource occupancy information of each process on the server; The process information includes: process rules; The process marking each process according to the process information of each process includes: process marking each process according to the intersection principle based on the intersection of the process rules of each process.
8. The device according to claim 7, characterized in that The device also includes: A second acquisition module is used to acquire characteristic information of the server corresponding to each process; The connection module is used to connect to the server corresponding to each process according to the characteristic information of the server corresponding to each process.
9. A computer device, characterized in that: include: at least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor performs the steps of the multi-server resource monitoring method as described in any one of claims 1-6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the multi-server resource monitoring method according to any one of claims 1 to 6 are implemented.
