CN112579385A - Server file monitoring method and device - Google Patents

Server file monitoring method and device Download PDF

Info

Publication number
CN112579385A
CN112579385A CN201910933322.4A CN201910933322A CN112579385A CN 112579385 A CN112579385 A CN 112579385A CN 201910933322 A CN201910933322 A CN 201910933322A CN 112579385 A CN112579385 A CN 112579385A
Authority
CN
China
Prior art keywords
file
attribute
information
service
server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910933322.4A
Other languages
Chinese (zh)
Inventor
陈继红
文佳敏
孙孝萍
陈雅静
尚民强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China National Petroleum Corp
BGP Inc
Original Assignee
China National Petroleum Corp
BGP Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China National Petroleum Corp, BGP Inc filed Critical China National Petroleum Corp
Priority to CN201910933322.4A priority Critical patent/CN112579385A/en
Publication of CN112579385A publication Critical patent/CN112579385A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3024Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/32Monitoring with visual or acoustical indication of the functioning of the machine
    • G06F11/324Display of status information
    • G06F11/327Alarm or error message display

Abstract

The application provides a server file monitoring method and device, comprising the following steps: when a resident program of a server stops running, storing service information of the server into a service state file and creating an attribute file, wherein the attribute file stores key attributes of the attribute file and key attributes of the service state file; when the resident program is restarted, acquiring current attribute information in the attribute file and current attribute information in the service state file, and respectively comparing the current attribute information with the key attribute of the corresponding attribute file and the key attribute of the service state file; and if the comparison result is consistent, reading the stored service information from the service state file, and recovering the service state when the resident program stops running. The method and the device can prevent the server state file recorded when the server is closed from being tampered, ensure that the correct server state file is loaded when the server is started, and enhance the safety of the server program.

Description

Server file monitoring method and device
Technical Field
The present application belongs to the field of computer technologies, and in particular, to a method and an apparatus for monitoring a server file.
Background
A Client and Server network structure often adopted in the prior art is a Client/Server structure (C/S structure), and a Server program is called Daemon, which is a Server program that runs all the time and is also called a Daemon process. The server-side program Daemon generally runs in the background of the system, has no control terminal, and does not interact with the foreground, and the Daemon program is generally used as system service. Daemon is a process that runs for a long time, usually starting after the system is started and ending when the system is shut down.
Generally, when the Daemon server program finishes running (shutdown), various service information of the current server is recorded into a service state file (StatusFile), which is called a state file for short. When the server program is started next time, finding out the appointed state file, loading the state file information, recovering to the service state when the server finishes the last time, and continuously providing service for the user.
The security of the service status file is important. Because it contains important service state information, the server program needs to ensure that the loaded information is consistent with the information recorded in the last shutdown when being started, so as to prevent malicious programs from tampering with the state file or replacing expired service state information. If wrong information is loaded when the service program is started, a great risk is caused for providing wrong and invalid services.
Disclosure of Invention
The application provides a server file monitoring method and device, which are used for at least solving the problem that a server state file recorded when a server is closed in the prior art cannot be perceived after being maliciously tampered.
According to one aspect of the application, a method for monitoring a server file is provided, which includes: when a resident program of a server stops running, storing service information of the server into a service state file and creating an attribute file, wherein the attribute file stores key attributes of the attribute file and key attributes of the service state file;
when the resident program is restarted, acquiring current attribute information in the attribute file and current attribute information in the service state file, and respectively comparing the current attribute information with the key attribute of the corresponding attribute file and the key attribute of the service state file;
and if the comparison result is consistent, reading the stored service information from the service state file, and recovering the service state when the resident program stops running.
In one embodiment, storing the service information of the server to the service state file and creating the property file includes:
sequentially storing the service information into a service state file in a binary mode;
creating an attribute file and respectively storing the key attribute of the service state file and the key attribute of the attribute file which are acquired in advance into the attribute file, wherein the key attribute of the service state file comprises the following steps: absolute path name of the state file, modification time of the state file, MD5 summary information of the state file, and file length of the state file, and key attributes of the attribute file include: absolute path name of the property file, modification time of the property file, MD5 digest information of the property file, and file length of the property file.
In an embodiment, the obtaining current attribute information in the attribute file and current attribute information in the service status file, and comparing the obtained current attribute information with the key attribute of the corresponding attribute file and the key attribute of the service status file respectively includes:
acquiring current attribute information of the attribute file and key attributes of the attribute file and comparing the current attribute information with the key attributes;
and if the comparison is consistent, acquiring the current attribute information of the service state file and the key attribute of the service state file, comparing the current attribute information and the key attribute of the service state file, and generating a comparison result.
In one embodiment, obtaining and comparing the current attribute information of the attribute file and the key attribute of the attribute file includes:
and comparing whether 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 information corresponding to the file length of the attribute file and the current attribute information of the attribute file are consistent or not.
In one embodiment, obtaining and comparing the current attribute information of the service state file and the key attribute of the service state file includes:
and comparing whether the absolute path name of the service state file, the modification time of the state file, the MD5 summary information of the state file and the file length of the state file are consistent with the information corresponding to the current attribute information of the service state file.
According to another aspect of the present application, there is provided a server file monitoring apparatus including:
the storage unit is used for storing the service information of the server to the service state file and creating an attribute file when a resident program of the server stops running, wherein the attribute file stores the key attribute of the attribute file and the key attribute of the service state file;
the comparison unit is used for acquiring the current attribute information in the attribute file and the current attribute information in the service state file when the resident program is restarted, and comparing the current attribute information in the attribute file and the current attribute information in the service state file with the key attribute of the corresponding attribute file and the key attribute of the service state file respectively;
and the state recovery unit is used for reading the stored service information from the service state file and recovering the service state when the resident program stops running if the comparison result is consistent.
In one embodiment, a memory cell includes:
the binary system storage module is used for sequentially storing the service information into the service state file in a binary system mode;
the attribute file creating module is used for creating an attribute file and respectively storing the key attribute of the service state file and the key attribute of the attribute file which are acquired in advance into the attribute file, wherein the key attribute of the service state file comprises the following steps: absolute path name of the state file, modification time of the state file, MD5 summary information of the state file, and file length of the state file, and key attributes of the attribute file include: absolute path name of the property file, modification time of the property file, MD5 digest information of the property file, and file length of the property file.
In one embodiment, the alignment unit includes:
the attribute file comparison module is used for acquiring the current attribute information of the attribute file and the key attribute of the attribute file and comparing the current attribute information with the key attribute;
and the service state file comparison module is used for acquiring the current attribute information of the service state file and the key attribute of the service state file and comparing the current attribute information and the key attribute of the service state file if the comparison is consistent, and generating a comparison result.
In an embodiment, the attribute file comparison module specifically includes:
and the information comparison module is used for comparing whether the absolute path name of the attribute file, the modification time of the attribute file, the MDS abstract information of the attribute file and the information corresponding to the file length of the attribute file and the current attribute information of the attribute file are consistent or not.
In an embodiment, the service status file comparison module specifically includes:
and the state attribute comparison module is used for comparing whether the absolute path name of the service state file, the modification time of the state file, the MD5 abstract information of the state file and the file length of the state file are consistent with the information corresponding to the current attribute information of the service state file.
According to the method and the device, the state file when the server is closed and the important attribute information of the attribute file are stored in the attribute file in a mode of creating the attribute file, when the server operates again, the data pre-stored in the attribute file are compared with the data when the server operates again, if the data are inconsistent, the operation is immediately stopped, the consistency of the information when the server stops operating and starts operating again is ensured, and the server is prevented from providing wrong service due to the fact that malicious programs falsify the state file information.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a server file protection method provided in the present application.
Fig. 2 is a flowchart of a method for storing service information in a service state file and creating an attribute file according to the present application.
Fig. 3 is a flowchart of a method of an information comparison inspection link according to the present application.
Fig. 4 is a block diagram of a server file protection apparatus according to the present application.
Fig. 5 is a specific implementation of an electronic device in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the prior art, a server state file recorded when a server is closed is easily tampered by malicious software or viruses, so that the tampered server state file is loaded when the server is started, and great loss is caused. Therefore, the server file protection method is provided to prevent the server state file recorded when the server is closed from being tampered, ensure that the correct server state file is loaded when the server is started, and remarkably enhance the security of the server program. As shown in fig. 1, a server file protection method provided by the present application includes the following steps:
s101: when the resident program of the server stops running, the service information of the server is stored in the service state file and an attribute file is created, wherein the attribute file is used for storing the key attribute of the service state file and is also used for storing the key attribute of the attribute file.
In one embodiment, when the server program (i.e. the resident program of the server) finishes running, the server program records/stores the service information of the server into a service state file (state file for short), and at the same time, creates a property file, in which key attributes of the service state file, such as absolute path name, modification time, MD5 summary information, file length, INODE, etc., are recorded in a certain order. Meanwhile, the attribute file also records the key attribute of the attribute file.
S102: when the resident program is restarted, the current attribute information in the attribute file and the current attribute information in the service state file are obtained and are respectively compared with the key attribute of the corresponding attribute file and the key attribute of the service state file.
In a specific embodiment, when the server program starts running, the current attribute information of the service state file stored when the server program stops running last time and the attribute file created in step S101 may be found and the current attribute information of the attribute file may be obtained, and then the current attribute information of the attribute file may be compared with the key attribute of the attribute file stored in the attribute file, and the current attribute information of the state file may be compared with the important attribute of the state file stored in the attribute file.
S103: and if the comparison result is consistent, reading the stored service information from the service state file, and recovering the service state when the resident program stops running.
In a specific embodiment, if the comparison results in S102 are all consistent, the server program reads the service information of the last run end from the state file and loads the service information of the last run end into the program to continue to resume the running of the program.
The method shown in fig. 1 can be executed by a server, a PC, and a mobile terminal, and the method establishes an attribute description file, referred to as an attribute file, of a server state file, obtains several key attributes of the state file and stores them in the attribute file while a server program stops running and records the state file, and stores several important attributes of the attribute file into the attribute file, so as to implement a function of first reading the attribute file when the server program starts running, and confirming whether the state file is tampered by checking and comparing the attribute information of the current state file and the attribute file with the consistency of the key attributes of the state file and the attribute file recorded in the attribute file. Therefore, correct service information is loaded when the server program is started, and the safety and the information consistency of the server are ensured.
In one embodiment, as shown in fig. 2, storing the service information of the server to the service status file and creating the property file includes:
s201: and sequentially storing the service information into the service state file in a binary mode.
In a specific embodiment, when the server program stops running, the various service information used in the server program may be sequentially saved in the state file in a binary manner according to a preset sequence, so that the server program can load the service information saved in the state file when starting next time and then continue to run the program.
S202: creating an attribute file and respectively storing the key attribute of the service state file and the key attribute of the attribute file which are acquired in advance into the attribute file, wherein the key attribute of the service state file comprises the following steps: absolute path name of the state file, modification time of the state file, MD5 summary information of the state file, and file length of the state file, and key attributes of the attribute file include: absolute path name of the property file, modification time of the property file, MD5 digest information of the property file, and file length of the property file.
In one embodiment, the server program obtains the attribute information of the state file by using a Linux operating system command or a corresponding POSIX interface, where the attribute information (see table 1) includes: absolute pathname of state file, modification time, MD5 digest information, INODE, file length (number of bytes).
Table 1 Attribute File content
Figure BDA0002220876460000061
Wherein:
1. absolute PATH name (ST _ PATH): the name of the path agreed for the server. Generally a fixed name.
2. Modification time (ST _ MTIME): the last modification time of the state file can be obtained using a stat command or interface. See stat command example: modify: 2017-09-2011: 37:03.823669038+0800
Stat command example:
[cjh@bgp~]$stat 1
File:`1'
Size:217 Blocks:8 IO Block:4096 regular file
Device:fd00h/64768d Inode:1204114 Links:1
Access:(0777/-rwxrwxrwx)Uid:(502/ cjh)Gid:(502/ cjh)
Access:2018-12-28 10:09:41.739390129+0800
Modify:2017-09-20 11:37:03.823669038+0800
Change:2017-09-20 11:37:03.823669038+0800
3. MD5 digest information (ST _ MD 5): the method for acquiring the abstract information comprises the following steps: the content of the state file is coded in 16-ary format using the result calculated by the MD5 digest algorithm in OPENSSL, and ST _ MD5 is HEX (MD5(StatusFile)) and is in the format of a 16-ary number of 32 bytes. Such as: 8b58265aa564fb54147d7267051b0232
4. INODE (ST _ INODE): INODE is the I node of a file, the physical meaning of which is the location of the file stored in disk. (see stat Command example) Inode:1204114
5. File length (ST _ SIZE): the information is the file length and the number of bytes. A stat command or interface fetch may be used.
In an embodiment, as shown in fig. 3, the obtaining current attribute information in the attribute file and current attribute information in the service status file, and comparing the obtained current attribute information and current attribute information with the key attribute of the corresponding attribute file and the key attribute of the service status file respectively includes:
s301: and acquiring current attribute information of the attribute file and the key attribute of the attribute file and comparing the current attribute information with the key attribute of the attribute file.
In a specific embodiment, when the server program starts running, the service state file and the attribute file stored when the server program finishes running last time may be found, then the current attribute information of the attribute file is obtained by using an operating system command or a POSIX interface, then the key attribute of the attribute file recorded in the attribute file is read, and the current attribute information is compared with the key attribute, if the information is inconsistent, it is indicated that the attribute file has been damaged or tampered, and at this time, the server program stops service.
S302: and if the comparison is consistent, acquiring the current attribute information of the service state file and the key attribute of the service state file, comparing the current attribute information and the key attribute of the service state file, and generating a comparison result.
In one embodiment, obtaining and comparing the current attribute information of the attribute file and the key attribute of the attribute file includes:
comparing whether the absolute path name of the attribute file, the modification time of the attribute file, the MDS abstract information of the attribute file and the information corresponding to the file length of the attribute file and the current attribute information of the attribute file are consistent or not, and specifically comprising the following steps:
3.1: firstly, using a system command to obtain attribute information of an attribute file:
CAT_PATH,CAT_MTIME,CAT_INODE
3.2: reading and analyzing the attribute file to obtain the state file and the attribute value recorded when the server stops last time of the attribute file:
3.2.1: reading the attribute of the obtained state file:
ST_PATH,ST_MTIME,ST_MD5,ST_INODE,ST_SIZE;
3.2.2: reading: AT _ PATH
Compare if it is the committed path, else fail exit.
3.2.3: reading: AT _ INDDE
The comparison is consistent with CAT _ INDODE, otherwise, the error exits. The location on the disk that indicates the file is changed or replaced with another file.
3.2.4: reading: AT _ STRSIZE, the random string AT _ TRS is read according to the length.
3.2.4: reading: 32 bytes of AT _ MD5 information
Calculating MD5 information of the actual property file:
CAT_MD5=HEX(MD5(ST_PATH+ST_MTIME+ST_MD5+ST_INODE+ST_SIZ E+AT_PATH+AT_INODE+AT_STRSIZE+ST_STR))
compare AT _ MD5 for consistency with CAT _ MD5, otherwise exit in error. Indicating that the property file content has been tampered with.
3.2.5, obtaining the current file position information: CAT _ SIZE
Reading: AT _ SIZE
And comparing whether AT _ SIZE is consistent with CAT _ SIZE, and if not, exiting in error. Indicating that the attribute file length is wrong.
3.2.6: reading: AT _ TIME
And comparing whether the AT _ TIME is consistent with the CAT _ TIME, and if not, exiting in error. Indicating that the property file has been modified.
In one embodiment, obtaining and comparing the current attribute information of the service state file and the key attribute of the service state file includes:
and comparing whether the absolute path name of the service state file, the modification time of the state file, the MDS abstract information of the state file and the file length of the state file are consistent with the information corresponding to the current attribute information of the service state file.
In one embodiment, the step of comparing the current attribute information of the service status file with the key attribute of the service status file specifically includes the following steps:
firstly, obtaining attribute information of a state file by using an operating system command or a POSIX interface, reading the attribute information of the state file recorded by the attribute file, and then comparing the attribute information and the attribute information, wherein the specific steps are as follows:
4.1: firstly, the system command is used to obtain the attribute of the state file:
CST_PATH,CST_MTIME,CST_MD5,CST_INODE,CST_SIZE
4.2: comparing attributes of state files read from attribute files
ST_PATH,ST_MTIME,ST_MD5,ST_INODE,ST_SIZE;
If CST _ PATH is equal to ST _ PATH,
CST_MTIME==ST_MTIME,
CST_MD5==ST_MD5,
CST_INODE==ST_INODE,
CST_SIZE==ST_SIZE
if the comparison information is inconsistent, the server program reports an error, the state file is described to be inconsistent with the information recorded when the server stops, and the server stops the service.
And if the comparison information is consistent, reading the stored service information from the service state file, and recovering the service state when the resident program stops running.
Based on the same inventive concept, the embodiment of the present application further provides a server file monitoring apparatus, which can be used to implement the method described in the above embodiment, as described in the following embodiments. Because the principle of solving the problems of 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 repeated parts are not repeated. As used hereinafter, the term "unit" or "module" may be a combination of software and/or hardware that implements a predetermined function. While the system described in the embodiments below is preferably implemented in software, implementations in hardware, or a combination of software and hardware are also possible and contemplated.
As shown in fig. 4, a server file monitoring apparatus includes:
a storage unit 401, configured to store service information of a server to a service state file and create an attribute file when a resident program of the server stops running, where the attribute file stores a key attribute of the attribute file and a key attribute of the service state file;
a comparing unit 402, configured to, when the resident program is restarted, obtain current attribute information in the attribute file and current attribute information in the service state file, and compare the current attribute information with the key attribute of the corresponding attribute file and the key attribute of the service state file respectively;
a state recovery unit 403, configured 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.
In one embodiment, the memory unit 401 includes:
the binary system storage module 4011 is configured to sequentially store the service information in the service state file in a binary system manner;
the property file creating module 4012 is configured to create a property file, and store the key attribute of the service state file and the key attribute of the property file, which are obtained in advance, into the property file, respectively, where the key attribute of the service state file includes: the absolute path name of the state file, the modification time of the state file, the MDS abstract information of the state file and the file length of the state file, and the key attributes of the attribute file comprise: 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.
In one embodiment, the comparing unit 402 comprises:
the attribute file comparison module 4021 is used for acquiring current attribute information of the attribute files and key attributes of the attribute files and comparing the current attribute information and the key attributes;
the service state file comparison module 4022 is configured to, if the comparison is consistent, obtain current attribute information of the service state file and the key attribute of the service state file, compare the current attribute information and the key attribute of the service state file, and generate a comparison result.
In an embodiment, the attribute file comparing module 4021 specifically includes:
and the information comparison module is used for comparing whether the absolute path name of the attribute file, the modification time of the attribute file, the MDS abstract information of the attribute file and the information corresponding to the file length of the attribute file and the current attribute information of the attribute file are consistent or not.
In an embodiment, the service status file comparing module 4022 specifically includes:
and the state attribute comparison module is used for comparing whether the absolute path name of the service state file, the modification time of the state file, the MDS abstract information of the state file and the file length of the state file are consistent with the information corresponding to the current attribute information of the service state file.
By the server file monitoring device, the consistency of service information of the server program when the server program stops running and restarts the running is ensured; and prevent malicious programs from tampering state file information and replacing expired state files to cause the service programs to provide wrong services, thereby ensuring the safety of the server programs.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The principle and the implementation mode of the invention are explained by applying specific embodiments in the invention, and the description of the embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
An embodiment of the present application further provides a specific implementation manner of an electronic device capable of implementing all steps in the method in the foregoing embodiment, and referring to fig. 5, the electronic device specifically includes the following contents:
a processor (processor)501, a memory 502, a communication Interface 503, a bus 504, and a nonvolatile memory 505;
the processor 501, the memory 502 and the communication interface 503 complete mutual communication through the bus 504;
the processor 501 is configured to call the computer programs in the memory 502 and the nonvolatile memory 505, and when the processor executes the computer programs, the processor implements all the steps in the method in the foregoing embodiments, for example, when the processor executes the computer programs, the processor implements the following steps:
s101: when the resident program of the server stops running, the service information of the server is stored in the service state file and the attribute file is created, wherein the attribute file stores the key attribute of the attribute file and the key attribute of the service state file.
S102: when the resident program is restarted, the current attribute information in the attribute file and the current attribute information in the service state file are obtained and are respectively compared with the key attribute of the corresponding attribute file and the key attribute of the service state file.
S103: and if the comparison result is consistent, reading the stored service information from the service state file, and recovering the service state when the resident program stops running.
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, where the computer-readable storage medium stores thereon a computer program, and the computer program when executed by a processor implements all the steps of the method in the above embodiments, for example, the processor implements the following steps when executing the computer program:
s101: when the resident program of the server stops running, the service information of the server is stored in the service state file and the attribute file is created, wherein the attribute file stores the key attribute of the attribute file and the key attribute of the service state file.
S102: when the resident program is restarted, the current attribute information in the attribute file and the current attribute information in the service state file are obtained and are respectively compared with the key attribute of the corresponding attribute file and the key attribute of the service state file.
S103: and if the comparison result is consistent, reading the stored service information from the service state file, and recovering the service state when the resident program stops running.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the hardware + program class embodiment, since it is substantially similar to the method embodiment, the description is simple, and the relevant points can be referred to the partial description of the method embodiment. Although embodiments of the present description provide method steps as described in embodiments or flowcharts, more or fewer steps may be included based on conventional or non-inventive means. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. When an actual apparatus or end product executes, it may execute sequentially or in parallel (e.g., parallel processors or multi-threaded environments, or even distributed data processing environments) according to the method shown in the embodiment or the figures. The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, the presence of additional identical or equivalent elements in a process, method, article, or apparatus that comprises the recited elements is not excluded. For convenience of description, the above devices are described as being divided into various modules by functions, and are described separately. Of course, in implementing the embodiments of the present description, the functions of each module may be implemented in one or more software and/or hardware, or a module implementing the same function may be implemented by a combination of multiple sub-modules or sub-units, and the like. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form. The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein. The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment. In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of an embodiment of the specification.
In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction. The above description is only an example of the embodiments of the present disclosure, and is not intended to limit the embodiments of the present disclosure. Various modifications and variations to the embodiments described herein will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiments of the present specification should be included in the scope of the claims of the embodiments of the present specification.

Claims (12)

1. A server file monitoring method is characterized by comprising the following steps:
when a resident program of a server stops running, storing service information of the server into a service state file and creating an attribute file, wherein the attribute file stores key attributes of the attribute file and key attributes of the service state file;
when the resident program is restarted, acquiring current attribute information in the attribute file and current attribute information in the service state file, and respectively comparing the current attribute information with the key attribute of the corresponding attribute file and the key attribute of the service state file;
and if the comparison result is consistent, reading the stored service information from the service state file, and recovering the service state when the resident program stops running.
2. The server file monitoring method according to claim 1, wherein storing the service information of the server to a service status file and creating a property file comprises:
sequentially storing the service information into the service state file in a binary mode;
creating the attribute file and respectively storing the key attribute of the service state file and the key attribute of the attribute file, which are acquired in advance, into the attribute file, wherein the key attribute of the service state file comprises: absolute path name of the state file, modification time of the state file, MD5 summary information of the state file, and file length of the state file, and the key attributes of the attribute file include: absolute path name of the property file, modification time of the property file, MD5 digest information of the property file, and file length of the property file.
3. The method for monitoring the server file according to claim 2, wherein the step of obtaining the current attribute information in the attribute file and the current attribute information in the service status file and comparing the obtained current attribute information with the key attribute of the corresponding attribute file and the key attribute of the service status file respectively comprises the steps of:
acquiring current attribute information of the attribute file and key attributes of the attribute file and comparing the current attribute information with the key attributes;
and if the comparison is consistent, acquiring the current attribute information of the service state file and the key attribute of the service state file, comparing the current attribute information and the key attribute of the service state file, and generating a comparison result.
4. The server file monitoring method according to claim 3, wherein the obtaining and comparing the current attribute information of the attribute file and the key attribute of the attribute file comprises:
and comparing whether 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 information corresponding to the file length of the attribute file and the current attribute information of the attribute file are consistent or not.
5. The server file monitoring method according to claim 3, wherein the obtaining and comparing the current attribute information of the service status file and the key attribute of the service status file comprises:
and comparing whether the absolute path name of the service state file, the modification time of the state file, the MD5 summary information of the state file and the file length of the state file are consistent with the information corresponding to the current attribute information of the service state file.
6. A server file monitoring apparatus, comprising:
the storage unit is used for storing the service information of the server to a service state file and creating an attribute file when a resident program of the server stops running, wherein the attribute file stores the key attribute of the attribute file and the key attribute of the service state file;
the comparison unit is used for acquiring the current attribute information in the attribute file and the current attribute information in the service state file when the resident program is restarted, and comparing the current attribute information in the attribute file and the current attribute information in the service state file with the key attribute of the corresponding attribute file and the key attribute of the service state file respectively;
and the state recovery unit is used for reading the stored service information from the service state file and recovering the service state when the resident program stops running if the comparison result is consistent.
7. The server file monitoring apparatus according to claim 6, wherein the storage unit includes:
the binary system storage module is used for sequentially storing the service information into the service state file in a binary system mode;
an attribute file creating module, configured to create the attribute file and store the key attribute of the service state file and the key attribute of the attribute file, which are obtained in advance, into the attribute file, respectively, where the key attribute of the service state file includes: absolute path name of the state file, modification time of the state file, MD5 summary information of the state file, and file length of the state file, and the key attributes of the attribute file include: absolute path name of the property file, modification time of the property file, MD5 digest information of the property file, and file length of the property file.
8. The apparatus according to claim 6, wherein the comparing unit comprises:
the attribute file comparison module is used for acquiring the current attribute information of the attribute file and the key attribute of the attribute file and comparing the current attribute information with the key attribute;
and the service state file comparison module is used for acquiring the current attribute information of the service state file and the key attribute of the service state file and comparing the current attribute information and the key attribute of the service state file if the comparison is consistent, and generating a comparison result.
9. The apparatus for monitoring a server file according to claim 8, wherein the attribute file comparison module specifically comprises:
and the information comparison module is used for comparing whether the absolute path name of the attribute file, the modification time of the attribute file, the MD5 abstract information of the attribute file and the information corresponding to the file length of the attribute file and the current attribute information of the attribute file are consistent or not.
10. The apparatus for monitoring server files according to claim 8, wherein the service status file comparison module specifically comprises:
and the state attribute comparison module is used for comparing whether the absolute path name of the service state file, the modification time of the state file, the MD5 abstract information of the state file and the file length of the state file are consistent with the information corresponding to the current attribute information of the service state file.
11. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the server file monitoring method according to any one of claims 1 to 5 when executing the program.
12. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the server file monitoring method according to any one of claims 1 to 5.
CN201910933322.4A 2019-09-29 2019-09-29 Server file monitoring method and device Pending CN112579385A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910933322.4A CN112579385A (en) 2019-09-29 2019-09-29 Server file monitoring method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910933322.4A CN112579385A (en) 2019-09-29 2019-09-29 Server file monitoring method and device

Publications (1)

Publication Number Publication Date
CN112579385A true CN112579385A (en) 2021-03-30

Family

ID=75111382

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910933322.4A Pending CN112579385A (en) 2019-09-29 2019-09-29 Server file monitoring method and device

Country Status (1)

Country Link
CN (1) CN112579385A (en)

Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080120350A1 (en) * 2001-11-09 2008-05-22 Persystent Technology Corporation System and Method for Management of End User Computing Devices
CN102135911A (en) * 2011-03-23 2011-07-27 中国工商银行股份有限公司 Method, device and system for starting and stopping server process
CN102200941A (en) * 2010-03-25 2011-09-28 杭州华三通信技术有限公司 Method and unit for monitoring process state
CN103942058A (en) * 2013-01-17 2014-07-23 深圳市潮流网络技术有限公司 Embedded electronic equipment software updating method and system
CN104573500A (en) * 2014-09-10 2015-04-29 中电科技(北京)有限公司 UEFI (Unified Extensible Firmware Interface)-based software real-time protection system and UEFI-based software real-time protection method
CN106371911A (en) * 2016-09-06 2017-02-01 北京海誉动想科技股份有限公司 Method for rebooting guarded process by daemon processes
CN106844491A (en) * 2016-12-26 2017-06-13 中国石油天然气集团公司 A kind of write-in of ephemeral data, read method and write-in, reading device
CN107623581A (en) * 2016-07-15 2018-01-23 阿里巴巴集团控股有限公司 Service list generation method, apparatus and system, acquisition, report method and device
CN107729755A (en) * 2017-09-28 2018-02-23 努比亚技术有限公司 A kind of terminal safety management method, terminal and computer-readable recording medium
CN108255631A (en) * 2017-12-28 2018-07-06 努比亚技术有限公司 Mobile terminal restarts localization method, mobile terminal and computer readable storage medium
CN109240809A (en) * 2017-07-11 2019-01-18 阿里巴巴集团控股有限公司 Process maintenance management method, container maintaining method, device and operating system
CN109413164A (en) * 2018-10-09 2019-03-01 郑州云海信息技术有限公司 A kind of access service recovery method, device, equipment and readable storage medium storing program for executing
CN109522147A (en) * 2018-11-15 2019-03-26 Oppo广东移动通信有限公司 A kind of method, apparatus, storage medium and the terminal of record booting exception information

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080120350A1 (en) * 2001-11-09 2008-05-22 Persystent Technology Corporation System and Method for Management of End User Computing Devices
CN102200941A (en) * 2010-03-25 2011-09-28 杭州华三通信技术有限公司 Method and unit for monitoring process state
CN102135911A (en) * 2011-03-23 2011-07-27 中国工商银行股份有限公司 Method, device and system for starting and stopping server process
CN103942058A (en) * 2013-01-17 2014-07-23 深圳市潮流网络技术有限公司 Embedded electronic equipment software updating method and system
CN104573500A (en) * 2014-09-10 2015-04-29 中电科技(北京)有限公司 UEFI (Unified Extensible Firmware Interface)-based software real-time protection system and UEFI-based software real-time protection method
CN107623581A (en) * 2016-07-15 2018-01-23 阿里巴巴集团控股有限公司 Service list generation method, apparatus and system, acquisition, report method and device
CN106371911A (en) * 2016-09-06 2017-02-01 北京海誉动想科技股份有限公司 Method for rebooting guarded process by daemon processes
CN106844491A (en) * 2016-12-26 2017-06-13 中国石油天然气集团公司 A kind of write-in of ephemeral data, read method and write-in, reading device
CN109240809A (en) * 2017-07-11 2019-01-18 阿里巴巴集团控股有限公司 Process maintenance management method, container maintaining method, device and operating system
CN107729755A (en) * 2017-09-28 2018-02-23 努比亚技术有限公司 A kind of terminal safety management method, terminal and computer-readable recording medium
CN108255631A (en) * 2017-12-28 2018-07-06 努比亚技术有限公司 Mobile terminal restarts localization method, mobile terminal and computer readable storage medium
CN109413164A (en) * 2018-10-09 2019-03-01 郑州云海信息技术有限公司 A kind of access service recovery method, device, equipment and readable storage medium storing program for executing
CN109522147A (en) * 2018-11-15 2019-03-26 Oppo广东移动通信有限公司 A kind of method, apparatus, storage medium and the terminal of record booting exception information

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
安留洋;黄永忠;兰明敬;赵旭;: "服务恢复中上下文建模与持久化", 计算机工程与应用, no. 02, pages 85 - 91 *
陈继红;: "基于3G技术的车辆跟踪服务系统的研究", 物探装备, no. 03, pages 20 - 24 *

Similar Documents

Publication Publication Date Title
CN106156186B (en) Data model management device, server and data processing method
US10621212B2 (en) Language tag management on international data storage
CN105511911A (en) System firmware upgrade package generation method and device
US10719502B2 (en) Information processing apparatus and control method for information processing apparatus
CN109542461A (en) Dissemination method, terminal device and the medium of application installation package
CN111858468B (en) Method, system, terminal and storage medium for verifying metadata of distributed file system
CN111008034B (en) Patch generation method and device
CN110162344B (en) Isolation current limiting method and device, computer equipment and readable storage medium
CN112306552A (en) System software version management method, device and storage medium
CN112860645A (en) Processing method and device for offline compressed file, computer equipment and medium
CN107391303B (en) Data processing method, device, system, server and computer storage medium
CN112256532A (en) Test interface generation method and device, computer equipment and readable storage medium
CN110083493A (en) A kind of embedded system failure self-recovery method, terminal device and storage medium
CN106155723B (en) Method and device for upgrading service application program, terminal and computer storage medium
CN112579385A (en) Server file monitoring method and device
CN111752600B (en) Code anomaly detection method and device, computer equipment and storage medium
CN113238748B (en) Direct current control and protection program page modification and verification method, device, terminal and medium
CN113806309A (en) Metadata deleting method, system, terminal and storage medium based on distributed lock
CN112579330B (en) Processing method, device and equipment for abnormal data of operating system
CN114153503A (en) BIOS control method, device and medium
CN113595762A (en) Network card configuration storage method and device
CN111444057A (en) Page performance data acquisition method and device and computing equipment
CN113157645B (en) Cluster data migration method, device, equipment and storage medium
CN112363870B (en) Application program development processing method and device, computer equipment and storage medium
US8825610B1 (en) System management based on goals relevant to a current state of a managed system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination