Disclosure of Invention
The application provides a BMC log collection method and system, which are used for solving the problem that the log collection efficiency is lower due to the log collection method in the prior art.
In order to solve the technical problems, the embodiment of the application discloses the following technical scheme:
a method of BMC log collection, the method comprising:
Determining a log collection mode according to the acquired command, wherein the log collection mode comprises automatic collection and manual collection;
when the log collection mode is automatic collection, all the devices are subjected to priority classification according to the user behaviors and the device states, and the devices of the user behavior priority set and the devices of the device operation state priority set are determined;
Reading data in the user behavior priority set and the equipment running state priority set, and processing the data by adopting a mode of establishing an IP rule to determine equipment needing BMC log collection;
analyzing equipment information of equipment needing BMC log collection;
and collecting the device log according to the device information analysis result.
Optionally, when the log collection mode is automatic collection, prioritizing all devices according to user behaviors and device states, and determining devices of a user behavior priority set and devices of a device running state priority set, where the method includes:
when the log collection mode is automatic collection, carrying out priority classification on all the devices according to the device states, determining the devices of the device running state priority set, and updating the device running state priority set;
And prioritizing all the devices according to the user behaviors, determining the devices of the user behavior priority set, and updating the user behavior priority set.
Optionally, when the log collection mode is automatic collection, prioritizing all devices according to the device states, determining devices of a device operation state priority set, and updating the device operation state priority set, where the method includes:
acquiring alarm information of current equipment, wherein the alarm information comprises alarm types and alarm levels;
determining the equipment state of the current equipment according to the alarm type and the alarm level, wherein the equipment state sequentially comprises an emergency state, a moderate state, a slight state and a normal state from large to small according to the alarm level;
Adding the equipment in the emergency state into an equipment operation state priority set;
when the equipment state changes, judging whether the current equipment state exceeds the alarm level of the current equipment at the last moment;
if so, adding the current equipment to the equipment operation state priority set.
Optionally, the method for prioritizing all devices according to user behaviors, determining devices of a user behavior priority set, and updating the user behavior priority set includes:
recording the operation time of the user for carrying out log query according to the log query information of the user on any device;
Judging whether the frequency of log inquiry of a user on any equipment is more than or equal to a set frequency threshold value or not in a set time period;
if yes, adding any device into the user behavior priority set.
If not, the user behavior priority set is not updated.
Optionally, the set period of time is one week, and the set frequency threshold is 3 times.
Optionally, the determining a log collection mode according to the acquired command includes:
When the acquired command is a timing collection command, determining that the log collection mode is automatic collection;
And when the acquired command is a single collection command, determining that the log collection mode is manual collection.
Optionally, the method further comprises:
When the log collection mode is manual collection, a page request mode is adopted to send a BMC log collection request to equipment requiring log collection;
According to the acquired BMC log collecting request, the equipment needing to collect the log returns corresponding response information;
according to the response information, analyzing the equipment information of the equipment needing to collect the log;
and collecting the device log according to the device information analysis result.
Optionally, the processing the data by establishing an IP rule includes:
Processing the data by eliminating the data corresponding to the specified IP or the specified IP segment, or
And processing the data by adopting a mode of collecting the data corresponding to the specified IP or the specified IP section.
A BMC log collection system, the system comprising:
The log collection mode determining module is used for determining a log collection mode according to the acquired command, wherein the log collection mode comprises automatic collection and manual collection;
The priority classification module is used for classifying all the devices according to the user behaviors and the device states when the log collection mode is automatic collection, and determining the devices of the user behavior priority set and the devices of the device running state priority set;
The priority set data processing module is used for reading the data in the user behavior priority set and the equipment running state priority set, processing the data in a mode of establishing an IP rule, and determining equipment needing BMC log collection;
the analysis module is used for analyzing the equipment information of the equipment needing BMC log collection;
and the log collection module is used for collecting the equipment log according to the analysis result of the equipment information.
Optionally, the system further comprises a manual collection module, wherein when the log collection mode is manual collection, a BMC log collection request is sent to equipment requiring log collection by adopting a page request mode.
The technical scheme provided by the embodiment of the application can comprise the following beneficial effects:
The application provides a BMC log collecting method, which comprises the steps of firstly determining a log collecting mode according to an acquired command, when the log collecting mode is automatic collecting, distinguishing priorities of all devices according to user behaviors and device states, determining devices of a user behavior priority set and devices of a device running state priority set, secondly reading data in the user behavior priority set and the device running state priority set, processing the data in a mode of establishing an IP rule, determining devices needing BMC log collecting, then analyzing device information of the devices needing BMC log collecting, and finally collecting the device log according to a device information analysis result. When the log is automatically collected, the device is distinguished based on two dimensions of user behavior and device state, and the data in the limited set is processed to determine the device with higher priority, so that BMC log collection of the device with higher priority is ensured.
The application also provides a BMC log collection system which mainly comprises a log collection mode determining module, a priority dividing module, a priority set data processing module, an analyzing module and a log collection module. When the collection mode is automatic collection, all devices are prioritized according to two dimensions of user behaviors and device states through a priority dividing module, priority combination of a user behavior priority set and device operation states is determined, then related data are processed through a priority set data processing module in a mode of establishing IP rules, devices needing BMC log collection are determined, and therefore devices with higher priority levels can be selected to carry out BMC log collection.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application as claimed.
Detailed Description
In order to make the technical solution of the present application better understood by those skilled in the art, the technical solution of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, shall fall within the scope of the present application.
Logstack is an application log, transmission of events, processing, management and search platform. The log of the application program can be collected and managed by using the logstack unification, and a Web interface is provided for inquiring and counting and is responsible for collecting and filtering data. The elastsearch is a distributed free-of-charge open source search and analysis engine that is suitable for all types of data including text, numbers, geospatial, structured and unstructured data, and the like. The elastic search is known for its simple REST style API, distributed nature, speed and extensibility, and is a core component of ELASTIC STACK responsible for storing data. Kibana is an open source analysis and visualization platform, commonly used with elastiscearch. Kibana can be used to search for, view data stored in the elastesearch. Kibana and the elastic search are in various different charts, tables, maps and the like, and the data is intuitively displayed, so that the purposes of advanced data analysis and visualization are achieved.
For a better understanding of the present application, embodiments of the present application are explained in detail below with reference to the drawings.
Example 1
Referring to fig. 1, fig. 1 is a flow chart of a method for collecting BMC logs according to an embodiment of the present application. As can be seen from fig. 1, the BMC log collecting method in this embodiment mainly includes the following steps:
S1, determining a log collection mode according to the acquired command.
The log collection mode in the embodiment comprises automatic collection and manual collection. An automatic collection mode is conventionally adopted. When a user checks the log of a certain device, if the log of the device is not stored in the elastic search, triggering a manual collection operation of the BMC log of the device.
Specifically, step S1 includes the following procedure:
and S11, when the acquired command is a timing collection command, determining that the log collection mode is automatic collection.
In this embodiment, the automatic collection mode is a conventional mode, and usually a timing collection mode is adopted, that is, a fixed collection frequency is set, and the BMC log of the device is automatically collected once every set time.
And S12, when the acquired command is a single collection command, determining that the log collection mode is manual collection.
When the log collection mode is automatic collection, executing step S2, according to the user behavior and the device state, prioritizing all devices, and determining the devices of the user behavior priority set and the devices of the device running state priority set.
In this embodiment, when all devices are prioritized, the devices are prioritized according to two dimensions of user behavior and device state, where the device state has a higher priority than the user behavior, that is, the devices are prioritized according to the device state first, and then the devices are prioritized according to the user behavior. By the method, the influence of the priority attention device state on the running process of the server can be ensured, so that the running stability of the server is improved, and the log collecting efficiency is further improved. And under the condition that the total number of executable tasks in the background is certain, the priority mode can give the residual capacity to the user behavior priority equipment after the equipment priority is differentiated, so that the resource utilization rate is further improved.
Specifically, step S2 includes the following procedure:
And S21, when the log collection mode is automatic collection, prioritizing all the devices according to the device states, determining the devices of the device running state priority set, and updating the device running state priority set.
Specifically, step S21 further includes the following steps:
s211, acquiring alarm information of the current equipment. The alarm information at least comprises an alarm type and an alarm level.
S212, determining the device state of the current device according to the alarm type and the alarm level.
The device states in this embodiment include, in order from the large to the small in alarm level, an emergency state, a medium state, a light state, and a normal state.
And S213, adding the equipment in the emergency state into the equipment operation state priority set.
And S214, judging whether the current equipment state exceeds the alarm level of the current equipment at the last moment when the equipment state changes.
If the current device status exceeds the alert level for the current device at the previous time, step S215 is performed by adding the current device to the device operational status priority set.
If the current equipment state does not exceed the alarm level of the current equipment at the last moment, the current equipment is not changed.
In summary, when all devices are prioritized according to the device states, in general, the devices in an emergency state are added to the device operation state priority set, so that the device in the emergency state with a higher alarm level can be ensured, BMC log collection and update can be timely performed, and log collection efficiency is improved. When there is an abnormal change condition in the device status exceeding the alarm level of the current device at the previous time, the device is added to the device operation status priority set according to step S215. The method can ensure that BMC log collection and updating are timely carried out when the alarm level changes, thereby improving the running stability of equipment, being beneficial to improving the flexibility of BMC log collection, enabling the collection method to timely collect and update important logs according to different scenes and improving the log collection efficiency.
And S22, prioritizing all the devices according to the user behaviors, determining the devices of the user behavior priority set, and updating the user behavior priority set.
Specifically, step S22 further includes the following steps:
S221, according to log query information of a user on any device, recording operation time of the user for log query.
S222, judging whether the frequency of log inquiry of any equipment by a user is more than or equal to a set frequency threshold value in a set time period.
In this embodiment, the set period of time is one week, and the set frequency threshold is 3 times. The set time period and the set frequency threshold value can ensure that the user behavior priority set is updated in time, and excessive system resources are not occupied too frequently for updating, so that the storage and calculation system resources are saved.
If the frequency of log query of the user on any device is not less than the set frequency threshold, step S223 is executed to add any device to the user behavior priority set, thereby realizing the update of the user behavior priority set.
If the frequency of log query by the user on any device is less than the set frequency threshold, step S224 is performed without updating the user behavior priority set.
As can be seen from the above steps S221-S224, when the user performs a log query of a certain device, the method according to the present embodiment records the operation time and frequency of the user. And when the user queries that a certain device reaches a set frequency threshold in the last period of time, adding the device into the user behavior priority set, or updating the user behavior priority set according to a set rule.
With continued reference to fig. 1, after determining the devices of the user behavior priority set and the devices of the device running state priority set, step S3 is performed, where data in the user behavior priority set and the device running state priority set are read, and the data are processed by adopting a manner of establishing IP rules, so as to determine the device that needs to perform BMC log collection.
In this embodiment, a method of establishing an IP rule is used to process data, including two methods. The first is to process the data by eliminating the data corresponding to the appointed IP or the appointed IP section.
And the second is to process the data by collecting the data corresponding to the appointed IP or the appointed IP section.
That is, assuming that the data in the user behavior priority set and the device operation state priority set include first data and second data, data specifying an IP or a specified IP section is defined as the first data, and data other than the data specifying an IP or a specified IP section is defined as the second data. When the first mode is adopted, after the data in the user behavior priority set and the equipment running state priority set are read, the second data are removed, the first data are remained, and then equipment needing BMC log collection is determined according to the first data. And when the second mode is adopted, after the data in the user behavior priority set and the equipment running state priority set are read, collecting first data, and determining equipment needing BMC log collection according to the first data.
With continued reference to fig. 1, after determining the device that needs to perform BMC log collection, step S4 is performed to perform device information analysis on the device that needs to perform BMC log collection.
S5, collecting the device log according to the device information analysis result.
Further, the BMC log collecting method in this embodiment further includes:
and S6, when the log collection mode is manual collection, sending a BMC log collection request to equipment requiring log collection by adopting a page request mode.
And S7, according to the acquired BMC log collection request, the equipment needing to collect the log returns corresponding response information.
In the manual collection mode, after the equipment needing to collect the logs returns corresponding response information, the subsequent execution method is the same as the automatic collection mode, and equipment information analysis and equipment log collection are also carried out according to analysis results. Specifically, in step S4, equipment information analysis is carried out on equipment needing to collect logs according to response information.
S5, collecting the device log according to the device information analysis result.
Further, the BMC log collection method in the embodiment further comprises the step of manually updating the BMC log of the designated device according to the obtained manual update instruction.
Specifically, when a user needs to manually update a log file of a specific device, the user may manually click an update button, trigger log update after acquiring the update instruction, and individually update the BMC log of the specific device.
Example two
Referring to fig. 2 on the basis of the embodiment shown in fig. 1, fig. 2 is a schematic structural diagram of a BMC log collection system according to an embodiment of the present application. As can be seen from FIG. 2, the BMC log collection system in this embodiment mainly includes a log collection mode determining module, a priority classification module, a priority set data processing module, an analyzing module and a log collection module.
The log collection mode determining module is used for determining a log collection mode according to the acquired command, wherein the log collection mode comprises automatic collection and manual collection, the priority dividing module is used for carrying out priority division on all devices according to user behaviors and device states when the log collection mode is automatic collection, determining devices of a user behavior priority set and devices of a device running state priority set, the priority set data processing module is used for reading data in the user behavior priority set and the device running state priority set, processing the data in a mode of establishing an IP rule, determining devices needing BMC log collection, the analyzing module is used for carrying out device information analysis on the devices needing BMC log collection, and the log collection module is used for carrying out device log collection according to the device information analysis result.
The log collection mode determining module is used for determining that the log collection mode is automatic collection when the acquired command is a timing collection command, and determining that the log collection mode is manual collection when the acquired command is a single collection command.
The prioritizing module comprises a device status prioritizing unit and a user behavior prioritizing unit. The system comprises a log collection unit, a device state priority classification unit, a user behavior priority classification unit and a user behavior priority classification unit, wherein the device state priority classification unit is used for classifying all devices according to the device state when the log collection mode is automatic collection, determining the devices of a device running state priority set and updating the device running state priority set, and the user behavior priority classification unit is used for classifying all devices according to the user behaviors, determining the devices of the user behavior priority set and updating the user behavior priority set.
Further, the equipment state prioritizing unit further comprises an alarm information acquisition subunit, an equipment state determining subunit, a first adding subunit, a first judging unit and a second adding subunit. The alarm information acquisition subunit is used for acquiring the alarm information of the current equipment, the alarm information comprises an alarm type and an alarm level, the equipment state determination subunit is used for determining the equipment state of the current equipment according to the alarm type and the alarm level, the equipment state sequentially comprises an emergency state, a middle state, a slight state and a normal state from large to small according to the alarm level, the first adding subunit is used for adding equipment in the emergency state into the equipment operation state priority set, the first judging unit is used for judging whether the current equipment state exceeds the alarm level of the current equipment at the last moment when the equipment state changes, and the second adding subunit is used for adding the current equipment into the equipment operation state priority set when the current equipment state exceeds the alarm level of the current equipment at the last moment.
The user behavior prioritizing unit includes a recording subunit, a second judging subunit, and a third adding subunit. The system comprises a recording subunit, a second judging subunit and a third adding subunit, wherein the recording subunit is used for recording the operation time of the user for carrying out the log query according to the log query information of the user on any equipment, the second judging subunit is used for judging whether the frequency of the user for carrying out the log query on any equipment is more than or equal to a set frequency threshold value or not in a set time period, if the frequency of the user for carrying out the log query on any equipment is more than or equal to the set frequency threshold value, the third adding subunit is started, otherwise, if the frequency of the user for carrying out the log query on any equipment is less than the set frequency threshold value, the user behavior priority set is not updated. And the third adding subunit is used for adding any equipment into the user behavior priority set when the frequency of log query of the user on any equipment is more than or equal to a set frequency threshold value.
Further, in the BMC log collecting system of this embodiment, the system further includes a manual collecting module, configured to send a BMC log collecting request to a device that needs to collect logs by adopting a page request manner when the log collecting manner is manual collection.
The working principle and working method of the BMC log collecting system in this embodiment are described in detail in the embodiment shown in fig. 1, and reference may be made between the two embodiments, which are not described herein.
The foregoing is only a specific embodiment of the application to enable those skilled in the art to understand or practice the application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.