Summary of the invention
In order to solve the problem, the object of the invention is to, a kind of method for supervising and the system of extracting first floor system behavioural characteristic are provided, can the first floor system behavioural characteristic of capture operation system more accurately, the active state current to system is monitored.
For achieving the above object, the operating system method for supervising of the extraction first floor system behavioural characteristic that the present invention proposes, comprise: step 1, the parameter of the kernel function of Resourse Distribute event and abnormality processing event and rreturn value in acquisition operations system, described parameter and rreturn value are delivered to User space from system kernel, and are recorded on storage file; Step 2, is configured to eigenwert by described parameter and rreturn value under User space, and described eigenwert is recorded to training dataset, the active state of wherein said eigenwert reactive system; Step 3, obtains the eigenwert that operating system is current, judges based on the described training dataset recorded in a large number the active state that operating system is current.
The operating system method for supervising of extraction first floor system behavioural characteristic of the present invention, wherein, the kernel function of described Resourse Distribute event comprises slaballocator memory allocation function, kfree releasing memory space function and/or kmem_cache_alloc and distributes idle object function; The kernel function of described abnormality processing event comprises do_page_falut page fault process function.
The operating system method for supervising of extraction first floor system behavioural characteristic of the present invention, wherein, above-mentioned steps 1 comprises: step 11, creates relayfs file system passage during operating system initialization in operating system nucleus; Step 12, revises the monitoring mechanism to function call in existing Ftrace function; Step 13, adds the function of the stack information for recording kernel function in described relayfs file system passage, and the exit portion in described kernel function adds the function for the parameter and rreturn value recording described kernel function.
The operating system method for supervising of extraction first floor system behavioural characteristic of the present invention, wherein, above-mentioned steps 1 also comprises: step 14, distributes one unique No. ID, distinguish kernel function with No. ID for each kernel function.
The operating system method for supervising of extraction first floor system behavioural characteristic of the present invention, wherein, regularly reads parameter and the rreturn value of the kernel function recorded, is recorded on storage file under User space from relayfs file system passage.
The operating system method for supervising of extraction first floor system behavioural characteristic of the present invention, wherein, in step 2 above, is configured to the described parameter that described disk file records and rreturn value the eigenwert that eigenwert is configured to have following form,
(S
i,F
1(i,1),F
1(i,2),...,F
2(i,1),F
2(i,2),...,R
1(i),...,R
j(i))(1)
Wherein, S
ibe expressed as kernel function ID, R
ji () is expressed as the rreturn value of function when jth time to call this function, F
ji () is expressed as i-th parameter value of function when jth time to call this function, for all kernel function distribute the ID specified.
The operating system method for supervising of extraction first floor system behavioural characteristic of the present invention, wherein, adopts eigenwert described in machine learning classification Algorithm Analysis, and is recorded to training dataset.
The operating system method for supervising of extraction first floor system behavioural characteristic of the present invention, wherein, in above-mentioned steps 3, the parameter of the kernel function obtained within a period of time and rreturn value are as system current activity state eigenwert.
In addition, the present invention also proposes a kind of operating system supervising device adopting any one method above-mentioned to extract first floor system behavioural characteristic.
Effect of the present invention is: the present invention does not monitor all functions of kernel, but the parameter of the function of Resourse Distribute event main in monitoring kernel and abnormality processing event and rreturn value, the workload of supervisory system can be reduced, lower system overhead is utilized to extract abundant first floor system feature, and different forms method is resolved the system features obtained, adopt machine learning classification method training characteristics data set, thus the monitor message in system past can be utilized to find and resolution system is current may produced problem.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearly understand, below in conjunction with accompanying drawing, the operating system method for supervising of extraction first floor system behavioural characteristic of the present invention and device are further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, be not intended to limit the present invention.
In general, operating system nucleus is mainly divided into management of process, memory management, and Virtual File System and network management etc. provide system resource to upper layer application.In the present invention, by monitoring the parameter of wherein Chief function and rreturn value and the behavioural characteristic of system under extracting fixed mode.Do not monitor all functions of kernel with document 1 unlike method for supervising of the present invention, but monitor parameter and the rreturn value of the function of main Resourse Distribute event and abnormality processing event in kernel.For parameter and rreturn value, there is action messages a large amount of in current system.And the present invention is by the behavioural characteristic of the method application supervisory system, because the behavioural characteristic of system also comprises the management to memory source, to the management and management of process etc. of file system.And the parameter of wherein called kernel function has also been rich in a lot of information.Such as monitor memory management part, follow the tracks of the distribution condition of slaballocator memory allocation function.Comprise kfree releasing memory space function, kmem_cache_alloc distributes in the call parameters of the kernel function such as idle object function and has request dispatching memory size with the internal memory of application to which region, finally can follow the tracks of according to tracer the Information Statistics that software collects and analyze internal fragmentation situation, find out Memory Allocation code snippet the most frequently, etc.Also can obtain kernel to distribute in the recent period use structure frequently according to the parameter transmitted in Memory Allocation mechanism (slab mechanism).Monitoring for anomalous event is mainly the monitoring to do_page_falut page fault process function, but the return message of function contains the decision-making made some anomalous events, as core dumped appears in client layer, there is copy-on-write (copy) etc. in consumer process.
The present invention needs to revise kernel code, monitors specified function recalls information and creates the transmission of relayfs passage for monitor message when operating system initialization.Finally user's space start a finger daemon regularly from relayfs read record the details of function call, be recorded in disk file.To the recorded information structural attitude value in disk file, for the training dataset of last machine learning classification.
Relayfs is a file system forwarding (relay) data fast, and it is gained the name with its function.It needs the instrument from kernel spacing forwarding mass data to user's space and application to provide forwarding mechanism fast and effectively for those.Use this forwarding instrument to monitor the necessary information that obtains to client layer to transmit inner nuclear layer function, analyze for client layer.
Provide specific embodiments of the invention below, by reference to the accompanying drawings the present invention is described in detail.
As shown in Figure 1, the method for supervising of extraction first floor system behavioural characteristic of the present invention, comprising:
Step 1, in acquisition operations system, the parameter of the kernel function of Resourse Distribute event and abnormality processing event and rreturn value, be delivered to described parameter and rreturn value User space from system kernel, and be recorded in disk file;
Step 2, is configured to eigenwert by described parameter and rreturn value under User space, and described eigenwert is recorded to training dataset, the active state of wherein said eigenwert reactive system;
Step 3, obtains the eigenwert that operating system is current, judges based on the described training dataset recorded in a large number the active state that operating system is current.
Wherein, in step 1, when described parameter and rreturn value being delivered to User space from system kernel, need amendment kernel code (for Linux system), it specifically comprises:
Step 11, creates relayfs passage, under being delivered to User space for kernel state monitoring function call information.The establishment position selected, under init/main.c function, uses unlatching fast-forwarding function relay_open to create a passage in do_basic_setup initialization function.The application program of user's space makes its data available under user's space by using mapping function mmap () to carry out mapping created passage file.
Step 12, revises in existing Ftrace, mainly adds one section of stub stub code in the beginning of all kernel function to the monitoring mechanism of function call, and Ftrace heavy duty this section of code realizes following the trail of (trace) function.Recompile kernel can call perl script a: recordmcount.pl address of each function to be write a special section: _ mcount_loc. is at the initial stage of kernel initialization, Ftrace inquiry _ _ mcount_loc section, obtain the entry address of each function, and mcount is replaced with dummy instruction (nop instruction).So in default situations, Ftrace can not have an impact to core performance.When user opens Ftrace function, make Ftrace that these nop instructions are dynamically replaced with ftrace_caller, for trace function invoke user registered.The present invention needs amendment perl script by appointment monitoring kernel function name write section _ _ mcount_loc section, all adds mcount in kernel function entry address and exit address place.
Step 13, be illustrated in figure 3 the monitoring kernel input function parameter of the embodiment of the present invention and the schematic diagram of function return value, this there is shown the position of added code, the present invention adds self-defining function and namely starts the stack information (i.e. function call parameter information) that stub stub_start records kernel function, exit portion in monitored kernel function is added self-defining function and is namely terminated the rreturn value that stub stub_end records kernel function, and can directly by obtaining above-mentioned rreturn value in the register %eax of the use stack rule of acquiescence, 0 is just used to represent for not having the situation of rreturn value, wherein, the stack information (i.e. function call parameter information) of above-mentioned kernel function is that the mcount of the entrance by adding in step 12 is redirected to function stub_start's, above-mentioned function return value is (as shown on the solid line in figure 3) that the mcount of outlet by adding in step 12 is redirected to stub_end, finally the rreturn value of the kernel function recorded in the stack information (i.e. function call parameter information) of the kernel function recorded in above-mentioned stub_start function and above-mentioned stub_end function is sent to the relayfs passage (as shown in phantom in Figure 3) that step 11 creates.
Step 14, all distributes one unique No. ID to monitored kernel function, distinguishes kernel function by No. ID.
Then be need by according to the system activity eigenwert described in above-mentioned ID sequence number construction step 2 for training characteristics in machine learning, wherein the method for concrete structural attitude value is as follows:
The kernel function parameters that disk file records and rreturn value are configured to the eigenwert that eigenwert is configured to have following form,
(S
i,F
1(i,1),F
1(i,2),...,F
2(i,1),F
2(i,2),...,R
1(i),...,R
j(i))(1)
S
ibe expressed as kernel function ID (for each kernel function specifies a unique ID), R
ji () is expressed as the rreturn value of function when jth time to call this function, F
ji () is expressed as i-th parameter value of jth time call function.All monitored functions are that it distributes the ID that specifies, finally according to assigned I D sequence as feature.
For the collection of the kernel function parameters in step 1 and rreturn value, finger daemon can be started at user's space and regularly read from relayfs file system record function call details, be recorded in disk file.
Above-mentioned steps 3 relates to the analysis of operating system current activity state, specifically comprises:
Step 31, using the parameter of the kernel function in a period of time T (such as T is for 30min or 60min) and rreturn value as the eigenwert of current system active state, the method for structural attitude value to be described in foregoing.
Step 32, automatic analysis system behavior uses traditional statistical technique such as cluster, machine learning or based on the characteristic signature similarity-rough set searching for label, uses form in previous step to turn to the data of data as input of eigenwert form.Finally based on the Experiment Training data set recorded in a large number, judge what state current system is in by gathering current activity state eigenwert.
The overall design block diagram of the operating system method for supervising of the extraction first floor system behavioural characteristic of the embodiment of the present invention as shown in Figure 2.Be specially, step 10, the switch that run function calls, start to collect kernel function call information, relayfs file system passage can be created by the method for above-mentioned steps 11-step 13, the parameter of kernel function and rreturn value are delivered to User space from system kernel, and under User space, start the information of finger daemon periodic collection from relayfs file system; Step 20, carries out formatting definition to the data collected, and concrete define method can adopt the method for above-mentioned formula (1); Step 30, uses eigenwert described in machine learning classification Algorithm Analysis, and is recorded to training dataset, obtains the eigenwert that operating system is current, judges based on the described training dataset recorded in a large number the active state that operating system is current.
In addition, the present invention also proposes a kind of operating system supervising device 1 adopting the operating system method for supervising of said extracted first floor system behavioural characteristic to extract first floor system behavioural characteristic, it is formed as shown in Figure 4, specifically comprise: information extraction modules 11, for parameter and the rreturn value of the kernel function of Resourse Distribute event and abnormality processing event in acquisition operations system, described parameter and rreturn value are delivered to User space from system kernel, and are recorded in disk file; Formatting module 12, for described parameter and rreturn value being configured to eigenwert under User space, is recorded to training dataset by described eigenwert, the active state of wherein said eigenwert reactive system; State analyzing module 13, for obtaining the current eigenwert of operating system, judges based on the described training dataset recorded in a large number the active state that operating system is current.