A server file monitoring method and device
By creating a property file to store key property information when the server is shut down, and comparing it when it is restarted, the problem of status file tampering is solved, ensuring that the correct state is loaded when the server starts, and enhancing security and consistency.
Patent Information
- Application Number
- CN201910933322.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-29
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2039-09-29
AI Technical Summary
In the existing technology, the status file when the server is shut down is easily tampered with by malware, causing the wrong status to be loaded when the server is started, causing security risks.
When the server is shut down, a property file is created to store the key property information of the status file, and compared when it is restarted. If it is inconsistent, it stops running to ensure information consistency and security.
By comparing the key information of the property file and the status file, malicious tampering is prevented and the correct service status is loaded when the server is started, which significantly enhances the security and information consistency of the server.
Smart Images

Figure CN112579385B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to a method and device for monitoring server files. Background Art
[0002] The client and server network structure commonly used in the prior art is the Client / Server structure (C / S structure). The server program is called Daemon, which is a server program that runs all the time, also known as a daemon process. The server program Daemon usually runs in the system background, has no control terminal, and does not interact with the foreground. The Daemon program is generally used as a system service. Daemon is a long-running process, which usually starts running after the system is started and ends when the system is shut down.
[0003] When the Daemon server program is shut down, it will record various service information of the current server in the service status file (StatusFile), which is referred to as the status file. When the server program is started next time, it will find the agreed status file, load the status file information, restore to the service status when the server was last shut down, and continue to provide services to users.
[0004] The security of the service status file is very important. Because it contains important service status information, the server program needs to ensure that the loaded information is consistent with the information recorded at the last shutdown when it is started, to prevent malicious programs from tampering with the status file or replacing expired service status information. If the wrong information is loaded when the service program is started, it will provide wrong and invalid services, causing great risks. Summary of the invention
[0005] The present application provides a method and device for monitoring server files, so as to at least solve the problem in the prior art that the server status files recorded when the server is shut down cannot be detected after being maliciously tampered with.
[0006] According to one aspect of the present application, a method for monitoring a server file is provided, comprising: when a resident program of a server stops running, storing service information of the server into a service status file and creating a property file, wherein the property file stores key properties of the property file and key properties of the service status file;
[0007] When the resident program is restarted, the current attribute information in the attribute file and the current attribute information in the service status file are obtained, and compared with the key attributes of the corresponding attribute file and the key attributes of the service status file respectively;
[0008] If the comparison result is consistent, the stored service information is read from the service status file to restore the service status when the resident program stops running.
[0009] In one embodiment, the service information of the server is stored in a service status file and a property file is created, including:
[0010] Save the service information in binary form to the service status file in sequence;
[0011] Create a property file and save the key attributes of the service status file and the key attributes of the property file in advance into the property file respectively. The key attributes of the service status file include: the absolute path name of the status file, the modification time of the status file, the MD5 summary information of the status file and the file length of the status file. The key attributes of the property file include: the absolute path name of the property file, the modification time of the property file, the MD5 summary information of the property file and the file length of the property file.
[0012] In one embodiment, obtaining current attribute information in the attribute file and current attribute information in the service status file, and comparing them with the key attributes of the corresponding attribute file and the key attributes of the service status file respectively, includes:
[0013] Obtain the current attribute information of the attribute file and the key attributes of the attribute file and compare them;
[0014] If the comparison is consistent, the current attribute information of the service status file and the key attributes of the service status file are obtained and compared, and a comparison result is generated.
[0015] In one embodiment, obtaining current attribute information of the attribute file and key attributes of the attribute file and performing comparisons include:
[0016] Compare the absolute path name of the property file, the modification time of the property file, the MD5 summary information of the property file, and the file length of the property file with the information corresponding to the current property information of the property file to see if they are consistent.
[0017] In one embodiment, obtaining current attribute information of the service status file and key attributes of the service status file and performing comparisons include:
[0018] Compare the absolute path name of the service status file, the modification time of the status file, the MD5 summary information of the status file, and the file length of the status file with the information corresponding to the current attribute information of the service status file to see if they are consistent.
[0019] According to another aspect of the present application, a server file monitoring device is provided, comprising:
[0020] A storage unit, used for storing the service information of the server into a service status file and creating a property file when the resident program of the server stops running, wherein the property file stores key properties of the property file and key properties of the service status file;
[0021] A comparison unit, used for obtaining current attribute information in the attribute file and the current attribute information in the service status file when the resident program is restarted, and comparing them with the key attributes of the corresponding attribute file and the key attributes of the service status file respectively;
[0022] The state recovery unit is used to read the stored service information from the service state file if the comparison result is consistent, and recover the service state when the resident program stops running.
[0023] In one embodiment, the storage unit includes:
[0024] A binary storage module is used to save the service information in binary form into the service status file in sequence;
[0025] The attribute file creation module is used to create an attribute file and save the key attributes of the service status file and the key attributes of the attribute file in advance into the attribute file respectively. The key attributes of the service status file include: the absolute path name of the status file, the modification time of the status file, the MD5 summary information of the status file and the file length of the status file. The key attributes of the attribute file include: the absolute path name of the attribute file, the modification time of the attribute file, the MD5 summary information of the attribute file and the file length of the attribute file.
[0026] In one embodiment, the comparison unit includes:
[0027] The attribute file comparison module is used to obtain the current attribute information of the attribute file and the key attributes of the attribute file and compare them;
[0028] The service status file comparison module is used to obtain the current attribute information of the service status file and the key attributes of the service status file and compare them if the comparison is consistent, and generate a comparison result.
[0029] In one embodiment, the property file comparison module specifically includes:
[0030] The information comparison module is used to compare whether the absolute path name of the attribute file, the modification time of the attribute file, the MDS summary information of the attribute file and the file length of the attribute file are consistent with the information corresponding to the current attribute information of the attribute file.
[0031] In one embodiment, the service status file comparison module specifically includes:
[0032] The status attribute comparison module is used to compare the absolute path name of the service status file, the modification time of the status file, the MD5 summary information of the status file and the file length of the status file with the information corresponding to the current attribute information of the service status file.
[0033] The present application saves the status file when the server is shut down and the important attribute information of the attribute file itself into the attribute file by creating an attribute file. When the server runs again, the data pre-stored in the attribute file is compared with the data when the server runs again. If the data is inconsistent, the operation is stopped immediately, ensuring the consistency of the runtime information when the server stops and restarts, and preventing malicious programs from tampering with the status file information and causing the server to provide erroneous services. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0035] Figure 1 A flowchart of a server file protection method provided in this application.
[0036] Figure 2 This is a flow chart of the method for storing service information into a service status file and creating a property file in this application.
[0037] Figure 3 This is a flow chart of the method for information comparison and inspection in this application.
[0038] Figure 4 This is a structural block diagram of a server file protection device provided in this application.
[0039] Figure 5 This is a specific implementation of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] In the prior art, the server status file recorded when the server is shut down can be easily tampered with by malware or viruses, resulting in the tampered server status file being loaded when the server is started, causing great losses. Based on this, the present application provides a server file protection method to prevent the server status file recorded when the server is shut down from being tampered with, ensure that the correct server status file is loaded when the server is started, and significantly enhance the security of the server program. Figure 1 As shown, a server file protection method provided by the present application includes the following steps:
[0042] S101: When the resident program of the server stops running, the service information of the server is stored in the service status file and a property file is created, wherein the property file is a file for storing key properties of the service status file and is also used to store its own key properties.
[0043] In a specific embodiment, the server program (i.e., the resident program of the server) records / stores the service information of the server into a service status file (referred to as the status file) when it ends its operation, and at the same time, creates a property file, which records the key attributes of the service status file in a certain order, such as the absolute path name of the status file, modification time, MD5 summary information, file length, INODE, etc. At the same time, the property file also records the key attributes of the property file itself.
[0044] S102: When the resident program is restarted, current attribute information in the attribute file and current attribute information in the service status file are obtained, and compared with key attributes of the corresponding attribute file and key attributes of the service status file respectively.
[0045] In a specific embodiment, when the server program starts running, it can first find the current attribute information of the service status file stored when it stopped running last time and the attribute file created in step S101 and obtain the current attribute information of the attribute file, and then compare the current attribute information of the attribute file with the key attributes of the attribute file stored in the attribute file, and the current attribute information of the status file with the important attributes of the status file stored in the attribute file.
[0046] S103: If the comparison result is consistent, the stored service information is read from the service status file, and the service status when the resident program stops running is restored.
[0047] In a specific embodiment, if the comparison results in S102 are all consistent, the server program reads the service information when the operation was last terminated from the state file and loads the service information when the operation was last terminated into the program to continue to resume the operation of the program.
[0048] Figure 1The execution subject of the method shown can be a server, a PC, or a mobile terminal. The method creates a property description file of a server status file, referred to as a property file. When the server program stops running and records the status file, several key properties of the status file are obtained and saved in the property file, and several important properties of the property file itself are saved in the property file. When the server program starts running, it can first read the property file, and by checking and comparing the consistency of the property information of the current status file and the property file and the key properties of the status file and the property file recorded in the property file, it is confirmed whether the status file has been tampered with. This ensures that the correct service information is loaded when the server program starts, and also ensures the security and information consistency of the server.
[0049] In one embodiment, if Figure 2 As shown, store the server's service information in the service status file and create a property file, including:
[0050] S201: Save the service information in binary form in sequence into a service status file.
[0051] In a specific embodiment, when the server program stops running, various types of service information used in the server program can be saved in binary form in a preset order to a status file, so that the next time the server program is started, the service information saved in the status file can be loaded and the program can continue to run.
[0052] S202: Create a property file and save the key attributes of the service status file and the key attributes of the property file obtained in advance into the property file respectively. The key attributes of the service status file include: the absolute path name of the status file, the modification time of the status file, the MD5 summary information of the status file and the file length of the status file. The key attributes of the property file include: the absolute path name of the property file, the modification time of the property file, the MD5 summary information of the property file and the file length of the property file.
[0053] In a specific embodiment, the server program uses Linux operating system commands or corresponding POSIX interfaces to obtain attribute information of the status file, and these attribute information (see Table 1) include: absolute path name of the status file, modification time, MD5 summary information, INODE, and file length (number of bytes).
[0054] Table 1 Properties file content
[0055]
[0056] in:
[0057] 1. Absolute path name (ST_PATH): It is the path name agreed upon by the server. It is usually a fixed name.
[0058] 2. Modification time (ST_MTIME): The last modification time of the status file, which can be obtained using the stat command or interface. See the stat command example: Modify:2017-09-20 11:37:03.823669038+0800
[0059] Stat command examples:
[0060] [cjh@bgp~]$stat 1
[0061] File:`1'
[0062] Size:217 Blocks:8 IO Block:4096regular file
[0063] Device:fd00h / 64768d Inode:1204114 Links:1
[0064] Access:(0777 / -rwxrwxrwx)Uid:(502 / cjh)Gid:(502 / cjh)
[0065] Access:2018-12-28 10:09:41.739390129+0800
[0066] Modify:2017-09-20 11:37:03.823669038+0800
[0067] Change:2017-09-20 11:37:03.823669038+0800
[0068] 3. MD5 summary information (ST_MD5): The method for obtaining this summary information is: use the MD5 summary algorithm in OPENSSL to calculate the content of the status file and encode it in hexadecimal, ST_MD5 = HEX (MD5 (StatusFile)), and its format is a 32-byte hexadecimal number. For example: 8b58265aa564fb54147d7267051b0232
[0069] 4. INODE (ST_INODE): INODE is the I node of the file, and its physical meaning is the location where the file is stored on the disk. (See stat command example) Inode: 1204114
[0070] 5. File length (ST_SIZE): This information is the file length, in bytes. You can use the stat command or interface to obtain it.
[0071] In one embodiment, if Figure 3 As shown, the current attribute information in the attribute file and the current attribute information in the service status file are obtained, and compared with the key attributes of the corresponding attribute file and the key attributes of the service status file respectively, including:
[0072] S301: Obtain current attribute information of an attribute file and key attributes of the attribute file and compare them.
[0073] In a specific embodiment, when the server program starts running, it can first find the service status file and attribute file stored when the last run ended, and then use the operating system command or POSIX interface to obtain the current attribute information of the attribute file, and then read the key attributes of the attribute file recorded in the attribute file, and compare the current attribute information with the key attributes. If the information is inconsistent, it means that the attribute file has been damaged or tampered with, and the server program stops the service.
[0074] S302: If the comparison is consistent, obtain the current attribute information of the service status file and the key attributes of the service status file, perform comparison, and generate a comparison result.
[0075] In one embodiment, obtaining current attribute information of the attribute file and key attributes of the attribute file and performing comparisons include:
[0076] Compare the absolute path name of the property file, the modification time of the property file, the MDS summary information of the property file, and the file length of the property file with the information corresponding to the current property information of the property file to see if they are consistent. The specific steps are as follows:
[0077] 3.1: First, use the system command to get the attribute information of the attribute file:
[0078] CAT_PATH, CAT_MTIME, CAT_INODE
[0079] 3.2: Read and parse the property file to get the property values recorded in the status file and property file when the server was stopped last time:
[0080] 3.2.1: Read the properties of the status file:
[0081] ST_PATH,ST_MTIME,ST_MD5,ST_INODE,ST_SIZE;
[0082] 3.2.2: Read: AT_PATH
[0083] Compare whether it is the agreed path, otherwise exit with error.
[0084] 3.2.3: Read: AT_INODE
[0085] Compare the result with CAT_INODE to see if they are consistent. Otherwise, the program will exit with an error. This means that the location of the file on disk has been changed or replaced by another file.
[0086] 3.2.4: Read: AT_STRSIZE, read the random string AT_TRS according to the length.
[0087] 3.2.4: Read: 32 bytes of AT_MD5 information
[0088] Calculate the MD5 information of the actual attribute file:
[0089] CAT_MD5=HEX(MD5(ST_PATH+ST_MTIME+ST_MD5+ST_INODE+ST_SIZE+AT_PATH+AT_INODE+AT_STRSIZE+ST_STR))
[0090] Compare AT_MD5 to see if it is consistent with CAT_MD5, otherwise exit with error, indicating that the content of the attribute file has been tampered with.
[0091] 3.2.5: Get the current file location information: CAT_SIZE
[0092] Read: AT_SIZE
[0093] Compare AT_SIZE and CAT_SIZE to see if they are consistent, otherwise exit with error. This means the length of the attribute file is incorrect.
[0094] 3.2.6: Read: AT_TIME
[0095] Compare AT_TIME and CAT_TIME to see if they are consistent, otherwise exit with an error, indicating that the attribute file has been modified.
[0096] In one embodiment, obtaining current attribute information of the service status file and key attributes of the service status file and performing comparisons include:
[0097] Compare the absolute path name of the service status file, the modification time of the status file, the MDS summary information of the status file, and the file length of the status file with the information corresponding to the current attribute information of the service status file to see if they are consistent.
[0098] In a specific embodiment, comparing the current attribute information of the service status file and the key attributes of the service status file specifically includes the following steps:
[0099] First, use the operating system command or POSIX interface to obtain the attribute information of the status file, and read the attribute information of the status file recorded in the attribute file, and then compare the two, as follows:
[0100] 4.1: First use the system command to get the properties of the status file:
[0101] CST_PATH, CST_MTIME, CST_MD5, CST_INODE, CST_SIZE
[0102] 4.2: Compare the properties of the state file read from the properties file
[0103] ST_PATH,ST_MTIME,ST_MD5,ST_INODE,ST_SIZE;
[0104] If CST_PATH == ST_PATH,
[0105] CST_MTIME==ST_MTIME,
[0106] CST_MD5==ST_MD5,
[0107] CST_INODE == ST_INODE,
[0108] CST_SIZE==ST_SIZE
[0109] If the comparison information is inconsistent, the server program reports an error, indicating that the status file is inconsistent with the information recorded when the server was stopped, and the server stops service.
[0110] If the compared information is consistent, the stored service information is read from the service status file to restore the service status when the resident program stops running.
[0111] Based on the same inventive concept, the embodiments of the present application also provide a server file monitoring device, which can be used to implement the method described in the above embodiments, as described in the following embodiments. Since the principle of solving the problem by the server file monitoring device is similar to that of the server file monitoring method, the implementation of the server file monitoring device can refer to the implementation of the server file monitoring method, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the system described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0112] like Figure 4 As shown, a server file monitoring device includes:
[0113] The storage unit 401 is used to store the service information of the server into the service status file and create a property file when the resident program of the server stops running, wherein the property file stores the key attributes of the property file and the key attributes of the service status file;
[0114] The comparison unit 402 is used to obtain the current attribute information in the attribute file and the current attribute information in the service status file when the resident program is restarted, and compare them with the key attributes of the corresponding attribute file and the key attributes of the service status file respectively;
[0115] The state recovery unit 403 is used to read the stored service information from the service state file if the comparison result is consistent, and recover the service state when the resident program stops running.
[0116] In one embodiment, the storage unit 401 includes:
[0117] The binary storage module 4011 is used to sequentially save the service information in binary form into the service status file;
[0118] The attribute file creation module 4012 is used to create an attribute file and save the key attributes of the service status file and the key attributes of the attribute file in advance into the attribute file respectively. The key attributes of the service status file include: the absolute path name of the status file, the modification time of the status file, the MDS summary information of the status file and the file length of the status file. The key attributes of the attribute file include: the absolute path name of the attribute file, the modification time of the attribute file, the MDS summary information of the attribute file and the file length of the attribute file.
[0119] In one embodiment, the comparison unit 402 includes:
[0120] The attribute file comparison module 4021 is used to obtain the current attribute information of the attribute file and the key attributes of the attribute file and compare them;
[0121] The service status file comparison module 4022 is used to obtain the current attribute information of the service status file and the key attributes of the service status file and compare them if the comparison is consistent, and generate a comparison result.
[0122] In one embodiment, the attribute file comparison module 4021 specifically includes:
[0123] The information comparison module is used to compare whether the absolute path name of the attribute file, the modification time of the attribute file, the MDS summary information of the attribute file and the file length of the attribute file are consistent with the information corresponding to the current attribute information of the attribute file.
[0124] In one embodiment, the service status file comparison module 4022 specifically includes:
[0125] The status attribute comparison module is used to compare whether the absolute path name of the service status file, the modification time of the status file, the MDS summary information of the status file and the file length of the status file are consistent with the information corresponding to the current attribute information of the service status file.
[0126] The server file monitoring device ensures the consistency of service information when the server program stops running and restarts running, and prevents malicious programs from tampering with status file information and replacing expired status files to cause the service program to provide erroneous services, thereby ensuring the security of the server program.
[0127] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0128] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0129] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0130] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0131] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
[0132] The embodiments of the present application also provide a specific implementation of an electronic device that can implement all the steps in the method in the above embodiments, see Figure 5 , the electronic device specifically includes the following contents:
[0133] Processor 501, memory 502, communication interface 503, bus 504 and non-volatile memory 505;
[0134] The processor 501, memory 502, and communication interface 503 communicate with each other via the bus 504;
[0135] The processor 501 is used to call the computer program in the memory 502 and the non-volatile memory 505. When the processor executes the computer program, all the steps in the method in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0136] S101: When the resident program of the server stops running, the service information of the server is stored in a service status file and a property file is created, wherein the property file stores key properties of the property file and key properties of the service status file.
[0137] S102: When the resident program is restarted, current attribute information in the attribute file and current attribute information in the service status file are obtained, and compared with key attributes of the corresponding attribute file and key attributes of the service status file respectively.
[0138] S103: If the comparison result is consistent, the stored service information is read from the service status file, and the service status when the resident program stops running is restored.
[0139] The embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps of the method in the above embodiments. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all the steps of the method in the above embodiments are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0140] S101: When the resident program of the server stops running, the service information of the server is stored in a service status file and a property file is created, wherein the property file stores key properties of the property file and key properties of the service status file.
[0141] S102: When the resident program is restarted, current attribute information in the attribute file and current attribute information in the service status file are obtained, and compared with key attributes of the corresponding attribute file and key attributes of the service status file respectively.
[0142] S103: If the comparison result is consistent, the stored service information is read from the service status file, and the service status when the resident program stops running is restored.
[0143] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the hardware + program embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. Although the embodiment of this specification provides the method operation steps described in the embodiment or flow chart, more or less operation steps can be included based on conventional or non-creative means. The order of steps listed in the embodiment is only one way of executing the order of many steps, and does not represent the only execution order. When the device or terminal product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiment or the accompanying drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment). The term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, product or device. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or device including the elements. For the convenience of description, the above device is described by dividing it into various modules according to its functions. Of course, when implementing the embodiments of this specification, the functions of each module can be implemented in the same one or more software and / or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The present invention is described with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiments of the present invention. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the process and / or box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0144] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, the embodiments of this specification may be in the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the embodiments of this specification may be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment. In the description of this specification, the description of the reference term "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of this specification.
[0145] In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradicting each other. The above is only an embodiment of the embodiment of this specification and is not intended to limit the embodiment of this specification. For those skilled in the art, the embodiment of this specification may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiment of this specification shall be included in the scope of the claims of the embodiment of this specification.
Claims
1. A server file monitoring method, characterized in that: include: When the resident program of the server stops running, the service information of the server is stored in the service status file and a property file is created. When the server program stops running and records the status file, several key properties of the status file are obtained and saved in the property file, wherein the property file stores the key properties of the property file and the key properties of the service status file; When the resident program is restarted, the current attribute information in the attribute file and the current attribute information in the service status file are obtained, and compared with the key attributes of the corresponding attribute file and the key attributes of the service status file respectively; If the comparison result is consistent, reading the stored service information from the service status file, and restoring the service status when the resident program stops running; The service information of the server is stored in a service status file and a property file is created, including: Saving the service information in binary form in sequence into the service status file; Create the attribute file and save the key attributes of the service status file and the key attributes of the attribute file obtained in advance into the attribute file respectively, wherein the key attributes of the service status file include: the absolute path name of the status file, the modification time of the status file, the MD5 summary information of the status file and the file length of the status file, and the key attributes of the attribute file include: the absolute path name of the attribute file, the modification time of the attribute file, the MD5 summary information of the attribute file and the file length of the attribute file; Obtaining current attribute information in the attribute file and current attribute information in the service status file, and comparing them with key attributes of the corresponding attribute file and key attributes of the service status file, respectively, including: Obtaining current attribute information of the attribute file and key attributes of the attribute file and performing comparison; If the comparison is consistent, obtaining the current attribute information of the service status file and the key attributes of the service status file and performing comparison, and generating the comparison result; The obtaining and comparing the current attribute information of the attribute file and the key attributes of the attribute file includes: Compare the absolute path name of the attribute file, the modification time of the attribute file, the MD5 summary information of the attribute file and the file length of the attribute file with the information corresponding to the current attribute information of the attribute file to see whether they are consistent; The obtaining and comparing the current attribute information of the service status file and the key attributes of the service status file includes: The absolute path name of the service status file, the modification time of the status file, the MD5 summary information of the status file and the file length of the status file are compared to see whether they are consistent with the information corresponding to the current attribute information of the service status file.
2. A server file monitoring device, characterized in that: include: A storage unit, used for storing the service information of the server into a service status file and creating a property file when the resident program of the server stops running, and obtaining several key properties of the status file and saving them into the property file while the server program stops running and records the status file, wherein the property file stores the key properties of the property file and the key properties of the service status file; a comparing unit, configured to obtain the current attribute information in the attribute file and the current attribute information in the service status file when the resident program is restarted, and compare them with the key attributes of the corresponding attribute file and the key attributes of the service status file respectively; A state recovery unit, configured to read the stored service information from the service state file and recover the service state when the resident program stops running if the comparison result is consistent; The storage unit comprises: A binary storage module, used for sequentially saving the service information in a binary manner into the service status file; A property file creation module is used to create the property file and save the key properties of the service status file and the key properties of the property file obtained in advance into the property file respectively, wherein the key properties of the service status file include: the absolute path name of the status file, the modification time of the status file, the MD5 summary information of the status file and the file length of the status file, and the key properties of the property file include: the absolute path name of the property file, the modification time of the property file, the MD5 summary information of the property file and the file length of the property file; The comparison unit comprises: The attribute file comparison module is used to obtain the current attribute information of the attribute file and the key attributes of the attribute file and compare them; A service status file comparison module, for obtaining and comparing the current attribute information of the service status file and the key attributes of the service status file if the comparison is consistent, and generating the comparison result; The attribute file comparison module specifically includes: An information comparison module is used to compare the absolute path name of the attribute file, the modification time of the attribute file, the MD5 summary information of the attribute file and the file length of the attribute file with the information corresponding to the current attribute information of the attribute file to see whether they are consistent; The service status file comparison module specifically includes: The status attribute comparison module is used to compare whether the absolute path name of the service status file, the modification time of the status file, the MD5 summary information of the status file and the file length of the status file are consistent with the information corresponding to the current attribute information of the service status file.
3. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the server file monitoring method of claim 1 is implemented.
4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the server file monitoring method according to claim 1 is implemented.
