Summary of the invention
For addressing the above problem, the invention provides a kind of data processing method and system of physical machine resource information, to reduce the redundant information in transmission data.
To achieve the above object of the invention, the invention provides a kind of data processing method of physical machine resource information, the method comprises:
Step 1 is obtained the multidate information that the static information of physical machine and current time represent with the form of current state value or accumulated value from the resource information of linux order and the file of proc file system;
Step 2, obtains the new multidate information of physical machine again after 1 second, the data in the new multidate information that the form with accumulated value is represented deduct the data of the multidate information obtaining upper one second, obtain the resource using information in 1 second;
Step 3, creates low-redundancy data form: DTI for identification data type, and CI is for identification data position, and DRB is used for the data item of identification data subsequent transmission, the result that DV arranges in order for the value of identification data item;
Step 4, described static information, described new multidate information and the resource using information in described 1 second are represented with low-redundancy data form respectively, then send it to destination node, repeat above-mentioned steps, obtain the real-time resource information of this destination node.
Further, the static information acquisition methods in described step 1 comprises:
Step 11: extract IP address the output information of the ifconfig order of the network card configuration information of checking providing from Linux;
Step 12, reads the cpuinfo file in proc file system, obtains check figure and the frequency of processor;
Step 13, reads the meminfo file in proc file system, obtains always size of internal memory;
Step 14, reads the partitions file in proc file system, obtains always size of disk;
Step 15,, the output information of the dmesg order of checking each unit status providing from Linux, obtain the network bandwidth;
Step 16, reads the stat file in proc file system, has been obtained from the accumulated value of the processor use amount since start;
Step 17, reads the net/dev file in proc file system, has been obtained from the accumulated value of the network bandwidth use amount since start.
Further, the multidate information acquisition methods in described step 1 comprises:
Step 111, reads the stat file in proc file system, has been obtained from the accumulated value of the processor use amount since start;
Step 112, reads the meminfo file in proc file system, obtains internal memory use amount;
Step 113, extracts disk use amount the output information of the df order of checking disk resource providing from Linux;
Step 114, reads the net/dev file in proc file system, has been obtained from the accumulated value of the network bandwidth use amount since start.
Further, described step 2 comprises:
Step 21, has deducted by the accumulated value of described processor use amount since start the processor use amount accumulated value obtaining upper one second, obtains the use amount of the processor in this second;
Step 22, has deducted by described network bandwidth use amount accumulated value since start the network bandwidth use amount accumulated value obtaining upper one second, obtains the use amount of the network bandwidth in this second.
Further, in described step 3:
If data type has N
dTIkind, use every data before
position is as DTI, wherein
represent to be not less than the smallest positive integral of m;
Described CI, uses a bit representation, if this position is 1, represents that these data are not the last item in data message, if this position is 0, represents that these data are the last item of data message;
The value of the data item in described DV is adjustable length character string, before this character string, adds the length of this character string of byte representation;
The data item number of every class data is at most N
dRB, at least N of every data that use is transmitted
dRBposition is as DRB, and each corresponding data item of described DRB, if certain position is 1, represents the value that DV comprises this corresponding data item, if this position is 0, DV does not comprise the value of this data item.
Further, in described step 3:
If the data of software systems internal transmission only have a class, DTI can be left out; If the data item of the data of each transmission is all identical, DRB can be left out.
For achieving the above object, the present invention also provides a kind of data handling system of physical machine resource information, and this system comprises:
Acquisition of information module is obtained the multidate information that the static information of physical machine and current time represent with the form of current state value or accumulated value from the resource information of linux order and the file of proc file system;
Message processing module, obtains the new multidate information of physical machine again after 1 second, the data in the new multidate information that the form with accumulated value is represented deduct the data of the multidate information obtaining upper one second, obtain the resource using information in 1 second;
Form creation module, creates low-redundancy data form: DTI for identification data type, and CI is for identification data position, and DRB is used for the data item of identification data subsequent transmission, the result that DV arranges in order for the value of identification data item;
Result acquisition module, described static information, described new multidate information and the resource using information in described 1 second are represented with low-redundancy data form respectively, then send it to destination node, repeat above-mentioned module, obtain the real-time resource information of this destination node.
Further, described acquisition of information module comprises:
Extract IP address module, the output information of the ifconfig order of the network card configuration information of checking providing from Linux, extract IP address;
First reads proc file system module, read the cpuinfo file in proc file system, obtain check figure and the frequency of processor, read the meminfo file in proc file system, obtain always size of internal memory, read the partitions file in proc file system, obtain always size of disk, read the stat file in proc file system, be obtained from the accumulated value of the processor use amount since start, read the net/dev file in proc file system, be obtained from the accumulated value of the network bandwidth use amount since start;
Operation dmesg command module, obtains the network bandwidth the output information of the dmesg order of checking each unit status providing from Linux.
Further, described acquisition of information module also comprises:
Second reads proc file system module, read the stat file in proc file system, be obtained from the accumulated value of the processor use amount since start, read the meminfo file in proc file system, obtain internal memory use amount, read the net/dev file in proc file system, be obtained from the accumulated value of the network bandwidth use amount since start;
Carry out df module, the output information of the df order of checking disk resource providing from Linux, extract disk use amount.
Further, it is characterized in that, described message processing module comprises:
The first processing module, has deducted by the accumulated value of described processor use amount since start the processor use amount accumulated value obtaining upper one second, obtains the use amount of the processor in this second;
The second processing module, has deducted by described network bandwidth use amount accumulated value since start the network bandwidth use amount accumulated value obtaining upper one second, obtains the use amount of the network bandwidth in this second.
Beneficial effect of the present invention is: greatly reduced the redundancy in data transmission.If the present invention is used in large-scale supervisory system, can be by reducing the Internet Transmission be produced by monitor data, thus increased the extendability of supervisory system.And the method for image data of the present invention is the data of directly utilizing operating system to provide, there is not the expense of using intermediate data sampling instrument to bring.
Below in conjunction with the drawings and specific embodiments, describe the present invention, but not as a limitation of the invention.
Embodiment
Fig. 7 is the data processing method process flow diagram of physical machine resource information of the present invention.As shown in Figure 7, the method comprises:
S1 obtains the multidate information that the static information of physical machine and current time represent with the form of current state value or accumulated value from the resource information of linux order and the file of proc file system;
S2, obtains the new multidate information of physical machine again after 1 second, the data in the new multidate information that the form with accumulated value is represented deduct the data of the multidate information obtaining upper one second, obtain the resource using information in 1 second;
S3, creates low-redundancy data form: DTI for identification data type, and CI is for identification data position, and DRB is used for the data item of identification data subsequent transmission, the result that DV arranges in order for the value of identification data item;
S4, represents described static information, described new multidate information and the resource using information in described 1 second respectively with low-redundancy data form, then send it to destination node, repeats above-mentioned steps, obtains the real-time resource information of this destination node.
Further, the static information acquisition methods in described S1 comprises:
S11:, the output information of the ifconfig order of the information of checking network card configuration providing from Linux, extract IP address;
S12, reads the cpuinfo file in proc file system, obtains check figure and the frequency of processor;
S13, reads the meminfo file in proc file system, obtains always size of internal memory;
S14, reads the partitions file in proc file system, obtains always size of disk;
S15, obtains Netowrk tape the output information of the dmesg order of checking each unit status providing from Linux;
S16, reads the stat file in proc file system, has been obtained from the accumulated value of the processor use amount since start;
S17, reads the net/dev file in proc file system, has been obtained from the accumulated value of the network bandwidth use amount since start.
Further, the multidate information acquisition methods in described S1 comprises:
S111, reads the stat file in proc file system, has been obtained from the accumulated value of the processor use amount since start;
S112, reads the meminfo file in proc file system, obtains internal memory use amount;
S113,, the output information of the df order of checking disk resource providing from Linux, extract disk use amount;
S114, reads the net/dev file in proc file system, has been obtained from the accumulated value of the network bandwidth use amount since start.
Further, described S2 comprises:
S21, has deducted by the accumulated value of described processor use amount since start the processor use amount accumulated value obtaining upper one second, obtains the use amount of the processor in this second;
S22, has deducted by described network bandwidth use amount accumulated value since start the network bandwidth use amount accumulated value obtaining upper one second, obtains the use amount of the network bandwidth in this second.
Further, in described S3:
If data type has N
dTIkind, use every data before
position is as DTI, wherein
represent to be not less than the smallest positive integral of m;
Described CI, uses a bit representation, if this position is 1, represents that these data are not the last item in data message, if this position is 0, represents that these data are the last item of data message;
The value of the data item in described DV is adjustable length character string, before this character string, adds the length of this character string of byte representation;
The data item number of every class data is at most N
dRB, at least N of every data that use is transmitted
dRBposition is as DRB, and each corresponding data item of described DRB, if certain position is 1, represents the value that DV comprises this corresponding data item, if this position is 0, DV does not comprise the value of this data item.
Further, in described S3:
If the data of software systems internal transmission only have a class, DTI can be left out; If the data item of the data of each transmission is all identical, DRB can be left out.
Fig. 8 is the data handling system schematic diagram of physical machine resource information of the present invention.As shown in Figure 8, this system comprises:
Acquisition of information module 100 is obtained the multidate information that the static information of physical machine and current time represent with the form of current state value or accumulated value from the resource information of linux order and the file of proc file system;
Message processing module obtains the new multidate information of physical machine again after 200,1 seconds, the data in the new multidate information that the form with accumulated value is represented deduct the data of the multidate information obtaining upper one second, obtain the resource using information in 1 second;
Form creation module 300, creates low-redundancy data form: DTI for identification data type, and CI is for identification data position, and DRB is used for the data item of identification data subsequent transmission, the result that DV arranges in order for the value of identification data item;
Result acquisition module 400, described static information, described new multidate information and the resource using information in described 1 second are represented with low-redundancy data form respectively, then send it to destination node, repeat above-mentioned module, obtain the real-time resource information of this destination node.
Further, described acquisition of information module 100 comprises:
Extract IP address module, the output of the information ifconfig order of checking network card configuration providing from Linux, extract IP address;
First reads proc file system module, read the cpuinfo file in proc file system, obtain check figure and the frequency of processor, read the meminfo file in proc file system, obtain always size of internal memory, read the partitions file in proc file system, obtain always size of disk, read the stat file in proc file system, be obtained from the accumulated value of the processor use amount since start, read the net/dev file in proc file system, be obtained from the accumulated value of the network bandwidth use amount since start;
Operation dmesg command module, obtains the network bandwidth the dmesg order of checking each unit status providing from Linux.
Further, described acquisition of information module 100 also comprises:
Second reads proc file system module, read the stat file in proc file system, be obtained from the accumulated value of the processor use amount since start, read the meminfo file in proc file system, obtain internal memory use amount, read the net/dev file in proc file system, be obtained from the accumulated value of the network bandwidth use amount since start;
Carry out df module, the output information of the df order of checking disk resource providing from Linux, extract disk use amount.
Further, it is characterized in that, described message processing module 200 comprises:
The first processing module, has deducted by the accumulated value of described processor use amount since start the processor use amount accumulated value obtaining upper one second, obtains the use amount of the processor in this second;
The second processing module, has deducted by described network bandwidth use amount accumulated value since start the network bandwidth use amount accumulated value obtaining upper one second, obtains the use amount of the network bandwidth in this second.
Further, in described form creation module 300:
If data type has N
dTIkind, use every data before
position is as DTI, wherein
represent to be not less than the smallest positive integral of m;
Described CI, uses a bit representation, if this position is 1, represents that these data are not the last item in data message, if this position is 0, represents that these data are the last item of data message;
The value of the data item in described DV is adjustable length character string, before this character string, adds the length of this character string of byte representation;
The data item number of every class data is at most N
dRB, at least N of every data that use is transmitted
dRBposition is as DRB, and each corresponding data item of described DRB, if certain position is 1, represents the value that DV comprises this corresponding data item, if this position is 0, DV does not comprise the value of this data item.
Further, in described form creation module 300:
If the data of software systems internal transmission only have a class, DTI can be left out; If the data item of the data of each transmission is all identical, DRB can be left out.
Resource information acquisition method of the present invention towards be (SuSE) Linux OS, order and proc file system that information source provides for Linux, proc file system mainly comprises the service condition of total resources and resource, and resource service condition has been that the form with the accumulated value (as the load of CPU and transmission volume etc.) since start and current state (as the use amount of internal memory use amount and disk etc.) represents.
A data message can comprise one or more data.Use the data representation method in this invention, the expression of complete data is as Fig. 1, and the expression of a datagram with many data is as Fig. 2.
The supervisory system of a large scale system, the data of transmission are totally two classes: static data and dynamic data.The data item that every class data wherein comprise (size and the unit of supposing each data item occurrence, following numeral all represents with 10 systems) is as follows:
Static data (totally 6): the network address (10.10.10.10, account for 4 bytes), (8 of processor check figures, account for a byte), processor frequencies (2048MHZ, account for two bytes), the total size of internal memory (4192MB, account for two bytes), the total size of disk (140272MB, account for four bytes) and network interface card bandwidth (1000Mbps accounts for two bytes).
Dynamic data (totally 5): the network address (10.10.10.10 accounts for 4 bytes), processor load (123MHZ, account for two bytes), internal memory use amount (2001MB, account for two bytes), disk use amount (2013MB, account for four bytes) and network interface card bandwidth use amount (28Mbps accounts for two bytes).
Wherein processor load and network interface card bandwidth use amount are to have represented with the form of accumulated value since start, other all represent with the form of current state.Because the data of this software systems internal transmission are totally two classes, so the DTI of every data is
position, 1 represents static data, 0 represents dynamic data.DRB is 6: for static data, 6 (first to the 6th) of DRB are map network address, processor check figure, processor frequencies, the total size of internal memory, the total size of disk and network interface card bandwidth successively; For dynamic data, first 5 (first to the 5th) of DRB are map network address, processor load, internal memory use amount, disk use amount and network interface card bandwidth use amount successively.
For ease of realizing, by a byte, represent the 8th of DTI(), the 7th of CI() and first 6 of DRB().
The concrete steps of data acquisition are as follows:
Steps A: utilize the multidate information that the static information of file acquisition physical machine of number order that Linux provides and proc file system and this moment represent with the form of accumulated value;
Step B: the static information obtaining is processed into the data message of low redundancy, sends to the destination node that need to obtain this physical machine information;
Step C:1 after second from newly read the multidate information of physical machine from the file of proc file system;
Step D: the multidate information representing for the form with accumulated value, the data that step C is obtained deduct respectively the data of obtaining before 1 second, obtain the resource service condition in this 1 second;
Step e: the multidate information that take that step C the is obtained multidate information that current state is representation and step D calculate is processed into the data message of low redundancy, sends to the destination node that need to obtain this physical machine information;
Step F: repeating step C ?E, destination node just can obtain the real-time resource information of this node.
Wherein the concrete steps of steps A are:
Steps A 1: the information of checking network card configuration in operation ifconfig(Linux), extract the IP address (10.10.10.10) in output information;
Steps A 2: read the cpuinfo file in proc file system, obtain check figure (8) and the frequency (2048MHZ) of processor;
Steps A 3: read the meminfo file in proc file system, obtain the total size of internal memory (4192MB);
Steps A 4: read the partitions file in proc file system, obtain the total size of disk (140272MB);
Steps A 5: operation dmesg order (order of checking each unit status that Linux provides), obtain the network bandwidth (1000Mbps);
Steps A 6: read the stat file in proc file system, be obtained from the accumulated value of the processor use amount since start;
Steps A 7: read the net/dev file in proc file system, be obtained from the accumulated value of the network bandwidth use amount since start.
The data message that in step B, processing obtains is as Fig. 3, and wherein BF (scale-of-two is 10111111) is for representing 8 figure places of DTI, CI and DRB, and remaining represents respectively the value of each static data item.
Step C comprises again step:
Step C1: read the stat file in proc file system, be obtained from the accumulated value of the processor use amount since start;
Step C2: read the meminfo file in proc file system, obtain internal memory use amount (2001MB);
Step C3: carry out the order of checking disk resource that df(Linux provides), from this order output information, extract disk use amount (2013MB);
Step C4: read the net/dev file in proc file system, be obtained from the accumulated value of the network bandwidth use amount since start;
Step D comprises step:
Step D1: the processor use amount accumulated value that step C1 is obtained deducts the processor use amount accumulated value that upper one second, (from steps A 6 or step C1) obtained, obtains the use amount (123MHZ) of the processor in this second;
Step D2: the network bandwidth use amount accumulated value that step C4 is obtained deducts the network bandwidth use amount accumulated value that upper one second, (from steps A 7 or step C4) obtained, obtains the use amount (28Mbps) of the network bandwidth in this second;
The data message that step e processing obtains is as Fig. 4, and wherein 1F (scale-of-two is 00011111) is for representing 8 figure places of DTI, CI and DRB, and remaining represents respectively the value of each Dynamic Data Items.
If send together with the dynamic data that the static data that steps A is obtained obtains with step C, the data message these data processings being obtained is as Fig. 5, wherein FF (scale-of-two is 11111111) and 1F (scale-of-two is 00011111) are respectively and represent DTI, the CI of Static and dynamic data and front 8 figure places of DRB, the CI of static data is the 7th of 1(FF) represent to also have data (dynamic data) after these data, and the CI of dynamic data is 0(1F the 7th) represent that these data are the last item.
If destination node only needs to obtain the dynamic data of processor load, internal memory use amount and the disk use amount of this physical machine node, the datagram that step e processing obtains is as Fig. 6, and wherein 0F (scale-of-two is 00001111) is for representing 8 figure places of DTI, CI and DRB.DRB is 0F (scale-of-two is 01111), represents that the DV in the data of this data message only contains the value of the network address, processor load, internal memory use amount and disk use amount, does not comprise network interface card bandwidth use amount.
Use data representation method of the present invention need to know the data class number of software systems internal transmission and the number of the data item that every class packet contains.For value, be that digital data item need to be known this data item size.
The DTI of every data is for the type of identification data.The total N of data of a software systems internal transmission
dTIclass, use every data before
(
representing to be not less than the smallest positive integral of m) position is as DTI, represents the type of these data.
That follow DTI closely is CI, uses a bit representation.If this position is 1, represent that these data are not the last item in data message, otherwise, represent that these data are the last item of data message.
After CI, be DRB, for identifying its follow-up data item.The data item number of every class data is at most N
dRB, at least N of every data that use is transmitted
dRBposition is as DRB.Each corresponding data item of DRB.In DRB, if certain position is 1, represent the value that DV comprises this corresponding data item, otherwise DV does not comprise the value of this data item.
The result that last DV arranges the value of each data item for the order of formulating according to CI.If this value is adjustable length character string, before this character string, add the length of this character string of byte representation.
If the data of software systems internal transmission only have a class, DTI can be left out; If the data item of the data of each transmission is all identical, DRB can be left out.Thereby further reduce the redundancy of software inhouse transmission data.
Certainly; the present invention also can have other various embodiments; in the situation that not deviating from spirit of the present invention and essence thereof; those of ordinary skill in the art are when making according to the present invention various corresponding changes and distortion, but these corresponding changes and distortion all should belong to the protection domain of the appended claim of the present invention.