Disclosure of Invention
In order to overcome the defects in the prior art, the invention provides a method for processing monitoring data of a server under linux, which comprises the following steps:
starting a server test program, continuously acquiring a test data stream, and traversing each test file information of the test data stream;
identifying the file name of each piece of test file information according to a preset rule, and storing the identified test file information into a database according to a preset storage mode;
and calling the test file information of the storage identifier in the database according to a preset condition, backing up the called test file information, and storing the backed-up test file information to a backup memory.
Preferably, the step of continuously acquiring the test data stream and traversing each test file information of the test data stream further includes:
and acquiring the test data stream from the http request, and traversing each piece of test file information of the whole test data stream by using while circulation.
Preferably, the step of identifying the file name of each piece of test file information according to a preset rule, and storing the identified test file information in a database according to a preset storage manner further includes:
and according to the UTF-8 code, the header of the file name of each piece of test file information is used as an identifier, a timestamp for acquiring the test file information is added to each piece of test file information, the test file information is arranged into a csv data format, and the test file information is sorted according to the receiving sequence of the test data stream and stored in a database after being sorted.
Preferably, the step of storing to the database according to a preset storage manner further comprises:
setting a time period storage folder according to a preset time period, and storing a test data stream acquired in the preset time period into the time period storage folder;
and when the ending time point of the preset time period is reached, storing the time period storage folder into a database.
Preferably, the step of storing to the database according to a preset storage manner further comprises:
and in the database, configuring a type folder according to the type of each file in the test data stream, and storing the type folder into a corresponding type folder according to the type of the received file.
Preferably, the step of retrieving the test file information of the storage identifier in the database according to the preset condition, backing up the retrieved test file information, and storing the backed-up test file information to the backup memory further includes:
setting a backup time point and a backup time period;
when the system runs to the set backup time point, starting backup, creating database connection, generating a backup session link, calling test file information stored in the database in the backup time period according to the set backup time period, backing up the test file information stored in the database in the backup time period, and storing the backup file in the backup database.
Preferably, the step of retrieving the test file information of the storage identifier in the database according to the preset condition, backing up the retrieved test file information, and storing the backed-up test file information to the backup memory further includes:
setting a backup time point, setting a backup time period and setting a test node;
when the system runs to the set backup time point, starting backup, creating database connection, generating a backup session link, calling test file information stored in the database in the backup time period and sent by the test node according to the set backup time period and the test node, backing up the test file information, and storing the backup file in the backup database.
Preferably, the step of retrieving the test file information of the storage identifier in the database according to the preset condition, backing up the retrieved test file information, and storing the backed-up test file information to the backup memory further includes:
setting a backup time point, setting a backup time period and setting a backup test file type;
when the system runs to the set backup time point, starting backup, creating database connection, generating a backup session link, calling test file information with the backup test file type stored in the database in the backup time period according to the set backup time period and the backup test file type, backing up the test file information, and storing the backup file in the backup database.
According to the technical scheme, the invention has the following advantages:
the test file capturing method provided by the invention has the advantages that the storage space of the server is more reasonably and efficiently utilized, the waste of resources is avoided, the loss of data can be prevented through timely and reasonable file backup, and the loss of data can be prevented through timely and reasonable file backup.
According to the invention, the test data and the test files are backed up and stored based on the setting of the user in the test process, and when the test data is lost in the midway of the test data storage device caused by external factors or internal factors, the data in the SEL log after the pressure test is finished is prevented from being incomplete, so that the evaluation of the test result is prevented from being influenced.
The invention can set backup time points and backup time periods; setting a backup time point, setting a backup time period and setting a test node; setting a backup time point, setting a backup time period and setting a backup test file type; therefore, testers can set important attention according to needs or extract and back up data influencing a test result, and corresponding data are called in a back-up database, so that the sorting and planning of the test data are facilitated.
Detailed Description
The invention provides a processing method of server monitoring data under linux, as shown in figure 1, the method comprises the following steps:
s1, starting a server test program, continuously acquiring a test data stream, and traversing each test file information of the test data stream;
and acquiring the test data stream from the http request, and traversing each piece of test file information of the whole test data stream by using while circulation.
S2, identifying the file name of each test file information according to a preset rule, and storing the identified test file information into a database according to a preset storage mode;
the method comprises the steps of coding a header serving as a file name of each piece of test file information according to UTF-8 as an identifier, adding a timestamp for obtaining the test file information to each piece of test file information, sorting the test file information into a csv data format, sorting according to a receiving sequence of a test data stream, and storing the sorted test file information in a database. The file name of each test file information is uniformly identified, so that subsequent uniform processing, sorting and query can be conveniently carried out on the files. The processing mode may include backup, deletion, modification, addition and replacement of files, and the like. Of course, the present invention is mainly to backup the test data file.
The captured test data is sorted here, and the sensors of different nodes are identified with prefixes, such as "101 _" indicating the sensor of node 101. And time stamping all sensors into csv data format.
The change curve of the sensor along with the time can be made through an EXCEL tool and the like for the csv data format. And realizing the visualization of data.
The implementation here may be as follows:
and S3, calling the test file information of the storage identifier in the database according to the preset condition, backing up the called test file information, and storing the backed-up test file information to a backup memory.
In the invention, a sensor is captured under linux and a data sorting method is completed. The change state of the hardware sensor along with the test time needs to be observed in the server test, the sensor state can be obtained through the method, and data are sorted into a visual curve along with the change of the time. Has certain effect on improving the product quality.
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions of the present invention will be clearly and completely described below with reference to specific embodiments and drawings. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the scope of protection of this patent.
In the embodiment provided by the present invention, as shown in fig. 2,
s11, starting a server test program, continuously acquiring a test data stream, and traversing each test file information of the test data stream; of course, the test data stream may be obtained from the http request, and the while loop is used to traverse each test file information of the whole test data stream.
S12, setting a time period storage folder according to a preset time period, and storing the test data stream acquired in the preset time period into the time period storage folder;
and S13, when the ending time point of the preset time period is reached, storing the time period storage folder into a database. The method comprises the steps of coding a header serving as a file name of each piece of test file information according to UTF-8 as an identifier, adding a timestamp for obtaining the test file information to each piece of test file information, sorting the test file information into a csv data format, sorting according to a receiving sequence of a test data stream, and storing the sorted test file information in a database.
And S14, calling the test file information of the storage identifier in the database according to the preset condition, backing up the called test file information, and storing the backed-up test file information to a backup memory.
The computer program product of the computer readable medium may form part of, which may include, packaging materials. The computer-readable medium of data may include computer storage media such as Random Access Memory (RAM), Read Only Memory (ROM), non-volatile random access memory (NVRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory, magnetic or optical data storage media, and the like. In some embodiments, an article of manufacture may comprise one or more computer-readable storage media.
In the embodiment provided by the invention, data can be processed according to each test node. Starting a server test program, continuously acquiring a test data stream, and traversing each test file information of the test data stream; of course, the test data stream may be obtained from the http request, and the while loop is used to traverse each test file information of the whole test data stream.
In a database, setting a corresponding node storage folder according to a pre-temperature test node, and storing a test data stream sent by the temperature test node into the node storage folder. And uniformly identifying each file name according to the UTF-8 codes, sequencing according to the receiving sequence of the test data stream, and storing the sequenced data stream to a database.
And calling the test file information stored in the database according to a preset condition, processing the called test file information, and updating the current storage state of the database after the processing is finished.
Certainly, the present invention is not limited to the temperature test node, and may also include a network port communication rate test node, a processor data processing amount test node, a hard disk data reading test node, a hard disk data storage test node, a memory test, and the like.
In the embodiment provided by the invention, a server test program is started, a test data stream is continuously acquired, and information of each test file of the test data stream is traversed; identifying the file name of each piece of test file information according to a preset rule, and storing the identified test file information into a database according to a preset storage mode; and configuring a type folder according to the type of each file in the test data stream in the database, and storing the type folder into a corresponding type folder according to the type of the received file. The file types here may include: TXT files, DOC files, XLS files, PPT files, DOCX files, XLSX files, PPTX files, JPG, PNG, PDF, TIFF, SWF, RAR, EXE, FLV, RMVB files, and the like. And uniformly identifying each file name according to the UTF-8 codes, sequencing according to the receiving sequence of the test data stream, and storing the sequenced data stream to a database.
And calling the test file information of the storage identifier in the database according to a preset condition, backing up the called test file information, and storing the backed-up test file information to a backup memory.
In some embodiments, computer-readable storage media may include non-volatile media. The term "non-transitory" as used herein may indicate that the storage medium does not contain a carrier wave or a propagated signal. In some embodiments, a non-transitory storage medium may store data, which may change over time (e.g., in RAM or cache).
In an embodiment of the present invention, as shown in figure 3,
s21, setting backup time point and setting backup time period
S22, starting a server test program, continuously acquiring a test data stream, and traversing each test file information of the test data stream;
s23, identifying the file name of each test file information according to a preset rule, and storing the identified test file information into a database according to a preset storage mode;
and S24, when the system runs to the set backup time point, starting backup, creating database connection, generating a backup session link, calling the test file information stored in the database in the backup time period according to the set backup time period, backing up the test file information stored in the database in the backup time period, and storing the backup file in the backup database.
The data files are backed up based on the preset backup time point, the preset backup time point is important according to the test data files received in a certain time period, or the test data files received in a certain time period need to be used in the later period, so that the useful test data files are prevented from being lost, or the useful test data files are removed to influence the use when the data files are removed in the later period, and effective backup is carried out.
In the embodiment of the present invention, as shown in fig. 4,
s31, setting a backup time point, a backup time period and a test node;
s32, starting a server test program, continuously acquiring a test data stream, and traversing each test file information of the test data stream;
s33, identifying the file name of each test file information according to a preset rule, and storing the identified test file information into a database according to a preset storage mode;
and S34, when the system runs to the set backup time point, starting backup, creating database connection, generating a backup session link, calling the test file information stored in the database in the backup time period and sent by the test node according to the set backup time period and the test node, backing up the test file information, and storing the backup file in the backup database.
It can be understood that the system may receive data files transmitted by a plurality of temperature test nodes, network port communication rate test nodes, processor data processing amount test nodes, hard disk read data test nodes, hard disk storage data test nodes, memory tests, and the like at the same time or at different times, and data files transmitted by some test nodes are important data files received in some time periods, or data files received in some time periods need to be used at a later stage, so as to prevent loss, or useful data files are cleared to influence use when data files are cleared at the later stage, and effective backup is performed.
In the embodiment of the present invention, as shown in fig. 5,
s41, setting a backup time point, a backup time period and a backup test file type;
s42, starting a server test program, continuously acquiring a test data stream, and traversing each test file information of the test data stream;
s43, identifying the file name of each test file information according to a preset rule, and storing the identified test file information into a database according to a preset storage mode;
and S44, when the system runs to the set backup time point, starting backup, creating database connection, generating a backup session link, calling test file information with the backup test file type stored in the database in the backup time period according to the set backup time period and the backup test file type, backing up the test file information, and storing the backup file in the backup database.
It can be understood that the system can use various types of test file information, some types of test file information are important for data files received in certain time periods, or data files received in certain time periods need to be used later, so that effective backup is performed in order to prevent loss or influence on use caused by removal of useful data files when data files are removed later.
In the embodiment of the invention, a backup time point and a backup time period are set; starting a server test program, continuously acquiring a test data stream, and traversing each test file information of the test data stream; of course, the test data stream may be obtained from the http request, and the while loop is used to traverse each test file information of the whole test data stream.
And according to the UTF-8 code, the header of the file name of each piece of test file information is used as an identifier, a timestamp for acquiring the test file information is added to each piece of test file information, the test file information is arranged into a csv data format, and the test file information is sorted according to the receiving sequence of the test data stream and stored in a database after being sorted.
Of course, the method may also be adopted in a database, where a corresponding node storage folder is set according to a preset test node, and the test data stream sent by the test node is stored in the node storage folder.
Of course, the method can also be adopted in a database, the type folder is configured according to the type of each file in the test data stream, and the type folder is stored into the corresponding type folder according to the type of the received file.
When the system runs to the set backup time point, starting backup, creating database connection, generating a backup session link, calling test file information stored in the database in the backup time period according to the set backup time period, backing up the test file information stored in the database in the backup time period, and storing the backup file in the backup database.
In the embodiment of the invention, a backup time point, a backup time period and a test node are set; and starting a server test program, continuously acquiring the test data stream, and traversing each test file information of the test data stream.
And according to the UTF-8 code, the header of the file name of each piece of test file information is used as an identifier, a timestamp for acquiring the test file information is added to each piece of test file information, the test file information is arranged into a csv data format, and the test file information is sorted according to the receiving sequence of the test data stream and stored in a database after being sorted.
Certainly, a time period storage folder can be set according to a preset time period, and the test data stream acquired in the preset time period is stored in the time period storage folder; and when the ending time point of the preset time period is reached, storing the time period storage folder into a database.
Or, in the database, configuring a type folder according to the type of each file in the test data stream, and storing the type folder into a corresponding type folder according to the type of the received file.
Or, in a database, setting a corresponding node storage folder according to a preset test node, and storing a test data stream sent by the test node to the node storage folder.
When the system runs to the set backup time point, starting backup, creating database connection, generating a backup session link, calling test file information stored in the database in the backup time period and sent by the test node according to the set backup time period and the test node, backing up the test file information, and storing the backup file in the backup database.
In the embodiment of the invention, a backup time point, a backup time period and a backup test file type are set; starting a server test program, continuously acquiring a test data stream, and traversing each test file information of the test data stream; and according to the UTF-8 code, the header of the file name of each piece of test file information is used as an identifier, a timestamp for acquiring the test file information is added to each piece of test file information, the test file information is arranged into a csv data format, and the test file information is sorted according to the receiving sequence of the test data stream and stored in a database after being sorted.
Certainly, a time period storage folder can be set according to a preset time period, and the test data stream acquired in the preset time period is stored in the time period storage folder; and when the ending time point of the preset time period is reached, storing the time period storage folder into a database.
Or, in the database, configuring a type folder according to the type of each file in the test data stream, and storing the type folder into a corresponding type folder according to the type of the received file.
Or, in a database, setting a corresponding node storage folder according to a preset test node, and storing a test data stream sent by the test node to the node storage folder.
When the system runs to the set backup time point, starting backup, creating database connection, generating a backup session link, calling test file information with the backup test file type stored in the database in the backup time period according to the set backup time period and the backup test file type, backing up the test file information, and storing the backup file in the backup database.
The method and apparatus of the present invention may be implemented in a number of ways. For example, the methods and apparatus of the present invention may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order for the steps of the method is for illustrative purposes only, and the steps of the method of the present invention are not limited to the order specifically described above unless specifically indicated otherwise. Furthermore, in some embodiments, the present invention may also be embodied as a program recorded in a recording medium, the program including machine-readable instructions for implementing a method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.
The processing of data files in the present invention is not limited to backup but may also include deletion, modification, replacement, and the like.
The invention utilizes the storage space of the server more reasonably and efficiently, avoids the waste of resources, can prevent the loss of data by timely and reasonably backing up the files, has high practicability, can be directly embedded into linux, and improves the development efficiency.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. 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 invention. Thus, the present invention 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.