The content of the invention
The present invention provides a kind of data capture method and device, to by presetting tcp (Transmission
Control Protocol, transmission control protocol) interface sent to request of data end request of data when, can be read default
The performance data that performance sampling instrument gathers in advance, and then performance data is sent to the data by the tcp interfaces and asked
Ask end so that request of data end can the data that collect of active pull performance sampling instrument, this is advantageous to improve user's body
Test.
The present invention provides a kind of data capture method, including:
In the request of data sent by default tcp interfaces to request of data end, default capabilities collection work is read
Have the performance data gathered in advance, wherein, the request of data end is connected with the default tcp interfaces, and the default tcp
Interface is the interface on the server;
The performance data is sent to the request of data end by the tcp interfaces.
In one embodiment, before the performance data that default capabilities sampling instrument gathers in advance is read, methods described
Also include:
When the default capabilities sampling instrument collects the performance data, the performance data is stored to default
In socket interfaces;
The performance data for reading default capabilities sampling instrument and gathering in advance, including:
The performance data is read from the default socket interfaces.
In one embodiment, methods described also includes:
It is described to read the performance data from the default socket interfaces, including:
The default socket interfaces are accessed by xineted processes, to read the performance data;
The performance data is sent to the request of data end by the default tcp interfaces.
In one embodiment, the default capabilities sampling instrument includes Collected sampling instruments.
The present invention also provides a kind of data acquisition facility, including:
Read module, in the request of data sent by default tcp interfaces to request of data end, reading pre-
If the performance data that performance sampling instrument gathers in advance, wherein, the request of data end is connected with the default tcp interfaces,
And the default tcp interfaces are the interface on the server;
Sending module, for the performance data to be sent to the request of data end by the tcp interfaces.
In one embodiment, described device also includes:
Memory module, for before the performance data that default capabilities sampling instrument gathers in advance is read, being preset when described
When performance sampling instrument collects the performance data, the performance data is stored into default socket interfaces;
The read module includes:
Reading submodule, for reading the performance data from the default socket interfaces.
In one embodiment, described device also includes:
The reading submodule includes:
Access unit, for accessing the default socket interfaces by xineted processes, to read the performance number
According to;
Transmitting element, for being sent the performance data to the request of data end by the default tcp interfaces.
In one embodiment, the default capabilities sampling instrument includes Collected sampling instruments.
The technical scheme provided by this disclosed embodiment can include the following benefits:
In the request of data sent by default tcp interfaces to request of data end, default capabilities collection can be read
The performance data that instrument gathers in advance, and then performance data is sent to request of data end by tcp interfaces, so that data
Request end can the data that collect of active pull performance sampling instrument, this is advantageous to improve Consumer's Experience.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification
Obtain it is clear that or being understood by implementing the present invention.The purpose of the present invention and other advantages can be by the explanations write
Specifically noted structure is realized and obtained in book, claims and accompanying drawing.
Below by drawings and examples, technical scheme is described in further detail.
Embodiment
The preferred embodiments of the present invention are illustrated below in conjunction with accompanying drawing, it will be appreciated that described herein preferred real
Apply example to be merely to illustrate and explain the present invention, be not intended to limit the present invention.
In order to solve the above-mentioned technical problem, the embodiment of the present disclosure provides a kind of data capture method, and this method is applied to
In Data Acquisition Program, system or device, its executive agent is server, and the operating system of the server can be unix systems
System, such as can be Linux system, as shown in figure 1, step S101 and step S102, wherein:
In step S101, in the request of data sent by default tcp interfaces to request of data end, read pre-
If the performance data that performance sampling instrument gathers in advance, wherein, request of data end is connected with default tcp interfaces, and default tcp
Interface is the interface on server;
Wherein, request of data end can be the terminals such as mobile phone or server.
Performance data can be service condition of the system resources such as CPU usage, internal memory etc..
In step s 102, performance data is sent to request of data end by tcp interfaces.
In the request of data sent by default tcp interfaces to request of data end, default capabilities collection can be read
The performance data that instrument gathers in advance, and then performance data is sent to request of data end by tcp interfaces, so that data
Request end can the data that collect of active pull performance sampling instrument, this is advantageous to improve Consumer's Experience.
As shown in Fig. 2 in one embodiment, read performance data that default capabilities sampling instrument gathers in advance it
Before, method also includes:
In step s 201, when default capabilities sampling instrument collects performance data, performance data is stored to default
In socket interfaces;
Wherein, UNIX Domain Socket are the processes for same main frame to grow up on socket frameworks
Between communicate (IPC, Inter-Process Communication).
It is to store performance data to the buffer area of unix socket interfaces during storage.
The performance data that reading default capabilities sampling instrument in step S101 shown in above-mentioned Fig. 1 gathers in advance, including:
In step S202, the reading performance data from default socket interfaces.
Before reading performance data, default socket interfaces can be set up, then store performance data to default
In socket interfaces, during in order to need to pull the data at request of data end afterwards, it can be preset from this in socket interfaces
Read.
Wherein, the configuration process for presetting socket interfaces can be as follows:
#Unixsocket is configured
LoadPlugin unixsock
<Plugin unixsock>
SocketFile"/var/run/collectd-unixsock"
SocketGroup"root"
SocketPerms"0660"
DeleteSocket true
</Plugin>
In one embodiment, method also includes:
The reading performance data from default socket interfaces, including:
By xineted process access preset socket interfaces, with reading performance data;
Performance data is sent to request of data end by default tcp interfaces.
When reading the performance data, can be connect by the automatic access preset socket of xineted processes in executive agent
Mouthful, with reading performance data, and then performance data is automatically sent to by request of data end by default tcp interfaces, so that data
Request end being capable of the data that collect of active pull Collected sampling instruments.
In addition, above-mentioned xineted processes are used to intercept network request, the request service of association is called, request accesses specific
The network port, then xinetd call background process processing request, thus, if receiving above-mentioned request of data can also pass through
Xineted intercepts the default tcp interfaces to determine.
Wherein, xinetd configuration process can be as follows:
Xinetd is configured
service collectdstatus{
Type=UNLISTED
Port=25827
Socket_type=stream
Protocol=tcp
Wait=no
Cps=100 3
Instances=500
Per_source=250
Flags=NODELAY
User=root
Server=/usr/bin/ncat
Server_args=-U/var/run/collectd-unixsock
Disable=no
}
In one embodiment, default capabilities sampling instrument includes Collected sampling instruments.
As shown in figure 3, the present invention also provides a kind of data acquisition facility, including:
Read module 301, it is configured as in the request of data sent by presetting tcp interfaces to request of data end
When, the performance data that default capabilities sampling instrument gathers in advance is read, wherein, request of data end is connected with default tcp interfaces,
And default tcp interfaces are the interface on server;
Sending module 302, it is configured as by tcp interfaces sending performance data to request of data end.
As shown in figure 4, in one embodiment, device also includes:
Memory module 401, it is configured as before the performance data that default capabilities sampling instrument gathers in advance is read, when pre-
If performance sampling instrument collects performance data, performance data is stored into default socket interfaces;
Read module 301 includes:
Reading submodule 3011, it is configured as the reading performance data from default socket interfaces.
In one embodiment, device also includes:
Reading submodule 3011 includes:
Access unit, it is configured as by xineted process access preset socket interfaces, with reading performance data;
Transmitting element, it is configured as sending performance data to request of data end by default tcp interfaces.
In one embodiment, default capabilities sampling instrument includes Collected sampling instruments.
On the device in above-described embodiment, wherein modules perform the concrete mode of operation in relevant this method
Embodiment in be described in detail, explanation will be not set forth in detail herein.
Finally, the data acquisition facility in the present invention is applied to terminal device.For example, it may be mobile phone, computer,
Digital broadcast terminal, messaging devices, game console, tablet device, Medical Devices, body-building equipment, personal digital assistant
Deng.
It should be understood by those skilled in the art that, embodiments of the invention can be provided as method, system or computer program
Product.Therefore, the present invention can use the reality in terms of complete hardware embodiment, complete software embodiment or combination software and hardware
Apply the form of example.Moreover, the present invention can use the computer for wherein including computer usable program code in one or more
The shape for the computer program product that usable storage medium is implemented on (including but is not limited to magnetic disk storage and optical memory etc.)
Formula.
The present invention is the flow with reference to method according to embodiments of the present invention, equipment (system) and computer program product
Figure and/or block diagram describe.It should be understood that can be by every first-class in computer program instructions implementation process figure and/or block diagram
Journey and/or the flow in square frame and flow chart and/or block diagram and/or the combination of square frame.These computer programs can be provided
The processors of all-purpose computer, special-purpose computer, Embedded Processor or other programmable data processing devices is instructed to produce
A raw machine so that produced by the instruction of computer or the computing device of other programmable data processing devices for real
The device for the function of being specified in present one flow of flow chart or one square frame of multiple flows and/or block diagram or multiple square frames.
These computer program instructions, which may be alternatively stored in, can guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works so that the instruction being stored in the computer-readable memory, which produces, to be included referring to
Make the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one square frame of block diagram or
The function of being specified in multiple square frames.
These computer program instructions can be also loaded into computer or other programmable data processing devices so that counted
Series of operation steps is performed on calculation machine or other programmable devices to produce computer implemented processing, so as in computer or
The instruction performed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram one
The step of function of being specified in individual square frame or multiple square frames.
Obviously, those skilled in the art can carry out the essence of various changes and modification without departing from the present invention to the present invention
God and scope.So, if these modifications and variations of the present invention belong to the scope of the claims in the present invention and its equivalent technologies
Within, then the present invention is also intended to comprising including these changes and modification.