File consistency detection method and system, storage medium, program product and computer equipment
By synchronously collecting task data and detecting file consistency, the problem of low file consistency detection efficiency in the existing technology is solved, and the effect of efficient detection and timely reminder is achieved.
Patent Information
- Application Number
- CN202510029682.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-08
- Publication Date
- 2025-05-13
AI Technical Summary
In the prior art, file consistency detection efficiency is low, and it is difficult to timely discover and process key files that have been modified, damaged, and replaced.
By obtaining the acquisition task data entered by the user, synchronizing it to the preset acquisition task table, new acquisition task data is detected, corresponding acquisition task is started, target identification information list and first target identification value are obtained, and file consistency detection is performed based on these information.
It improves the efficiency of file consistency detection, can efficiently detect key files that have been modified, damaged, and replaced, and promptly remind maintenance personnel.
Smart Images

Figure CN119988392A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a file consistency detection method, system, storage medium, program product and computer device. Background Art
[0002] In the current environment, there are more and more cases of damage and loss of key data such as system files and application files due to abnormal situations such as power outages, erroneous operations, and even network attacks. In the development and testing environment, there are even more test failures caused by developers' manual modifications during debugging and forgetting to roll back during environment recovery (the test is not the expected version). Therefore, how to find these key files that have been modified, damaged, or replaced in real time or regularly, and to remind maintenance personnel in time has become an urgent need.
[0003] In the related art, it is usually achieved through manual detection, for example, manually checking each file after a problem occurs, which leads to low efficiency. In particular, when there are many files and the device types are inconsistent, the related problems are more prominent. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present application propose a file consistency detection method, system, storage medium, program product and computer device, which can improve the efficiency of file consistency detection, thereby efficiently detecting key files that have been modified, damaged or replaced.
[0005] In a first aspect, an embodiment of the present application provides a file consistency detection method, comprising:
[0006] Acquire the collection task data input by the user, and synchronize the collection task data to the preset collection task table;
[0007] Detecting that the acquisition task data is newly added in the acquisition task table, starting an acquisition task matching the acquisition task data, wherein the acquisition task is designed to acquire file data of the device to be detected;
[0008] Acquire a target identification information list and a first target identification value, wherein the target identification information list matches the collected file data, and the first target identification value is determined according to the target identification information list;
[0009] A file consistency check is performed based on the first target identification value, and if the first target identification value fails the check, a file consistency check is performed based on the target identification information list.
[0010] Optionally, the collection task table is stored in a preset database, and the preset database also stores a collection result table and a collection result raw data table. The file consistency detection based on the first target identification value includes:
[0011] Adding time information to the first target identification value to form a second target identification value;
[0012] Entering the second target identification value into the collection result table of the preset database, so that the preset database queries whether there is information matching the second target identification value in the collection result table, and if not, determining that the first target identification value has failed the test;
[0013] Wherein, the method further comprises:
[0014] In the case that there is no information matching the second target identification value, the target identification information list is stored in the acquisition result raw data table.
[0015] Optionally, the collected task data is suitable for characterizing a current task, the second target identification value is a collection result of the current task, and the method further includes:
[0016] Detecting that the second target identification value is entered into the collection result table, determining whether the second target identification value is the first collection result of the current task;
[0017] If so, taking the second target identification value as a reference value corresponding to the current task, and storing the reference value in the collection result table;
[0018] If not, obtain the reference value corresponding to the current task from the collection result table, and compare the difference between the second target identification value and the obtained reference value to obtain a comparison result, so as to update the collection result table according to the comparison result.
[0019] Optionally, the reference identification information list corresponding to the obtained reference value is stored in the acquisition result raw data table, and the file consistency detection based on the target identification information list includes:
[0020] In the case where there is a difference between the second target identification value and the obtained reference value, obtaining the reference identification information list from the acquisition result raw data table, and comparing the target identification information list with the reference identification information list to obtain list difference information as a file consistency detection result corresponding to the target identification information list;
[0021] Wherein, the method further comprises:
[0022] The list difference information is stored in the collection result table.
[0023] Optionally, the method further comprises:
[0024] After obtaining the list difference information, a notification message carrying the list difference information is sent to the user, so that the user can perform analysis according to the list difference information.
[0025] Optionally, the identification types corresponding to the target identification information list and the first target identification value are both md5.
[0026] In a second aspect, an embodiment of the present application provides a file consistency detection system, including:
[0027] A configuration tool, configured to obtain the collection task data input by the user, and synchronize the collection task data into a preset collection task table;
[0028] A collection module is configured to detect that the collection task data is newly added in the collection task table, and start a collection task matching the collection task data, wherein the collection task is designed to collect file data of the device to be detected;
[0029] The acquisition module is further configured to acquire a target identification information list and a first target identification value, wherein the target identification information list matches the acquired file data, and the first target identification value is determined according to the target identification information list;
[0030] The analysis module is configured to perform a file consistency check based on the first target identification value, and if the first target identification value fails the check, perform a file consistency check based on the target identification information list.
[0031] In a third aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any of the methods described above are implemented.
[0032] In a fourth aspect, an embodiment of the present application provides a computer program product, including computer instructions, which, when executed by a processor, implement the steps of any of the methods described above.
[0033] In a fifth aspect, an embodiment of the present application provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the steps of any of the methods described above when executing the computer program.
[0034] In summary, the embodiments of the present application have at least the following beneficial effects:
[0035] According to an embodiment of the present application, acquisition task data input by a user is obtained, and the acquisition task data is synchronized to a preset acquisition task table; when the acquisition task data is newly added to the acquisition task table, an acquisition task matching the acquisition task data is started, wherein the acquisition task is designed to collect file data of a device to be detected; a target identification information list and a first target identification value are obtained, wherein the target identification information list matches the collected file data, and the first target identification value is determined based on the target identification information list; a file consistency check is performed based on the first target identification value, and when the first target identification value fails the check, a file consistency check is performed based on the target identification information list, thereby improving the efficiency of the file consistency check and efficiently detecting key files that have been modified, damaged, or replaced. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a flowchart of a file consistency detection method provided in an embodiment of the present application;
[0037] Figure 2 is a schematic diagram of file consistency detection provided by an embodiment of the present application;
[0038] Figure 3 is a schematic diagram of the index relationship between the tables provided in the embodiment of the present application;
[0039] Figure 4 is a schematic diagram of file consistency detection provided by an embodiment of the present application;
[0040] Figure 5 is a schematic diagram of file consistency detection provided by an embodiment of the present application;
[0041] Figure 6 It is a structural diagram of a file consistency detection system provided in an embodiment of the present application;
[0042] Figure 7 It is a schematic diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0044] In the description of the present application, the terms "first", "second", "third", etc. are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, features defined as "first", "second", "third", etc. may explicitly or implicitly include one or more of the features. In the description of the present application, unless otherwise specified, the meaning of "multiple" is two or more. In the description of the present application, the term "including" and its variations are open inclusions, i.e., "including but not limited to". The term "based on" means "at least partially based on". The term "according to" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments".
[0045] In the description of this application, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0046] In the description of this application, it should be noted that, unless otherwise defined, all technical and scientific terms used in this application have the same meaning as those commonly understood by those skilled in the art. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood by specific circumstances.
[0047] The following is an explanation of some terminology concepts involved in the embodiments of the present application:
[0048] The MD5 (Message-Digest Algorithm 5) identifier usually refers to a 128-bit (16-byte) hash value generated by the MD5 algorithm, which is used as a digital fingerprint of data or files.
[0049] SSH (Secure Shell) interface is a network protocol designed to provide a secure encrypted channel for communication between computers. It is mainly used for remote login, command execution and file transfer, and is widely used in system management, server maintenance and other fields. The SSH protocol not only provides data encryption function, but also ensures the security and integrity check of identity authentication.
[0050] First, see Figure 1, shows a schematic flow chart of a file consistency detection method provided in an embodiment of the present application, the method includes steps S101-S104, which are as follows:
[0051] S101, obtaining collection task data input by a user, and synchronizing the collection task data into a preset collection task table;
[0052] In one example, a user may input collection task data for configuring a collection task through a configuration tool.
[0053] S102, detecting that the acquisition task data is newly added in the acquisition task table, and starting an acquisition task matching the acquisition task data, wherein the acquisition task is designed to acquire file data of the device to be detected;
[0054] In one example, see Figure 2 The number of the devices to be detected can be multiple, namely, device 1 to be detected, device 2 to be detected, ..., device n to be detected.
[0055] In one example, the collection task data is suitable for indicating the start time of the collection task, for example, starting the collection task regularly or at a specific interval, so that further, after detecting that the collection task data is newly added to the collection task table, the collection task is started when the start time indicated by the newly added collection task data is reached. In this way, in this embodiment, the automatic detection process can be improved, and unified data maintenance and management are facilitated, maintenance and analysis are convenient, and efficiency is improved.
[0056] In one example, the collection tasks matched by different collection task data may be the same or different. If the user inputs collection task data for the same collection task multiple times, the different collection task data are suitable for indicating different start orders (or times) of the collection task.
[0057] In one example, you can log in to the device to be detected through the ssh interface, execute find with parameters to generate a file list, and then use cat combined with the sort command to sort the file list into an ordered file list as the collected file data. In this embodiment, the file list is dynamically identified and generated using the detection rules of find, which reduces the configuration complexity and improves the design flexibility; in addition to predicting the detection of files, it can also perceive newly added files and issue an alarm for such changes, thereby improving the detection value.
[0058] S103, obtaining a target identification information list and a first target identification value, wherein the target identification information list matches the collected file data, and the first target identification value is determined according to the target identification information list;
[0059] In one example, the same identification generation algorithm can be used to respectively calculate the target identification information list and the first target identification value. Preferably, the identification generation algorithm can be used to calculate the collected file data to obtain the target identification information list, and the identification generation algorithm can be used to calculate the target identification information list to obtain the first target identification value. In this way, the first target identification value and the target identification information list each have the same corresponding identification type.
[0060] In one example, the collected file data may be first saved as a file, and then the target identification information list may be calculated from the file.
[0061] In this embodiment, the ssh interface can be used to remotely log in to the device, and the MD5 (i.e., the first target identification value and the target identification information list) can be calculated on the device side using tools such as find and md5sum that come with Linux. The collection tool does not need to be designed, which reduces the design cost; and the server side only collects and summarizes the results, analyzes and counts, which reduces the network transmission pressure and the server calculation pressure. It should be understood that the method described in this embodiment is executed by the server at this time.
[0062] S104: Perform a file consistency check based on the first target identification value, and if the first target identification value fails the check, perform a file consistency check based on the target identification information list.
[0063] In this embodiment, it is obvious that the data volume of the first target identification value will be smaller than the target identification information list. Therefore, the file consistency check is first performed using the first target identification value, and then the file consistency check is performed using the target identification information list when the check fails. This can greatly improve the detection efficiency while retaining the original detection recognition and accuracy capabilities.
[0064] In an optional implementation, the collection task table is stored in a preset database, and the preset database also stores a collection result table and a collection result raw data table, and the file consistency detection based on the first target identification value includes:
[0065] Adding time information to the first target identification value to form a second target identification value;
[0066] Entering the second target identification value into the collection result table of the preset database, so that the preset database queries whether there is information matching the second target identification value in the collection result table, and if not, determining that the first target identification value has failed the test;
[0067] Wherein, the method further comprises:
[0068] In the case that there is no information matching the second target identification value, the target identification information list is stored in the acquisition result raw data table.
[0069] In one example, time information is added to the first target identification value, and then the formed second target identification value is structured and stored in a data table, which can facilitate unified maintenance and storage, facilitate data processing and analysis, and also reduce the difficulty of data statistical analysis design.
[0070] In an example, the collection task table can be constructed into a corresponding data table structure in the following manner:
[0071] CREATE TABLE `checktask`(
[0072] --Device login account and password
[0073] `username`varchar(20)DEFAULT NULL,
[0074] `password`varchar(20)DEFAULT NULL,
[0075] --The port for ssh login. Some devices may set it to other values.
[0076] `targetport`int NOT NULL DEFAULT'22',
[0077] --Device IP address
[0078] `targetip`varchar(50)DEFAULT NULL,
[0079] --Detection mode (regular or time interval, default is one-day detection)
[0080] `checkmode`varchar(255)DEFAULT NULL,
[0081] --The time of next test
[0082] `checknext`varchar(50)DEFAULT NULL,
[0083] --The data id of the task
[0084] `id`int NOT NULL AUTO_INCREMENT,
[0085] --Whether the current task is enabled, 1 to enable, 0 to disable
[0086] `taskenable`int NOT NULL DEFAULT'1',
[0087] --Description of the task, for easy operation and email notification
[0088] `taskdesc`text,
[0089] --The total number of times detected
[0090] `totalcnt`int NOT NULL DEFAULT'0',
[0091] --The number of successful detections
[0092] `successcnt`int NOT NULL DEFAULT'0',
[0093] --Corresponding test mode (specific parameters of the corresponding test mode)
[0094] `modeinfo`varchar(255)DEFAULT NULL,
[0095] --Trigger email method (send periodically or send when an exception occurs)
[0096] `trigeremailmode`text,
[0097] --Filter rules for excluded files found during scanning
[0098] `exclude` text,
[0099] --Device uid, to avoid unexpected detection due to the same IP
[0100] `targetuid`text,
[0101] --Scan file rules
[0102] `include` text,
[0103] --Email address to receive email notifications
[0104] `email` text,
[0105] --Used to specify the path for the device to store detection file information and md5 information
[0106] `tmpdir`varchar(300)DEFAULT NULL,
[0107] --Task detection status: new task, executing, completed, waiting for next time
[0108] `checkstatus`varchar(255)DEFAULT NULL,
[0109] PRIMARY KEY (`id`) )
[0111] In this way, checktask can represent the collection task table.
[0112] In an example, the collection result table can be constructed into a corresponding data table structure in the following manner:
[0113] CREATE TABLE `checkresult`(
[0114] --Collection timestamp
[0115] `checktime`varchar(30)DEFAULT NULL,
[0116] --Collection result corresponding point collection task id
[0117] `checktaskid`int DEFAULT NULL,
[0118] --The md5 value of the file in the md5 list information of the collected file
[0119] `checkmd5`varchar(100)DEFAULT NULL,
[0120] --Compare the results, you can use the tool to set (mark) a certain time as a new reference point
[0121] `checkresult`varchar(30)DEFAULT NULL,
[0122] --Save the difference information when there is a difference with the mark record
[0123] `resultinfo`text,
[0124] --The corresponding device IP (to prevent the collection task from being cleared and unable to be backtracked)
[0125] `targetip`varchar(50)DEFAULT NULL,
[0126] --The corresponding device uid
[0127] `targetuid`text,
[0128] --Collection result original data corresponding to data id (guide to the actual file md5 information list)
[0129] `resultid` int DEFAULT NULL,
[0130] --Collection result data id uniquely identifies the data
[0131] `id`int NOT NULL AUTO_INCREMENT,
[0132] PRIMARY KEY (`id`) )
[0134] In this way, checkresult can represent the collection result table.
[0135] In one example, the original data table of the acquisition result can be constructed into a corresponding data table structure in the following manner:
[0136] CREATE TABLE`checkresultfile`(
[0137] --device-ip
[0138] `targetip`varchar(50)DEFAULT NULL,
[0139] --Detect actual results (file md5 information list, file and md5 correspond one to one)
[0140] `checkresult` mediumtext,
[0141] --The md5 calculated based on the actual result information
[0142] `checkmd5`varchar(100)DEFAULT NULL,
[0143] --The ID of the original data of the collection result
[0144] `id`int NOT NULL AUTO_INCREMENT,
[0145] PRIMARY KEY (`id`) )
[0147] In this way, checkresultfile can represent the original data table of the collection results.
[0148] Further, see Figure 3 , which is the index relationship between the above parameters, and the dotted arrows are for reference to further ensure the validity of the data.
[0149] Combining the above embodiments and Figure 4 , the time information (such as a timestamp) can be added to the first target identification value using the database interface of the preset database, and the second target identification value can be entered into the collection result table of the preset database and the target identification information list can be stored in the collection result original data table.
[0150] In an optional implementation, the collected task data is suitable for characterizing the current task, the second target identification value is a collection result of the current task, and the method further includes:
[0151] Detecting that the second target identification value is entered into the collection result table, determining whether the second target identification value is the first collection result of the current task;
[0152] If so, taking the second target identification value as a reference value corresponding to the current task, and storing the reference value in the collection result table;
[0153] If not, obtain the reference value corresponding to the current task from the collection result table, and compare the difference between the second target identification value and the obtained reference value to obtain a comparison result, so as to update the collection result table according to the comparison result.
[0154] In one example, see Figure 5 When a new collection result is detected in the collection result table (i.e., the second target identification value is entered), the checkresult field is empty, and the analysis of the current collection result as shown in the figure begins, where "the first collection result of the current task" means "the first task of the task".
[0155] a) During analysis, if this is the first result of the task, set checkresult to mark to indicate that the current result is the reference value of the task (the reference value can also be specified using a database tool, so that after the device file is upgraded, the upgraded version can be used as a reference without restarting the task).
[0156] b) If it is not the first task, find the last result marked as mark in the collection result table and read its checkmd5.
[0157] c) Compare the reference checkmd5 (i.e. the reference value obtained) with the checkmd5 of the current result (i.e. the second target identification value). If there is no difference, modify the checkresult of the current result to success, otherwise set it to fail. At the same time, compare the difference of checkmd5 and save it in resultinfo to update the collection result table. Among them, the corresponding task number information of the "collection task table" can be updated.
[0158] In an optional implementation, the reference identification information list corresponding to the obtained reference value is stored in the acquisition result raw data table, and the file consistency detection based on the target identification information list includes:
[0159] In the case where there is a difference between the second target identification value and the obtained reference value, obtaining the reference identification information list from the acquisition result raw data table, and comparing the target identification information list with the reference identification information list to obtain list difference information as a file consistency detection result corresponding to the target identification information list;
[0160] Wherein, the method further comprises:
[0161] The list difference information is stored in the collection result table.
[0162] In this embodiment, the list difference information is stored in the collection result table, which can facilitate the user to directly view it next time.
[0163] In an optional embodiment, the method further includes:
[0164] After obtaining the list difference information, a notification message carrying the list difference information is sent to the user, so that the user can perform analysis according to the list difference information.
[0165] In one example, the notification message may be sent in the form of an email, and the notification message may also carry the exception information corresponding to the current task. Exemplarily, the email is triggered according to a pre-configured task email triggering rule.
[0166] In an optional implementation, the identification types corresponding to the target identification information list and the first target identification value are both md5.
[0167] In an example, the target identification information list and the first target identification value can both be calculated using a pre-configured md5sum tool.
[0168] In one example, the present application combines the management process with a database, and drives the collection task by configuring a "collection task table", so some common database operations can be used to realize the driven collection.
[0169] The following is a Python implementation example for reference (for adding collection tasks):
[0170] #Encapsulate the function of generating SQL insert statements using field key-value pairs for easy reuse def GenSqlStr(strTableName,strKeyvals):
[0171] # Assign initial values to local variables
[0172] strValues=None
[0173] strKeyInfos=""
[0174] strKeys=""
[0175] strvaluef=""
[0176] strValues = []
[0177] #Traverse the key-value pair dictionary and generate insert statements
[0178] for key,value in strKeyvals.items():
[0179] if value! =""and value! =None:
[0180] if strKeys=="":
[0181] strKeys=key
[0182] else:
[0183] strKeys=strKeys+","+key
[0184] if type(value)==str or type(value)==bytes or type(value)==unicode:valuef="%s"
[0185] elif type(value)==list:
[0186] value = ".join(value)
[0187] valuef = "%s"
[0188] elif type(value) == dict:
[0189] value = json.dumps(value)
[0190] valuef = "%s"
[0191] else:
[0192] value=str(value)
[0193] valuef = "%s"
[0194] strValues.append(value)
[0195] if strvaluef=="":
[0196] strvaluef=valuef
[0197] else:
[0198] strvaluef=strvaluef+","+valuef
[0199] strKeyInfos="("+strKeys+")values("+strvaluef+")"
[0200] sql="INSERT INTO"+strTableName+""+strKeyInfos
[0201] #Return the assembled SQL statement
[0202] return sql
[0203] #Encapsulated insert collection task table function
[0204] def InsertTask(strkeyvals):
[0205] #First use the pymysql library to establish a connection to the database (gstrIP, gstrUser, gstrPassword respectively correspond to the database server IP, account password; gstrDbName database name) dbconnection = pymysql.connect (
[0206] host=gstrIP,
[0207] user=gstrUser,
[0208] password=gstrPassword,
[0209] database = gstrDbName,
[0210] charset = 'utf8mb4')
[0211] bRet=False
[0212] #Set the SQL statement for the insert task to be executed
[0213] sql=GenSqlStr('checktask',strKeyvals)
[0214] #Call the interface to execute the SQL statement and add the task to the "Collection Task Table"
[0215] with dbconnection.cursor()as cursor:
[0216] try:
[0217] cursor.execute(sql,strValues)
[0218] self.m_connection.commit()
[0219] bRet=True
[0220] except pymysql.MySQLError as e:
[0221] ErrorLog("checktask:data insert failed:",e)
[0222] dbconnection.rollback()
[0223] #Reclaim mysql resources
[0224] dbconnection.close()
[0225] return bRet
[0226] #In actual use, you can directly call the InsertTask function, for example:
[0227] # Initialize a key-value pair table
[0228] newTaskObj = {}
[0229] #Remote ssh account password
[0230] newTaskObj['username']='root'
[0231] newTaskObj['password']='123456'
[0232] #The remote IP address, the SSH port defaults to 22 and can be left unconfigured
[0233] newTaskObj['targetip']='192.168.1.2'
[0234] #Set the enable flag to 1, indicating that the task is enabled
[0235] newTaskObj['taskenable'] = 1
[0236] #Give the collection task a name to facilitate subsequent classification and email viewing
[0237] newTaskObj['taskdesc'] = 'Test demo'
[0238] #The retrieved files are files in the / app / install directory (including subdirectories)
[0239] newTaskObj['include']=' / app / install'
[0240] #Filter files with suffixes such as ini and cfg, and also filter all files in directories such as cfg and log
[0241] #Conform to the matching parameter rules of the find function
[0242] newTaskObj['exclude']="-not-name'*.ini'-not-name'*.cfg'-not-path'* / cfg / *'-not-path'* / log / *'"
[0243] #Configure the email address for email notifications
[0244] newTaskObj['email']='admin@demo.cn'
[0245] #Then call the InsertTask function to add the task
[0246] InsertTask(newTaskObj)
[0247] In summary, it is possible to add collection tasks through Python.
[0248] In addition, combined Figure 2 , giving a specific example:
[0249] S1, the user configures the collection task through the tool operation; S2, the configuration tool synchronizes the data to the collection task table of the database; S3, the task collection module detects the database, finds the newly added collection task, and starts the collection task; S4, the collection module uses the configured information to collect file consistency information for the specified device under test; S5, the collection module adds a timestamp to the collected data (the md5 identifier of the md5 information list of the file list, and does not directly store the md5 information list) and enters it into the database; S6, the collection module queries the database and finds that the MD5 of the compressed information does not exist in the original data, then the md5 information list of this time is packaged and stored in the original data table; S7, the analysis module detects the collection results and compares the devices according to the settings MD5 information of the compressed information; S8, storing the comparison result in the collection result table (the first collection result is marked as mark as the basic reference point data by default, and the subsequent collection of the task is compared with this reference). When an abnormality is found (inconsistent with the marked mark), the original file MD5 information list data corresponding to the current time and mark will be read out from the collection history, and a one-to-one comparison will be performed. The difference information will be counted and the difference will be written back to the collection result table for record, which is convenient for direct viewing next time, and then the statistical information will be sent to the user by email according to the configuration; S9, the user receives the email; S10, reading the information in the database according to the received statistical information, and using the stored original data and test results to analyze the specific circumstances of the problem and inconsistency.
[0250] In combination with the above-mentioned related embodiments, the present application can also achieve the following technical effects:
[0251] 1. High versatility and low design cost: The technologies used in this application are all mature scripting technologies with simple logic: conventional ssh interfaces, terminal detection shell tools find, and md5sum are all commonly used Linux tools, which are simple and convenient to use; and there is no complex interactive design and tool development.
[0252] 2. High detection efficiency: This application compresses the data information by performing secondary calculation of md5 on the collected data. The verification first checks the consistency of the compressed data information, and then performs actual comparison after inconsistency is found, which greatly improves the detection efficiency and reduces the complexity.
[0253] 3. Timeliness: Flexible configuration of scheduled periodic detection, timely notification (email) when problems are found
[0254] 4. Structured data storage with attached time information, data with temporal and spatial characteristics, unified data storage and maintenance can provide more scenario designs and enhance the value of data collection.
[0255] On the second aspect, accordingly, the embodiments of the present application also provide a file consistency detection system, which can implement all the processes of the file consistency detection method provided in the above embodiments.
[0256] See also Figure 6 , shows a schematic diagram of the structure of a file consistency detection system provided in an embodiment of the present application, the system comprising:
[0257] Configuration tool 601, configured to obtain the collection task data input by the user, and synchronize the collection task data into a preset collection task table;
[0258] The collection module 602 is configured to detect that the collection task data is newly added in the collection task table, and start a collection task matching the collection task data, wherein the collection task is designed to collect file data of the device to be detected;
[0259] The acquisition module 602 is further configured to acquire a target identification information list and a first target identification value, wherein the target identification information list matches the acquired file data, and the first target identification value is determined according to the target identification information list;
[0260] The analysis module 603 is configured to perform a file consistency check based on the first target identification value, and if the first target identification value fails the check, perform a file consistency check based on the target identification information list.
[0261] In an optional implementation, the collection task table is stored in a preset database, and the preset database also stores a collection result table and a collection result raw data table, and the file consistency detection based on the first target identification value includes:
[0262] Adding time information to the first target identification value to form a second target identification value;
[0263] Entering the second target identification value into the collection result table of the preset database, so that the preset database queries whether there is information matching the second target identification value in the collection result table, and if not, determining that the first target identification value has failed the test;
[0264] Wherein, the system further comprises:
[0265] The first storage module is used to store the target identification information list in the acquisition result original data table when there is no information matching the second target identification value.
[0266] In an optional implementation, the collected task data is suitable for characterizing the current task, the second target identification value is a collection result of the current task, and the analysis module is further used to:
[0267] Detecting that the second target identification value is entered into the collection result table, determining whether the second target identification value is the first collection result of the current task;
[0268] If so, taking the second target identification value as a reference value corresponding to the current task, and storing the reference value in the collection result table;
[0269] If not, obtain the reference value corresponding to the current task from the collection result table, and compare the difference between the second target identification value and the obtained reference value to obtain a comparison result, so as to update the collection result table according to the comparison result.
[0270] In an optional implementation, the reference identification information list corresponding to the obtained reference value is stored in the acquisition result raw data table, and the file consistency detection based on the target identification information list includes:
[0271] In the case where there is a difference between the second target identification value and the obtained reference value, obtaining the reference identification information list from the acquisition result raw data table, and comparing the target identification information list with the reference identification information list to obtain list difference information as a file consistency detection result corresponding to the target identification information list;
[0272] Wherein, the system further comprises:
[0273] The second storage module is used to store the list difference information in the collection result table.
[0274] In an optional embodiment, the system further includes:
[0275] The notification module is used to send a notification message carrying the list difference information to the user after obtaining the list difference information, so that the user can perform analysis according to the list difference information.
[0276] In an optional implementation, the identification types corresponding to the target identification information list and the first target identification value are both md5.
[0277] In a third aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any of the methods described above are implemented.
[0278] In a fourth aspect, an embodiment of the present application provides a computer program product, including computer instructions, which, when executed by a processor, implement the steps of any of the methods described above.
[0279] In a fifth aspect, an embodiment of the present application provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the steps of any of the methods described above when executing the computer program.
[0280] See also Figure 7 The computer device of this embodiment includes: a processor 701, a memory 702, and a computer program stored in the memory 702 and executable on the processor 701, such as a file consistency detection program. When the processor 701 executes the computer program, the steps in the above-mentioned various file consistency detection method embodiments are implemented, such as Figure 1 Steps S101-S104 are shown.
[0281] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 702 and executed by the processor 701 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the computer device.
[0282] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may include, but is not limited to, a processor 701 and a memory 702. Those skilled in the art will appreciate that the schematic diagram is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than shown in the diagram, or may combine certain components, or different components. For example, the computer device may also include input and output devices, network access devices, buses, etc.
[0283] The processor 701 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor 701 may also be any conventional processor, etc. The processor 701 is the control center of the computer device, and uses various interfaces and lines to connect various parts of the entire computer device.
[0284] The memory 702 can be used to store the computer program and / or module, and the processor 701 realizes various functions of the computer device by running or executing the computer program and / or module stored in the memory 702, and calling the data stored in the memory 702. The memory 702 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 702 can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0285] Wherein, if the module / unit integrated in the computer device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor 701. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0286] In summary, the embodiments of the present application have at least the following beneficial effects:
[0287] According to an embodiment of the present application, acquisition task data input by a user is obtained, and the acquisition task data is synchronized to a preset acquisition task table; when the acquisition task data is newly added to the acquisition task table, an acquisition task matching the acquisition task data is started, wherein the acquisition task is designed to collect file data of a device to be detected; a target identification information list and a first target identification value are obtained, wherein the target identification information list matches the collected file data, and the first target identification value is determined based on the target identification information list; a file consistency check is performed based on the first target identification value, and when the first target identification value fails the check, a file consistency check is performed based on the target identification information list, thereby improving the efficiency of the file consistency check and efficiently detecting key files that have been modified, damaged, or replaced.
[0288] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus the necessary hardware platform, and of course it can also be implemented entirely by hardware. Based on such an understanding, all or part of the contribution of the technical solution of the present application to the background technology can be embodied in the form of a software product, and the computer software product can be stored in a storage medium, such as ROM (Read-Only Memory) / RAM (Random Access Memory), a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application or some parts of the embodiments.
[0289] The above is a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications are also considered to be within the scope of protection of the present application.
Claims
1. A file consistency detection method, characterized in that: include: Acquire the collection task data input by the user, and synchronize the collection task data to the preset collection task table; Detecting that the acquisition task data is newly added in the acquisition task table, starting an acquisition task matching the acquisition task data, wherein the acquisition task is designed to acquire file data of the device to be detected; Acquire a target identification information list and a first target identification value, wherein the target identification information list matches the collected file data, and the first target identification value is determined according to the target identification information list; A file consistency check is performed based on the first target identification value, and if the first target identification value fails the check, a file consistency check is performed based on the target identification information list.
2. The method according to claim 1, characterized in that The collection task table is stored in a preset database, and the preset database also stores a collection result table and a collection result original data table. The file consistency detection based on the first target identification value includes: Adding time information to the first target identification value to form a second target identification value; Entering the second target identification value into the collection result table of the preset database, so that the preset database queries whether there is information matching the second target identification value in the collection result table, and if not, determining that the first target identification value has failed the test; Wherein, the method further comprises: In the case that there is no information matching the second target identification value, the target identification information list is stored in the acquisition result raw data table.
3. The method according to claim 2, characterized in that The collected task data is suitable for characterizing the current task, the second target identification value is a collection result of the current task, and the method further includes: Detecting that the second target identification value is entered into the collection result table, determining whether the second target identification value is the first collection result of the current task; If so, taking the second target identification value as a reference value corresponding to the current task, and storing the reference value in the collection result table; If not, obtain the reference value corresponding to the current task from the collection result table, and compare the difference between the second target identification value and the obtained reference value to obtain a comparison result, so as to update the collection result table according to the comparison result.
4. The method according to claim 3, characterized in that The reference identification information list corresponding to the obtained reference value is stored in the acquisition result raw data table, and the file consistency detection based on the target identification information list includes: In the case where there is a difference between the second target identification value and the obtained reference value, obtaining the reference identification information list from the acquisition result raw data table, and comparing the target identification information list with the reference identification information list to obtain list difference information as a file consistency detection result corresponding to the target identification information list; Wherein, the method further comprises: The list difference information is stored in the collection result table.
5. The method according to claim 4, characterized in that The method further comprises: After obtaining the list difference information, a notification message carrying the list difference information is sent to the user, so that the user can perform analysis according to the list difference information.
6. The method according to claim 1, characterized in that The identification types corresponding to the target identification information list and the first target identification value are both md5.
7. A file consistency detection system, characterized in that: include: A configuration tool, configured to obtain the collection task data input by the user, and synchronize the collection task data into a preset collection task table; A collection module is configured to detect that the collection task data is newly added in the collection task table, and start a collection task matching the collection task data, wherein the collection task is designed to collect file data of the device to be detected; The acquisition module is further configured to acquire a target identification information list and a first target identification value, wherein the target identification information list matches the acquired file data, and the first target identification value is determined according to the target identification information list; The analysis module is configured to perform a file consistency check based on the first target identification value, and if the first target identification value fails the check, perform a file consistency check based on the target identification information list.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the method according to any one of claims 1 to 6 is implemented.
10. A computer device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the computer program.