CN105630653A - CPU vacancy rate determination method and device for Docker container - Google Patents

CPU vacancy rate determination method and device for Docker container Download PDF

Info

Publication number
CN105630653A
CN105630653A CN201610147661.6A CN201610147661A CN105630653A CN 105630653 A CN105630653 A CN 105630653A CN 201610147661 A CN201610147661 A CN 201610147661A CN 105630653 A CN105630653 A CN 105630653A
Authority
CN
China
Prior art keywords
cpu
detected
clock number
period
idle
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
CN201610147661.6A
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.)
Juhaokan Technology Co Ltd
Original Assignee
Qingdao Hisense Media Network 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 Qingdao Hisense Media Network Technology Co Ltd filed Critical Qingdao Hisense Media Network Technology Co Ltd
Priority to CN201610147661.6A priority Critical patent/CN105630653A/en
Publication of CN105630653A publication Critical patent/CN105630653A/en
Pending legal-status Critical Current

Links

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/3024Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3409Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment
    • G06F11/3433Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment for performance assessment for load management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Computer Hardware Design (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the invention provides a CPU vacancy rate determination method and device for a Docker container.The method includes the steps that one or more CPU indicators corresponding to the Docker container are obtained; the total clock number and the idle clock number of all the CPUs within the to-be-detected time frame corresponding to the to-be-detected moment are obtained according to indicators of the CPUs; according to the total clock number and the idle clock number of the CPUs within the to-be-detected time frame, the CPU vacancy rate of the Docker container within the to-be-detected time frame is determined.The CPU vacancy rate determination method and device for the Docker container aim at achieving the effect that the Docker container still can precisely determine the CPU vacancy rate of the Docker container within the to-be-detected moment under the condition that the usage condition of the CPUs by other Dockers cannot be known in the Docker container.

Description

The idle rate defining method of the CPU of Docker container and device
Technical field
The embodiment of the present invention relates to field of computer technology, particularly relates to the idle rate defining method of CPU and the device of a kind of Docker container.
Background technology
Docker container is a kind of application container engine increased income, it is possible to by integrated for multiple application program in a Docker container, and by this Docker container by multiple application issued in terminal.
At present, a terminal can be run multiple Docker container, each Docker container can use identical central processing unit (CentralProcessingUnit is called for short CPU) resource, such as, terminal comprises 3 CPU, it is designated as CPU1-CPU3 respectively, terminal is run 2 Docker containers, is designated as Docker container 1 and Docker container 2 respectively, then Docker container 1 can use CPU1 and CPU2, Docker container 2 to use CPU2 and CPU3. In actual application, application program in order to ensure in Docker container can normally be run, Docker container needs its available residue CPU resource (the idle rate of CPU) to be monitored, when the idle rate of CPU of Docker container is less than predetermined threshold value, generate alarm message, so that Docker container is detected and safeguards by operation personnel.
But, in the prior art, due to mutually isolated between each Docker container in terminal, make cannot intercom mutually between each Docker container, when the CPU that a Docker container uses is used by other Docker containers simultaneously, this Docker container cannot obtain other Docker container to the service condition of this CPU, and this Docker container is in moment CPU to be detected idle rate to cause this Docker container to determine accurately.
Summary of the invention
The embodiment of the present invention provides the idle rate defining method of the CPU of a kind of Docker container and device, in order to realize to know that other Docker containers are to, under the service condition of CPU, Docker container still can determine the CPU idle rate of Docker container in the moment to be detected accurately at Docker container.
First aspect, the embodiment of the present invention provides the CPU of a kind of Docker container defining method of idle rate, comprising:
Obtain the mark of at least one CPU corresponding to described Docker container;
Respectively according to the mark of each described CPU, obtain the total clock number of each described CPU within period to be detected corresponding to moment to be detected and idle clock number;
According to the total clock number of each described CPU within the described period to be detected and idle clock number, it is determined that described Docker container is in the idle rate of CPU in described moment to be detected.
Method as above, for the arbitrary CPU at least one CPU described, according to the mark of described CPU, obtains the total clock number of described CPU within the described period to be detected, comprising:
Obtain the time length and the clock requency of described CPU of described period to be detected;
Time length and described clock requency according to the described period to be detected, it is determined that the total clock number of described CPU within the described period to be detected.
Method as above, for the arbitrary CPU at least one CPU described, according to the mark of described CPU, obtains the total clock number of described CPU within the described period to be detected, comprising:
Mark according to described CPU, obtains the first record file of the mark correspondence of described CPU, and described first record file comprises the total clock number of described CPU between Startup time to each moment;
Described first record file in, obtain described CPU described Startup time to the described period to be detected the initial moment between total clock number and described CPU described Startup time to the described period to be detected end time between total clock number;
According to described CPU at described Startup time to total clock number between described Startup time to described end time of the total clock number between the described initial moment and described CPU, obtain the total clock number of described CPU within the described period to be detected.
Method as above, for the arbitrary CPU at least one CPU described, according to the mark of described CPU, obtains the idle clock number of described CPU within the described period to be detected, comprising:
Mark according to described CPU, obtains the 2nd record file of the mark correspondence of described CPU, and described 2nd record file comprises the idle clock number of described CPU between Startup time to each moment;
Described 2nd record file in, obtain described CPU described Startup time to the described period to be detected the initial moment between idle clock number and described CPU described Startup time to the described period to be detected end time between idle clock number;
According to described CPU at described Startup time to idle clock number between described Startup time to described end time of the idle clock number between the described initial moment and described CPU, obtain the idle clock number of described CPU within the period to be detected.
Method as above, according to the total clock number of each described CPU within the period to be detected and idle clock number, it is determined that described Docker container, in the idle rate of CPU in described moment to be detected, comprising:
According to the total clock number of each described CPU within the period to be detected and idle clock number, it is determined that the idle rate of each described CPU, and determine that the CPU idle rate of described Docker container within the described period to be detected is the mean value of the idle rate of each described CPU; Or,
Obtain the total clock number sum of each described CPU within the period to be detected and each described CPU idle clock number sum within the period to be detected, according to described total clock number sum and described idle clock number sum, it is determined that described Docker container is in the idle rate of CPU in described moment to be detected.
Method as above, it is determined that the mark of the CPU that described Docker container is corresponding, comprising:
Obtain the configuration file that described Docker container is corresponding;
In described configuration file, obtain the mark of CPU corresponding to Docker container.
Method as above, described according to the total clock number of each described CPU within the described period to be detected and idle clock number, it is determined that described Docker container, after the idle rate of CPU in described moment to be detected, also comprises:
Judge whether the CPU idle rate of described Docker container in the described moment to be detected is less than predetermined threshold value;
If determining, the CPU idle rate of described Docker container in the described moment to be detected is less than predetermined threshold value, then generate alarm message.
Second aspect, the embodiment of the present invention provides the CPU of a kind of Docker container determining device of idle rate, comprising:
First acquisition module, for obtaining the mark of at least one CPU corresponding to described Docker container;
2nd acquisition module, for respectively according to the mark of each described CPU, obtains the total clock number of each described CPU within period to be detected corresponding to moment to be detected;
3rd acquisition module, for respectively according to the mark of each described CPU, obtains the idle clock number of each described CPU within period to be detected corresponding to moment to be detected;
Determination module, for according to the total clock number of each described CPU within the described period to be detected and idle clock number, it is determined that described Docker container is in the idle rate of CPU in described moment to be detected.
Device as above, described 2nd acquisition module specifically for:
Obtain the time length and the clock requency of described CPU of described period to be detected;
Time length and described clock requency according to the described period to be detected, it is determined that the total clock number of described CPU within the described period to be detected.
Device as above, described 2nd acquisition module concrete also for:
Mark according to described CPU, obtains the first record file of the mark correspondence of described CPU, and described first record file comprises the total clock number of described CPU between Startup time to each moment;
Described first record file in, obtain described CPU described Startup time to the described period to be detected the initial moment between total clock number and described CPU described Startup time to the described period to be detected end time between total clock number;
According to described CPU at described Startup time to total clock number between described Startup time to described end time of the total clock number between the described initial moment and described CPU, obtain the total clock number of described CPU within the described period to be detected.
The defining method of the idle rate of the CPU of the Docker container that the embodiment of the present invention provides and device, when needing to obtain the CPU free time rate of Docker container in the moment to be detected, by obtaining the mark of at least one CPU corresponding to Docker container, respectively according to the mark of each CPU, obtain the total clock number of each CPU within period to be detected corresponding to moment to be detected and idle clock number, and according to the total clock number of each CPU within the period to be detected and idle clock number, it is determined that Docker container is in the idle rate of CPU in moment to be detected. In above process, by CPU corresponding to Docker container in total clock number of period to be detected and idle clock number, that can determine the CPU resource that Docker container is corresponding accurately takies situation, when Docker container cannot know other Docker containers to the service condition of CPU, Docker container still can determine the CPU idle rate of Docker container in the moment to be detected accurately.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, it is briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, it is also possible to obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is the application scene schematic diagram of Docker container provided by the invention;
Fig. 2 is the schema of the defining method of the idle rate of CPU of Docker container provided by the invention;
Fig. 3 is the schema one of the acquisition total clock number of CPU within the period to be detected provided by the invention;
Fig. 4 is the flowchart 2 of the acquisition total clock number of CPU within the period to be detected provided by the invention;
Fig. 5 is the schema of the acquisition idle clock number of CPU within the period to be detected provided by the invention;
Fig. 6 is the structure iron one of the determining device of the idle rate of CPU of Docker container provided by the invention;
Fig. 7 is the structure iron two of the determining device of the idle rate of CPU of Docker container provided by the invention.
Embodiment
For making the object of the embodiment of the present invention, technical scheme and advantage clearly, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is the present invention's part embodiment, instead of whole embodiments. Based on the embodiment in the present invention, those of ordinary skill in the art, not making other embodiments all obtained under creative work prerequisite, belong to the scope of protection of the invention.
Fig. 1 is the application scene schematic diagram of Docker container provided by the invention, please refer to Fig. 1, the operating system of terminal is run Docker container 1 (101-A) and Docker container 2 (101-B), it is provided with CPU1 (102-A), CPU2 (102-B) and CPU3 (102-C) in the terminal, wherein, Docker container 1 can use CPU1 and CPU2, Docker container 2 can use CPU2 and CPU3. In actual application, Docker container 1 and Docker container 2 independent calculate the idle rate of respective CPU. Below, by specific embodiment, defining method and device to the idle rate of the CPU of Docker container are described in detail.
Fig. 2 is the schema of the defining method of the idle rate of CPU of Docker container provided by the invention, and please according to Fig. 1, the method can comprise:
S201, the mark obtaining at least one CPU corresponding to Docker container;
S202, respectively according to the mark of each CPU, obtain the total clock number of each CPU within period to be detected corresponding to moment to be detected and idle clock number;
S203, according to the total clock number of each CPU within the period to be detected and idle clock number, it is determined that Docker container is in the idle rate of CPU in moment to be detected.
The executive agent of the embodiment of the present invention can be the determining device (hereinafter referred determining device) of the idle rate of CPU of Docker container, and this determining device can be arranged on Docker internal tank.
In embodiments of the present invention, Docker container at least one CPU corresponding, in actual application, can when creating Docker container, it is Docker container allocation CPU by resource management module, optionally, after completing CPU for Docker container allocation, the corresponding relation of Docker container and CPU can be kept in configuration file by resource management module, such as, in Linux system, resource management module can be cgroups module, community enterprise operations system (CommunityEnterpriseOperatingSystem in Linux system, it is called for short CentOS) in, configuration file can be the file in following path :/sys/fs/cgroup/cpuset/system.slice/docker-{ longid}.Scope/cpuset.cpus.
In embodiments of the present invention, the period to be detected of its correspondence it is carved with when each is to be detected, period to be detected can be a time period before or after the moment to be detected, such as, assume that the moment to be detected is 10 zeros zero second (10:00:00) of certain day, then the period to be detected can be 9: 59: 58 (09:59:58)-10:00:00, can also be 09:59:59-10:00:01, can also be 10:00:00-10:00:03, in actual application, can arrange according to actual needs the period to be detected time long, preferably, the time length of period to be detected is 2 seconds, the corresponding relation in period to be detected and moment to be detected can also be set according to actual needs, this is not done concrete restriction by the present invention.
In actual application, when determining device needs to obtain the CPU free time rate of Docker container in the moment to be detected, first obtain the mark of at least one CPU corresponding to Docker container, optionally, can first obtain configuration file corresponding to Docker container, and in configuration file, obtain the mark of CPU corresponding to Docker container.
Acquire the mark of at least one CPU corresponding to Docker container in determining device after, obtain the total clock number of each CPU within period to be detected corresponding to moment to be detected and idle clock number, wherein, the number of the total clock of CPU within the period to be detected refers to the clock number that CPU experiences within the period to be detected, the idle clock number of CPU in the period to be detected refers to the number of the idle clock that CPU experiences within the period to be detected, acquire the total clock number of each CPU within period to be detected corresponding to moment to be detected and idle clock number in determining device after, according to the total clock number of each CPU within the period to be detected and idle clock number, determine the CPU idle rate of Docker container in the moment to be detected.
Below, by concrete example, the method shown in Fig. 2 embodiment is described in detail.
Exemplary, assume corresponding two CPU of Docker container 1, being designated as CPU1 and CPU2 respectively, when determining device needs to obtain the CPU free time rate of Docker container 1 in moment T1 to be detected, the period to be detected (T2-T3) that moment T1 to be detected is corresponding first determined by Docker container 1.
Determining device according to the mark of CPU1, obtains the total clock number 100 of CPU1 within the T2-T3 period and the CPU1 idle clock number 20 within the T2-T3 period.
Determining device according to the mark of CPU2, obtains the total clock number 200 of CPU2 within the T2-T3 period and the CPU2 idle clock number 30 within the T2-T3 period.
Then determining device can determine that the CPU idle rate of Docker container 1 in moment T1 to be detected is:
The defining method of the idle rate of the CPU of the Docker container that the embodiment of the present invention provides, when needing to obtain the CPU free time rate of Docker container in the moment to be detected, by obtaining the mark of at least one CPU corresponding to Docker container, respectively according to the mark of each CPU, obtain the total clock number of each CPU within period to be detected corresponding to moment to be detected and idle clock number, and according to the total clock number of each CPU within the period to be detected and idle clock number, it is determined that Docker container is in the idle rate of CPU in moment to be detected. In above process, by CPU corresponding to Docker container in total clock number of period to be detected and idle clock number, that can determine the CPU resource that Docker container is corresponding accurately takies situation, when Docker container cannot know other Docker containers to the service condition of CPU, Docker container still can determine the CPU idle rate of Docker container in the moment to be detected accurately.
On basis embodiment illustrated in fig. 2, it is possible to obtain the total clock number of CPU within the period to be detected by the implementation that the following two kinds is feasible, concrete, refer to the embodiment shown in Fig. 3-Fig. 4.
Fig. 3 is the schema one of the acquisition total clock number of CPU within the period to be detected provided by the invention, refers to Fig. 3, and the method can comprise:
S301, the time length and the clock requency of CPU obtaining the period to be detected;
S302, time length and clock requency according to the period to be detected, it is determined that the total clock number of CPU within the period to be detected.
In the embodiment shown in fig. 3, when determining device needs to obtain the total clock number of CPU within the period to be detected, first obtain the period to be detected time long, and the clock requency of CPU, wherein, the clock requency of CPU is the attribute value of CPU, period to be detected time length can for user pre-set time long, when determining device acquires the period to be detected long, and after the clock requency of CPU, time length and clock requency according to the period to be detected, determine the total clock number of CPU within the period to be detected, concrete, the total clock number of CPU within the period to be detected can be: the period to be detected time length (unit is the second) with the product of clock requency, not only can determine to obtain the total clock number of CPU within the period to be detected accurately by this kind of mode, the speed obtaining the total clock number of CPU within the period to be detected can also be improved, and then realize determining the CPU idle rate of Docker container in the moment to be detected fast.
Exemplary, when determining device needs to obtain the total clock number of CPU1 within the period to be detected, determining device first obtain the period to be detected time long, the time length assuming the period to be detected is 2 seconds, the clock requency of CPU1 is 100HZ again, then determining device can determine that the total clock number of CPU1 within the period to be detected is 2*100=200.
Fig. 4 is the flowchart 2 of the acquisition total clock number of CPU within the period to be detected provided by the invention, refers to Fig. 4, and the method can comprise:
S401, mark according to CPU, obtain the first record file of the mark correspondence of CPU, and the first record file comprises the total clock number of CPU between Startup time to each moment;
S402, first record file in, obtain CPU Startup time to the period to be detected the initial moment between total clock number and CPU Startup time to the period to be detected end time between total clock number;
S403, according to CPU at Startup time to total clock number between Startup time to end time of the total clock number between the initial moment and CPU, obtain the total clock number of CPU within the period to be detected.
In the embodiment shown in fig. 3, before CPU starts work, total clock number of CPU is zero, after CPU starts to start work (such as, starting up of terminal), start the total clock to CPU to count, CPU often experiences a clock, then total clock number of CPU adds 1, for the ease of recording in the first record file, it is possible to total clock number of every second record CPU in the first record file; Exemplary, it is assumed that the clock requency of CPU1 is 100HZ, that is, CPU1 experiences 100 clocks in 1 second, then terminal start in zero second when 0. 0, and every second total clock number to CPU1 carries out once record, then the first record file can be as shown in table 1.
Table 1
Moment Total clock number of CPU1
00:00:00-00:00:01 0
00:00:00-00:00:01 100
00:00:00-00:00:02 200
���� ����
00:00:00-00:00:10 1000
���� ����
In actual application, when needing to obtain the total clock number of CPU within the period to be detected, the first mark according to CPU obtains the first record file of the mark correspondence of CPU, wherein, first record file can only comprise this CPU in total clock number corresponding to each moment, it is also possible to comprise other CPU in total clock number corresponding to each moment.
After obtaining the first record file, determining device needs the initial moment obtaining the period to be detected and end time, then according to the initial moment, first record file obtains total clock number corresponding to initial moment, according to end time, in the first record file, obtain total clock number corresponding to end time; Then, the total clock number corresponding according to the initial moment and total clock number corresponding to end time, obtain the total clock number of CPU within the period to be detected, concrete, the total clock number of CPU within the period to be detected can be: the difference of total clock number that total clock number corresponding to end time is corresponding with the initial moment.
In this kind of feasible implementation, owing to CPU often experiences a clock, total clock number of CPU all can be added up by the first record file, by the first record file, the total clock number of CPU within the period to be detected can be obtained accurately, and then improve the accuracy determining Docker container in the idle rate of CPU in moment to be detected.
Exemplary, when determining device needs to obtain the total clock number of CPU1 within the period to be detected, determining device obtains the first record file corresponding to CPU1, and obtain the initial moment (T1) of period to be detected and the end time (T2) of period to be detected, it is then determined that device obtains total clock number (N1) corresponding to T1 moment and total clock number (N2) corresponding to T2 moment in the first record file, then determining device can determine that the total clock number of CPU1 within the period to be detected is N2-N1.
On the basis of any one embodiment above-mentioned, it is possible to obtain the idle clock number of CPU within the period to be detected by implementation feasible as follows, concrete, shown in Figure 5 embodiment.
Fig. 5 is the schema of the acquisition idle clock number of CPU within the period to be detected provided by the invention, refers to Fig. 5, and the method can comprise:
S501, mark according to CPU, obtain the 2nd record file of the mark correspondence of CPU, and the 2nd record file comprises the idle clock number of CPU between Startup time to each moment;
S502, the 2nd record file in, obtain CPU Startup time to the period to be detected the initial moment between idle clock number and CPU Startup time to the period to be detected end time between idle clock number;
S503, according to CPU at Startup time to idle clock number between Startup time to end time of the idle clock number between the initial moment and CPU, obtain the idle clock number of CPU within the period to be detected.
In the embodiment shown in fig. 5, before CPU starts work, the idle clock number of CPU is zero, after CPU starts to start work (such as, starting up of terminal), start the idle clock to CPU to count, when CPU is in idle state in a certain clock, then the number of the idle clock of CPU is added 1, for the ease of recording in the 2nd record file, it is possible to total clock number of every second record CPU in the 2nd record file; Wherein, the storage mode of the 2nd record file and embodiment illustrated in fig. 4 in the storage mode of the first file similar, no longer repeat herein.
It should be noted that, the 2nd record file with embodiment illustrated in fig. 4 in first record file can be two independent record files, it is possible to thinking same record file, this is not done concrete restriction by the present invention.
Also it should be noted that, the process of the middle acquisition idle clock number of CPU within the period to be detected embodiment illustrated in fig. 5, similar with the process of the total clock number of middle acquisition CPU embodiment illustrated in fig. 4 within the period to be detected, no longer repeat herein.
In this kind of feasible implementation, owing to CPU often experiences an idle clock, the idle clock number of CPU all can be added up by the 2nd record file, by the 2nd record file, the idle clock number of CPU within the period to be detected can be obtained accurately, and then improve the accuracy determining Docker container in the idle rate of CPU in moment to be detected.
On the basis of any one embodiment above-mentioned, optionally, it is possible to by the implementation that the following two kinds is feasible, according to the total clock number within the period to be detected and the idle clock number of each CPU, determine the CPU idle rate of Docker container in the moment to be detected, concrete:
A kind of feasible implementation:
According to the total clock number of each CPU within the period to be detected and idle clock number, it is determined that the idle rate of each CPU, and determine that the CPU idle rate of Docker container within the period to be detected is the mean value of the idle rate of each CPU;
In this kind of feasible implementation, after obtaining the total clock number of each CPU within the period to be detected and idle clock number, can first determine the idle rate of each CPU, then the mean value of the idle rate of each CPU is defined as the CPU idle rate of Docker container within the period to be detected.
Exemplary, it is assumed that corresponding two CPU of Docker container 1, are designated as CPU1 and CPU2 respectively.
Assume that the total clock number of CPU1 within the period to be detected is 100, idle clock number is 20, then the idle rate of CPU1 within the period to be detected is
Assume that the total clock number of CPU2 within the period to be detected is 200, idle clock number is 30, then the idle rate of CPU2 within the period to be detected is
Then determining device can determine that the idle rate of the CPU of Docker container 1 within the period to be detected is
Another kind of feasible implementation:
Obtain the total clock number sum of each CPU within the period to be detected and each CPU idle clock number sum within the period to be detected, according to total clock number sum and idle clock number sum, it is determined that Docker container is in the idle rate of CPU in moment to be detected.
In this kind of feasible implementation, after obtaining the total clock number of each CPU within the period to be detected and idle clock number, obtain the total clock number sum of each CPU within the period to be detected and idle clock number sum, according to total clock number sum and idle clock number sum, determine the CPU idle rate of Docker container in the moment to be detected, concrete, the CPU idle rate of Docker container in the moment to be detected is: the ratio of idle clock number sum and total clock number sum.
Exemplary, it is assumed that corresponding two CPU of Docker container 1, are designated as CPU1 and CPU2 respectively.
Assume that the total clock number of CPU1 within the period to be detected is 100, to be the total clock number of 20, CPU2 within the period to be detected be idle clock number 200, idle clock number is 30.
Then the total clock number sum of CPU1 and CPU2 within the period to be detected is idle clock number sum within the period to be detected of 100+200=300, CPU1 and CPU2 is 20+30=50.
Then determining device can determine that the idle rate of the CPU of Docker container 1 within the period to be detected is
On the basis of any one embodiment above-mentioned, after determining device determines to obtain the CPU idle rate of Docker container in the moment to be detected, can also judge whether the CPU idle rate of Docker container in the moment to be detected is less than predetermined threshold value, if, generate alarm message, to notify that Docker container is detected and safeguards by operation personnel.
Fig. 6 is the structure iron one of the determining device of the idle rate of CPU of Docker container provided by the invention, please refer to Fig. 6, and this device can comprise:
First acquisition module 601, for obtaining the mark of at least one CPU corresponding to Docker container;
2nd acquisition module 602, for respectively according to the mark of each CPU, obtains the total clock number of each CPU within period to be detected corresponding to moment to be detected;
3rd acquisition module 603, for respectively according to the mark of each CPU, obtains the idle clock number of each CPU within period to be detected corresponding to moment to be detected;
Determination module 604, for according to the total clock number of each CPU within the period to be detected and idle clock number, it is determined that Docker container is in the idle rate of CPU in moment to be detected.
In actual application, optionally, the 2nd acquisition module 602 specifically may be used for:
Obtain the time length and the clock requency of CPU of period to be detected;
Time length and clock requency according to the period to be detected, it is determined that the total clock number of CPU within the period to be detected.
Optionally, the 2nd acquisition module 602 specifically can also be used for:
Mark according to CPU, obtains the first record file of the mark correspondence of CPU, and the first record file comprises the total clock number of CPU between Startup time to each moment;
First record file in, obtain CPU Startup time to the period to be detected the initial moment between total clock number and CPU Startup time to the period to be detected end time between total clock number;
According to CPU at Startup time to total clock number between Startup time to end time of the total clock number between the initial moment and CPU, obtain the total clock number of CPU within the period to be detected.
Optionally, the 3rd acquisition module 603 specifically may be used for:
Mark according to CPU, obtains the 2nd record file of the mark correspondence of CPU, and the 2nd record file comprises the idle clock number of CPU between Startup time to each moment;
The 2nd record file in, obtain CPU Startup time to the period to be detected the initial moment between idle clock number and CPU Startup time to the period to be detected end time between idle clock number;
According to CPU at Startup time to idle clock number between Startup time to end time of the idle clock number between the initial moment and CPU, obtain the idle clock number of CPU within the period to be detected.
In actual application, it is determined that module 604 specifically may be used for:
According to the total clock number of each CPU within the period to be detected and idle clock number, it is determined that the idle rate of each CPU, and determine that the CPU idle rate of Docker container within the period to be detected is the mean value of the idle rate of each CPU; Or,
Obtain the total clock number sum of each CPU within the period to be detected and each CPU idle clock number sum within the period to be detected, according to total clock number sum and idle clock number sum, it is determined that Docker container is in the idle rate of CPU in moment to be detected.
Optionally, the first acquisition module 601 specifically may be used for:
Obtain the configuration file that Docker container is corresponding;
In configuration file, obtain the mark of CPU corresponding to Docker container.
Fig. 7 is the structure iron two of the determining device of the idle rate of CPU of Docker container provided by the invention, on basis embodiment illustrated in fig. 6, please refer to Fig. 7, and this device can also comprise and judges module 605 and generation module 606, wherein,
Judge module 605 for, at determination module according to the total clock number of each CPU within the period to be detected and idle clock number, determine that Docker container is after the idle rate of CPU in moment to be detected, judge whether the CPU free time rate of Docker container in the moment to be detected is less than predetermined threshold value;
Generation module 606 for, when judging that module judges that Docker container is less than predetermined threshold value in the idle rate of CPU in moment to be detected, generate alarm message.
Device described in the embodiment of the present invention can perform the technical scheme shown in Fig. 1-Fig. 5 embodiment, its realize principle and useful effect similar, no longer repeat herein.
One of ordinary skill in the art will appreciate that: all or part of step realizing above-mentioned each embodiment of the method can be completed by the hardware that programmed instruction is relevant. Aforesaid program can be stored in a computer read/write memory medium. This program, when performing, performs the step comprising above-mentioned each embodiment of the method; And aforesaid storage media comprises: ROM, RAM, magnetic disc or CD etc. various can be program code stored medium.
Last it is noted that above each embodiment is only in order to illustrate the technical scheme of the present invention, it is not intended to limit; Although with reference to foregoing embodiments to invention has been detailed description, it will be understood by those within the art that: the technical scheme described in foregoing embodiments still can be modified by it, or wherein some or all of technology feature is carried out equivalent replacement; And these amendments or replacement, do not make the scope of the essence disengaging various embodiments of the present invention technical scheme of appropriate technical solution.

Claims (10)

1. the defining method of the idle rate of the CPU of a Docker container, it is characterised in that, comprising:
Obtain the mark of at least one CPU corresponding to described Docker container;
Respectively according to the mark of each described CPU, obtain the total clock number of each described CPU within period to be detected corresponding to moment to be detected and idle clock number;
According to the total clock number of each described CPU within the described period to be detected and idle clock number, it is determined that described Docker container is in the idle rate of CPU in described moment to be detected.
2. method according to claim 1, it is characterised in that, for the arbitrary CPU at least one CPU described, according to the mark of described CPU, obtain the total clock number of described CPU within the described period to be detected, comprising:
Obtain the time length and the clock requency of described CPU of described period to be detected;
Time length and described clock requency according to the described period to be detected, it is determined that the total clock number of described CPU within the described period to be detected.
3. method according to claim 1, it is characterised in that, for the arbitrary CPU at least one CPU described, according to the mark of described CPU, obtain the total clock number of described CPU within the described period to be detected, comprising:
Mark according to described CPU, obtains the first record file of the mark correspondence of described CPU, and described first record file comprises the total clock number of described CPU between Startup time to each moment;
Described first record file in, obtain described CPU described Startup time to the described period to be detected the initial moment between total clock number and described CPU described Startup time to the described period to be detected end time between total clock number;
According to described CPU at described Startup time to total clock number between described Startup time to described end time of the total clock number between the described initial moment and described CPU, obtain the total clock number of described CPU within the described period to be detected.
4. method according to the arbitrary item of claim 1-3, it is characterised in that, for the arbitrary CPU at least one CPU described, according to the mark of described CPU, obtain the idle clock number of described CPU within the described period to be detected, comprising:
Mark according to described CPU, obtains the 2nd record file of the mark correspondence of described CPU, and described 2nd record file comprises the idle clock number of described CPU between Startup time to each moment;
Described 2nd record file in, obtain described CPU described Startup time to the described period to be detected the initial moment between idle clock number and described CPU described Startup time to the described period to be detected end time between idle clock number;
According to described CPU at described Startup time to idle clock number between described Startup time to described end time of the idle clock number between the described initial moment and described CPU, obtain the idle clock number of described CPU within the period to be detected.
5. method according to the arbitrary item of claim 1-3, it is characterised in that, according to the total clock number of each described CPU within the period to be detected and idle clock number, it is determined that described Docker container, in the idle rate of CPU in described moment to be detected, comprising:
According to the total clock number of each described CPU within the period to be detected and idle clock number, it is determined that the idle rate of each described CPU, and determine that the CPU idle rate of described Docker container within the described period to be detected is the mean value of the idle rate of each described CPU; Or,
Obtain the total clock number sum of each described CPU within the period to be detected and each described CPU idle clock number sum within the period to be detected, according to described total clock number sum and described idle clock number sum, it is determined that described Docker container is in the idle rate of CPU in described moment to be detected.
6. method according to the arbitrary item of claim 1-3, it is characterised in that, it is determined that the mark of the CPU that described Docker container is corresponding, comprising:
Obtain the configuration file that described Docker container is corresponding;
In described configuration file, obtain the mark of CPU corresponding to Docker container.
7. method according to the arbitrary item of claim 1-3, it is characterized in that, described according to the total clock number of each described CPU within the described period to be detected and idle clock number, it is determined that described Docker container, after the idle rate of CPU in described moment to be detected, also comprises:
Judge whether the CPU idle rate of described Docker container in the described moment to be detected is less than predetermined threshold value;
If determining, the CPU idle rate of described Docker container in the described moment to be detected is less than predetermined threshold value, then generate alarm message.
8. the determining device of the idle rate of the CPU of a Docker container, it is characterised in that, comprising:
First acquisition module, for obtaining the mark of at least one CPU corresponding to described Docker container;
2nd acquisition module, for respectively according to the mark of each described CPU, obtains the total clock number of each described CPU within period to be detected corresponding to moment to be detected;
3rd acquisition module, for respectively according to the mark of each described CPU, obtains the idle clock number of each described CPU within period to be detected corresponding to moment to be detected;
Determination module, for according to the total clock number of each described CPU within the described period to be detected and idle clock number, it is determined that described Docker container is in the idle rate of CPU in described moment to be detected.
9. device according to claim 8, it is characterised in that, described 2nd acquisition module specifically for:
Obtain the time length and the clock requency of described CPU of described period to be detected;
Time length and described clock requency according to the described period to be detected, it is determined that the total clock number of described CPU within the described period to be detected.
10. device according to claim 8, it is characterised in that, described 2nd acquisition module concrete also for:
Mark according to described CPU, obtains the first record file of the mark correspondence of described CPU, and described first record file comprises the total clock number of described CPU between Startup time to each moment;
Described first record file in, obtain described CPU described Startup time to the described period to be detected the initial moment between total clock number and described CPU described Startup time to the described period to be detected end time between total clock number;
According to described CPU at described Startup time to total clock number between described Startup time to described end time of the total clock number between the described initial moment and described CPU, obtain the total clock number of described CPU within the described period to be detected.
CN201610147661.6A 2016-03-15 2016-03-15 CPU vacancy rate determination method and device for Docker container Pending CN105630653A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610147661.6A CN105630653A (en) 2016-03-15 2016-03-15 CPU vacancy rate determination method and device for Docker container

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610147661.6A CN105630653A (en) 2016-03-15 2016-03-15 CPU vacancy rate determination method and device for Docker container

Publications (1)

Publication Number Publication Date
CN105630653A true CN105630653A (en) 2016-06-01

Family

ID=56045626

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610147661.6A Pending CN105630653A (en) 2016-03-15 2016-03-15 CPU vacancy rate determination method and device for Docker container

Country Status (1)

Country Link
CN (1) CN105630653A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106897203A (en) * 2017-03-29 2017-06-27 北京经纬恒润科技有限公司 A kind of cpu load rate computational methods and device
CN107819802A (en) * 2016-09-13 2018-03-20 华为软件技术有限公司 A kind of mirror image acquisition methods, node device and server in node cluster
CN109298913A (en) * 2018-09-26 2019-02-01 武芮 The method and device of schedules system resources between a kind of multi-vessel system
CN111552614A (en) * 2020-04-28 2020-08-18 杭州迪普科技股份有限公司 Statistical method and device for CPU utilization rate
CN114090371A (en) * 2021-10-28 2022-02-25 苏州浪潮智能科技有限公司 Port utilization rate determining method and device, electronic equipment and readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622290A (en) * 2012-03-07 2012-08-01 苏州阔地网络科技有限公司 Process monitoring method and system
CN104899126A (en) * 2015-06-12 2015-09-09 北京奇虎科技有限公司 Method, device and system for performing local real-time monitoring on containers in host
CN104950757A (en) * 2015-06-12 2015-09-30 北京奇虎科技有限公司 Container monitoring method and system
CN104951360A (en) * 2015-06-30 2015-09-30 北京奇虎科技有限公司 Configuration management mode and device based on Docker

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102622290A (en) * 2012-03-07 2012-08-01 苏州阔地网络科技有限公司 Process monitoring method and system
CN104899126A (en) * 2015-06-12 2015-09-09 北京奇虎科技有限公司 Method, device and system for performing local real-time monitoring on containers in host
CN104950757A (en) * 2015-06-12 2015-09-30 北京奇虎科技有限公司 Container monitoring method and system
CN104951360A (en) * 2015-06-30 2015-09-30 北京奇虎科技有限公司 Configuration management mode and device based on Docker

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
华为DOCKER实践小组: "《Docker进阶与实战》", 29 February 2016, 机械工业出版社 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107819802A (en) * 2016-09-13 2018-03-20 华为软件技术有限公司 A kind of mirror image acquisition methods, node device and server in node cluster
CN107819802B (en) * 2016-09-13 2021-02-26 华为技术有限公司 Mirror image obtaining method in node cluster, node equipment and server
CN106897203A (en) * 2017-03-29 2017-06-27 北京经纬恒润科技有限公司 A kind of cpu load rate computational methods and device
CN109298913A (en) * 2018-09-26 2019-02-01 武芮 The method and device of schedules system resources between a kind of multi-vessel system
CN111552614A (en) * 2020-04-28 2020-08-18 杭州迪普科技股份有限公司 Statistical method and device for CPU utilization rate
CN114090371A (en) * 2021-10-28 2022-02-25 苏州浪潮智能科技有限公司 Port utilization rate determining method and device, electronic equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN105630653A (en) CPU vacancy rate determination method and device for Docker container
CN108205424B (en) Data migration method and device based on disk and electronic equipment
CN108108127B (en) File reading method and system
CN106326067B (en) A kind of method and device that cpu performance is monitored under pressure test
CN110019502B (en) Synchronization method between primary database and backup database, database system and device
CN110537170B (en) Method, system and computer readable storage device for analyzing large scale data processing jobs
CN106897342B (en) Data verification method and equipment
CN110718264A (en) Method and device for testing information of solid state disk, computer equipment and storage medium
JP2008310748A (en) Task execution time recording device, task execution time recording method, and task execution recording program
CN110515795A (en) A kind of monitoring method of big data component, device, electronic equipment
CN108009223B (en) Method and device for detecting consistency of transaction data
CN107491372A (en) A kind of method and system for linux system RPM bags statistics CPU usage
CN110018932B (en) Method and device for monitoring container magnetic disk
US8219858B2 (en) Method for testing hard disks under an extensible firmware interface
CN109471901B (en) Data synchronization method and device
CN103279408A (en) RAID (redundant array of inexpensive disk) performance testing method
CN107766131B (en) Task scheduling method and device
CN111367710B (en) eMMC problem reduction method and device
CN111159051A (en) Deadlock detection method and device, electronic equipment and readable storage medium
CN113886342A (en) File format conversion method and device, storage medium and processor
US9864668B2 (en) Apparatus, method, and system for event data processing
CN114416442A (en) Hardware change detection method and device, electronic equipment and readable storage medium
US20140298354A1 (en) Information processing apparatus, information processing method, and storage medium
CN106959888B (en) Task processing method and device in cloud storage system
CN112328550A (en) File management method and device under distributed file system architecture

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C41 Transfer of patent application or patent right or utility model
TA01 Transfer of patent application right

Effective date of registration: 20161230

Address after: 266100 Shandong Province, Qingdao city Laoshan District Songling Road No. 399

Applicant after: Poly Polytron Technologies Inc

Address before: 266100 Laoshan, Qingdao province Hongkong District No. East Road, room 248, room 131

Applicant before: Hisense Media Networks Co., Ltd.

RJ01 Rejection of invention patent application after publication

Application publication date: 20160601

RJ01 Rejection of invention patent application after publication