CN109240886B - Exception handling method, exception handling device, computer equipment and storage medium - Google Patents

Exception handling method, exception handling device, computer equipment and storage medium Download PDF

Info

Publication number
CN109240886B
CN109240886B CN201811021610.4A CN201811021610A CN109240886B CN 109240886 B CN109240886 B CN 109240886B CN 201811021610 A CN201811021610 A CN 201811021610A CN 109240886 B CN109240886 B CN 109240886B
Authority
CN
China
Prior art keywords
exception
abnormal
interface
preset
application program
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.)
Active
Application number
CN201811021610.4A
Other languages
Chinese (zh)
Other versions
CN109240886A (en
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811021610.4A priority Critical patent/CN109240886B/en
Publication of CN109240886A publication Critical patent/CN109240886A/en
Application granted granted Critical
Publication of CN109240886B publication Critical patent/CN109240886B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the invention discloses an exception handling method, an exception handling device, computer equipment and a storage medium, wherein the method comprises the following steps: determining a log file corresponding to an application program; if the application program is detected to throw the abnormity, searching abnormal information corresponding to the abnormity of the application program in the log file; acquiring an abnormal keyword corresponding to the abnormal information by using a preset script; identifying an abnormal type and an abnormal grade according to the abnormal keyword; and calling a preset exception handling interface to handle exception according to the exception type and the exception grade. The embodiment of the invention can realize the capture of the exception and automatically process the captured exception.

Description

Exception handling method and device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to an exception handling method and apparatus, a computer device, and a storage medium.
Background
In the prior art, there is no complete and reasonable response mechanism for system exception, on one hand, when system exception occurs, if program codes are written correspondingly for each exception manually for exception handling, a large amount of manpower and material resources are usually spent, which causes waste of manpower and material resources; on the other hand, automatic response and automatic processing cannot be realized aiming at various exceptions; with the continuous innovation of the technology and the continuous increase of the service volume, the existing abnormal response mechanism can not meet the current service requirements and development.
Disclosure of Invention
In view of this, embodiments of the present invention provide an exception handling method and apparatus, a computer device, and a storage medium, which can capture an exception and automatically handle the captured exception.
In one aspect, an embodiment of the present invention provides an exception handling method, where the method includes:
determining a log file corresponding to an application program;
if the application program is detected to throw the abnormity, searching abnormal information corresponding to the abnormity of the application program in the log file;
acquiring abnormal keywords corresponding to the abnormal information by using a preset script;
identifying an abnormal type and an abnormal grade according to the abnormal keyword;
and calling a preset exception handling interface to handle exception according to the exception type and the exception level.
In another aspect, an embodiment of the present invention provides an exception handling apparatus, where the apparatus includes:
the determining unit is used for determining the log file corresponding to the application program;
the searching unit is used for searching the abnormal information corresponding to the abnormality of the application program in the log file if the application program is detected to throw the abnormality;
the acquiring unit is used for acquiring the abnormal key words corresponding to the abnormal information by using a preset script;
the identification unit is used for identifying the abnormal type and the abnormal grade according to the abnormal keyword;
and the processing unit is used for calling a preset exception handling interface to handle exception according to the exception type and the exception grade.
In still another aspect, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the exception handling method as described above when executing the computer program.
In still another aspect, the present invention also provides a computer-readable storage medium, where one or more computer programs are stored, and the one or more computer programs are executable by one or more processors to implement the exception handling method described above.
The embodiment of the invention provides an exception handling method, an exception handling device, computer equipment and a storage medium, wherein the method comprises the following steps: determining a log file corresponding to an application program; if the application program is detected to throw the abnormity, searching abnormal information corresponding to the abnormity of the application program in the log file; acquiring an abnormal keyword corresponding to the abnormal information by using a preset script; identifying an abnormal type and an abnormal grade according to the abnormal keyword; and calling a preset exception handling interface to handle exception according to the exception type and the exception level. The embodiment of the invention can realize the capture of the abnormity and automatically process the captured abnormity.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a schematic flow chart diagram of a method for exception handling according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart diagram of an exception handling method according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart diagram of a method for exception handling according to an embodiment of the present invention;
FIG. 4 is a schematic block diagram of an exception handling apparatus according to an embodiment of the present invention;
FIG. 5 is another schematic block diagram of an exception handling apparatus provided by an embodiment of the present invention;
FIG. 6 is another schematic block diagram of an exception handling apparatus provided by an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
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 some, not all, embodiments of the present invention. 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.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the specification of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
Referring to fig. 1, fig. 1 is a schematic flow chart of an exception handling method according to an embodiment of the present invention. The method can be operated in terminals such as smart phones (such as Android phones, IOS phones and the like), tablet computers, notebook computers, smart devices and the like. As shown in fig. 1, the method includes steps S101 to S105.
S101, determining a log file corresponding to the application program.
In the embodiment of the present invention, the log file permanently records events in the application program operation aspect, each application program has an independent log file to record events occurring during the application program operation process, for example, application exceptions occurring in the application program (e.g., exceptions such as a host volume full, a CPU (Central Processing Unit) usage rate high, a thread blocking, a memory shortage, an I/O (Input/Output) read-write slow, and an application file missing) may find corresponding records from the log file of the application program, or the database program of the application program may also record database program operation errors in the log file. Specifically, the log file exists in a specified file format in the application program, for example, the log format, and in this embodiment, all log files in the log format in the application program can be viewed through a cmd command.
S102, if the application program is detected to throw the abnormity, the abnormal information corresponding to the abnormity of the application program is searched in the log file.
In the embodiment of the present invention, a code block thrown by an exception is set for a code position corresponding to an application program that may generate an exception, for example, a try-catch-final block is set for a code position corresponding to an application program that is prone to generate an exception to detect, where the try block includes a code statement that may generate an exception, the catch block is responsible for capturing the exception that occurs in the try block, and the final block is responsible for executing other user-defined execution statements (for example, sending the captured exception to a caller, etc.), where the exception that occurs in the try block may be multiple exceptions, and for multiple different exceptions, multiple catch blocks need to be set to capture to detect that the application program throws an exception. In this embodiment, because the log file records events occurring during the running process of the application program, when the application program throws an exception, exception information for the exception may be found from the log file corresponding to the application program, where the exception information includes running information of the application program and environment information such as CPU utilization, thread occupancy information, and memory occupancy.
In one embodiment, the abnormality information may further include time information of occurrence of an abnormality, and the like.
Further, referring to fig. 2, the step S102 includes steps S202 to S204.
S202, recording timestamp information generated when the application throws the exception by using a flash collection system.
In the embodiment of the invention, an event that an application throws an exception is monitored by a data collection component (such as an agent component) in a flash collection system, and timestamp information when the event occurs is collected; the timestamp information includes a time node when the application throws the exception, the time node corresponding to a system time on the application.
S204, the log file is positioned according to the timestamp information, and abnormal information corresponding to the abnormality of the application program is found.
In the embodiment of the present invention, the time stamp information at the time of occurrence of the abnormality, which is collected by the flash collection system, is located in the log file, and specifically, since the time information at the time of occurrence of the abnormality of the application program is recorded in the log file, the collected time stamp information is compared with the time information at the time of occurrence of the abnormality in the log file, so that the abnormality information recorded in the log file can be located, so as to obtain the corresponding abnormality information.
S103, acquiring abnormal keywords corresponding to the abnormal information by using a preset script.
In this embodiment of the present invention, the preset script includes a shell script, and the specifically obtaining the abnormal keyword corresponding to the abnormal information by using the preset script includes: and acquiring abnormal keywords corresponding to the abnormal information by using a grep command of the shell script. For example, when the CPU utilization is high, the abnormal keyword obtained through the grep command in the shell script is "the CPU utilization is high"; when the memory is insufficient, the abnormal keyword acquired through the grep command in the shell script is 'out of memory' and the like.
And S104, identifying the abnormal type and the abnormal grade according to the abnormal keyword.
In the embodiment of the invention, the exception type and the exception level can be set, wherein the exception type comprises the types of the application program exception, the environment exception and the like, and the environment exception comprises the types of high CPU utilization rate, insufficient memory, thread blocking and the like. Further, the anomalies may be classified into different levels in advance, for example, a level 1 anomaly is a lowest level anomaly, such as lowest alarm information of an application program; the grade 5 abnormality is the highest grade abnormality, such as a downtime alarm abnormality. Different exception information corresponds to different exception types and exception levels. For example, if a CPU abnormality is detected, the abnormality type is identified as high CPU utilization. And when the downtime alarm occurs, identifying that the abnormal grade is grade 5 abnormal and the like.
And S105, calling a preset exception handling interface to handle exception according to the exception type and the exception grade.
In the embodiment of the present invention, the exception handling interface may be preset, and the interface table entry may be configured in the exception handling interface to establish a mapping relationship between the exception type and the exception level and the preset exception handling interface, that is, different preset exception handling interfaces correspond to different exception types and exception levels, and different preset exception handling interfaces are called to handle exceptions according to the identified exception types and exception levels. The preset exception handling interface comprises an exception handling interface Handler customized by a programmer according to the requirement of the programmer and a default exception handling interface DefaultHandler for handling common exceptions.
It should be noted that different preset exception handling interfaces are further provided with preset handling rules for different exception types and exception levels.
Further, referring to fig. 3, the step S105 includes S302 to S306.
S302, obtaining an interface table entry corresponding to the preset exception handling interface, where the interface table entry is used to describe a precondition for invoking the preset exception handling interface, and the precondition includes preset exception type information and preset exception level information.
In the embodiment of the invention, interface table entries are respectively configured in a user-defined exception handling interface Handler or a default exception handling interface DefaultHandler in advance, and the mapping relation between the exception type and the exception level and the preset exception handling interface is established through the configuration interface table entries.
Table 1 is a sample of configuring the interface table entry.
TABLE 1
Interface serial number Preset exception type Presetting exception levels
Handler1 High CPU utilization rate 3
Handler2 Insufficient memory 5
S304, matching the identified exception type and exception grade with the precondition in the acquired interface table entry.
In this embodiment, different preset processing interfaces matched according to different exception types and exception grades are different, and when matching is performed, if the identified exception type and exception grade are in one-to-one correspondence with a precondition in the preset processing interface, the exception type and exception grade conform to the precondition in the interface entry, and it is described that the preset processing interface is successfully matched.
S306, if the exception type and the exception level accord with the precondition in the interface table entry, calling a corresponding preset exception handling interface to handle the exception.
In the embodiment of the invention, if the exception type and the exception level meet the precondition in the interface table entry, the successfully matched exception handling interface Handler or the default exception handling interface DefaultHandler is called to handle the exception.
In an embodiment, the invoking a preset exception handling interface according to the exception type and the exception level is specifically configured to: and calling a preset exception handling interface according to the exception type and the exception grade, and handling the exception through a preset handling rule corresponding to the preset exception handling interface.
In this embodiment, if the application exception is that the host volume is full, the preset processing rule is: identifying and deleting the temporary file and the log stored by the current host, or compressing the temporary file and the log stored by the current host to form a compressed file, and moving the compressed file to other hosts, wherein the other hosts can be standby hosts of the current host, or other cluster hosts in the same cluster space with the current host, and deleting the temporary file and the log stored on the current host; if the application exception is that the CPU utilization rate is higher than that of the preset processing rule, the preset processing rule is as follows: identifying an application with the highest CUP utilization rate, closing/restarting the identified application and connecting a terminal currently using the application to other hosts; if the application exception is thread blocking, the preset processing rule is as follows: and the current host does not receive the tasks any more, restarts the current host after the current task is processed, and distributes other tasks to other hosts.
As can be seen from the above, in the embodiment of the present invention, the log file corresponding to the application program is determined; if the application program is detected to throw the abnormity, the abnormity information corresponding to the abnormity of the application program is searched in the log file; acquiring abnormal keywords corresponding to the abnormal information by using a preset script; identifying an abnormal type and an abnormal grade according to the abnormal keyword; and calling a preset exception handling interface to handle exception according to the exception type and the exception grade. The embodiment of the invention can realize the capture of the abnormity and automatically process the captured abnormity.
Referring to fig. 4, in response to the above-mentioned exception handling method, an embodiment of the present invention further provides an exception handling apparatus, where the apparatus 100 includes: the device comprises a determination unit 101, a search unit 102, an acquisition unit 103, a recognition unit 104 and a processing unit 105.
The determining unit 101 is configured to determine a log file corresponding to an application program. In the embodiment of the present invention, the log file permanently records events in the application program operation aspect, each application program has an independent log file to record events occurring during the application program operation process, for example, application exceptions occurring in the application program (e.g., exceptions such as a host volume full, a CPU (Central Processing Unit) usage rate high, a thread blocking, a memory shortage, an I/O (Input/Output) read-write slow, and an application file missing) may find corresponding records from the log file of the application program, or the database program of the application program may also record database program operation errors in the log file. Specifically, the log file exists in a specified file format in the application program, for example, the log format, and in this embodiment, all log files in the log format in the application program can be viewed through a cmd command
The searching unit 102 is configured to search, if it is detected that the application program throws an exception, exception information corresponding to the exception of the application program in the log file. In the embodiment of the present invention, a code block thrown by an exception is set for a code position corresponding to an application program that may generate an exception, for example, a try-catch-final block is set for a code position corresponding to an application program that is prone to generate an exception to detect, where the try block includes a code statement that may generate an exception, the catch block is responsible for capturing the exception that occurs in the try block, and the final block is responsible for executing other user-defined execution statements (for example, sending the captured exception to a caller, etc.), where the exception that occurs in the try block may be multiple exceptions, and for multiple different exceptions, multiple catch blocks need to be set to capture to detect that the application program throws an exception. In this embodiment, because the log file records events occurring during the running process of the application program, when the application program throws an exception, exception information for the exception can be found from the log file corresponding to the application program, where the exception information includes running information of the application program and environment information such as CPU usage rate, thread occupancy information, memory occupancy rate, and the like.
An obtaining unit 103, configured to obtain an exception keyword corresponding to the exception information using a preset script. In this embodiment of the present invention, the preset script includes a shell script, and the obtaining unit 103 is specifically configured to: and acquiring abnormal keywords corresponding to the abnormal information by using a grep command of the shell script. For example, when the CPU utilization is high, the exception keyword obtained through the grep command in the shell script is "high CPU utilization"; when the memory is insufficient, the abnormal keyword acquired through the grep command in the shell script is 'out of memory' and the like.
And the identifying unit 104 is used for identifying the exception type and the exception grade according to the exception keyword. In the embodiment of the invention, the exception type and the exception level can be set, wherein the exception type comprises the types of the application program exception, the environment exception and the like, and the environment exception comprises the types of high CPU utilization rate, insufficient memory, thread blocking and the like. Furthermore, the anomalies can be classified into different levels in advance, for example, the anomaly of which the level 1 is the lowest level, such as the lowest alarm information of an application program; the grade 5 abnormality is the highest grade abnormality, such as a downtime alarm abnormality. Different exception information corresponds to different exception types and exception levels. For example, if a CPU abnormality is detected, the abnormality type is identified as high CPU utilization. And when the downtime alarm occurs, identifying that the abnormal grade is grade 5 abnormal and the like.
And the processing unit 105 is configured to invoke a preset exception handling interface to handle an exception according to the exception type and the exception level. In the embodiment of the present invention, an exception handling interface may be preset, and an interface table entry may be configured in the exception handling interface to establish a mapping relationship between the exception type and the exception level and the preset exception handling interface, that is, different preset exception handling interfaces correspond to different exception types and exception levels, and different preset exception handling interfaces are called to handle exceptions according to the identified exception type and exception level. The preset exception handling interface comprises an exception handling interface Handler customized by a programmer according to the requirement of the programmer and a default exception handling interface DefaultHandler for handling common exceptions.
In one embodiment, the processing unit 105 is specifically configured to: and calling a preset exception handling interface according to the exception type and the exception grade, and handling the exception through a preset handling rule corresponding to the preset exception handling interface.
It should be noted that different preset exception handling interfaces are further provided with preset handling rules for different exception types and exception levels.
As can be seen from the above, in the embodiment of the present invention, the log file corresponding to the application program is determined; if the application program is detected to throw the abnormity, searching abnormal information corresponding to the abnormity of the application program in the log file; acquiring abnormal keywords corresponding to the abnormal information by using a preset script; identifying an abnormal type and an abnormal grade according to the abnormal keyword; and calling a preset exception handling interface to handle exception according to the exception type and the exception grade. The embodiment of the invention can realize the capture of the abnormity and automatically process the captured abnormity.
Referring to fig. 5, the search unit 102 includes:
the recording unit 102a is configured to record, by using a flash collection system, timestamp information generated when the application throws the exception. In the embodiment of the invention, an event that an application throws an exception is monitored by a data collection component (such as an agent component) in a flash collection system, and timestamp information when the event occurs is collected; the timestamp information includes a time node when the application throws the exception, the time node corresponding to a system time on the application.
The searching subunit 102b is configured to locate the log file according to the timestamp information, and search for exception information corresponding to the exception of the application program. In the embodiment of the present invention, the time stamp information collected by the flume collection system when the exception occurs is used to locate the exception information in the log file, and specifically, the time information when the exception occurs is recorded in the log file, so that the collected time stamp information is compared with the time information when the exception occurs in the log file, so as to locate the exception information recorded in the log file, so as to obtain the corresponding exception information.
Referring to fig. 6, the processing unit 105 includes:
an obtaining unit 105a, configured to obtain an interface table entry corresponding to the preset exception handling interface, where the interface table entry is used to describe a precondition for invoking the preset exception handling interface, and the precondition includes preset exception type information and preset exception level information. In the embodiment of the invention, interface table entries are respectively configured in a user-defined exception handling interface Handler or a default exception handling interface DefaultHandler in advance, and the mapping relation between the exception type and the exception level and the preset exception handling interface is established through the configuration interface table entries.
A matching unit 105b, configured to match the identified exception type and exception level with the precondition in the obtained interface table entry. In this embodiment, different preset processing interfaces matched according to different exception types and exception grades are different, and when matching is performed, if the identified exception type and exception grade are in one-to-one correspondence with a precondition in the preset processing interface, the exception type and exception grade conform to the precondition in the interface entry, and it is described that the preset processing interface is successfully matched.
And the processing subunit 105c is configured to, if the exception type and the exception level meet the precondition in the interface entry, call a corresponding preset exception handling interface to handle the exception. In the embodiment of the invention, if the exception type and the exception level meet the precondition in the interface table entry, the exception handling interface Handler or the default exception handling interface DefaultHandler which is successfully matched is called to handle the exception.
The exception handling apparatus corresponds to the exception handling method one to one, and the specific principle and process thereof are the same as those of the method described in the above embodiment, and are not described again.
The above-described exception handling apparatus may be implemented in the form of a computer program which may be run on a computer device as shown in figure 7.
FIG. 7 is a schematic diagram of a computer device according to the present invention. The equipment can be a terminal or a server, wherein the terminal can be an electronic device with a communication function, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant and a wearable device. The server may be an independent server or a server cluster composed of a plurality of servers. Referring to fig. 7, the computer apparatus 500 includes a processor 502, a nonvolatile storage medium 503, an internal memory 504, and a network interface 505, which are connected by a system bus 501. The non-volatile storage medium 503 of the computer device 500 can store, among other things, an operating system 5031 and a computer program 5032 that, when executed, causes the processor 502 to perform an exception handling method. The processor 502 of the computer device 500 is used to provide computing and control capabilities that support the overall operation of the computer device 500. The internal memory 504 provides an environment for the execution of the computer program 5032 in the non-volatile storage medium 503, which when executed by the processor causes the processor 502 to perform an exception handling method. The network interface 505 of the computer device 500 is used for network communication such as sending assigned tasks and the like. Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
Wherein the processor 502 implements the following operations when executing the computer program:
determining a log file corresponding to an application program;
if the application program is detected to throw the abnormity, searching abnormal information corresponding to the abnormity of the application program in the log file;
acquiring abnormal keywords corresponding to the abnormal information by using a preset script;
identifying an abnormal type and an abnormal grade according to the abnormal keyword;
and calling a preset exception handling interface to handle exception according to the exception type and the exception level.
In an embodiment, the finding, in the log file, the abnormal information corresponding to the abnormality of the application program after the abnormality of the application program is detected includes:
recording timestamp information generated when the application throws an exception by using a flash collection system;
and positioning the log file according to the timestamp information and finding abnormal information corresponding to the abnormality of the application program.
In an embodiment, the preset script includes a shell script, and the obtaining of the abnormal keyword corresponding to the abnormal information by using the preset script includes:
and acquiring an abnormal keyword corresponding to the abnormal information by using a grep command of the shell script.
In one embodiment, the invoking a preset exception handling interface to handle the exception according to the exception type and the exception level includes:
acquiring an interface table entry corresponding to the preset exception handling interface, wherein the interface table entry is used for describing a precondition for calling the preset exception handling interface, and the precondition comprises preset exception type information and preset exception grade information;
matching the identified abnormal type and abnormal grade with the precondition in the acquired interface table entry;
and if the exception type and the exception level accord with the precondition in the interface table entry, calling a corresponding preset exception handling interface to handle the exception.
In one embodiment, said invoking a preset exception handling interface to handle the exception according to the exception type and the exception level includes:
and calling a preset exception handling interface according to the exception type and the exception grade, and handling the exception through a preset handling rule corresponding to the preset exception handling interface.
Those skilled in the art will appreciate that the embodiment of a computer device illustrated in fig. 7 does not constitute a limitation on the specific construction of the computer device, and that in other embodiments a computer device may include more or fewer components than those illustrated, or some components may be combined, or a different arrangement of components. For example, in some embodiments, the computer device only includes a memory and a processor, and in such embodiments, the structures and functions of the memory and the processor are the same as those of the embodiment shown in fig. 7, which are not described herein again.
The present invention provides a computer readable storage medium storing one or more computer programs, the one or more computer programs being executable by one or more processors to perform the steps of:
determining a log file corresponding to an application program;
if the application program is detected to throw the abnormity, searching abnormal information corresponding to the abnormity of the application program in the log file;
acquiring abnormal keywords corresponding to the abnormal information by using a preset script;
identifying an abnormal type and an abnormal grade according to the abnormal keyword;
and calling a preset exception handling interface to handle exception according to the exception type and the exception level.
In an embodiment, the finding, in the log file, the abnormal information corresponding to the abnormality of the application program after the abnormality of the application program is detected includes:
recording timestamp information generated when the application throws an exception by using a flash collection system;
and positioning the log file according to the timestamp information and finding abnormal information corresponding to the abnormality of the application program.
In an embodiment, the preset script includes a shell script, and the obtaining of the abnormal keyword corresponding to the abnormal information by using the preset script includes:
and acquiring abnormal keywords corresponding to the abnormal information by using a grep command of the shell script.
In one embodiment, the invoking a preset exception handling interface to handle the exception according to the exception type and the exception level includes:
acquiring an interface table entry corresponding to the preset exception handling interface, wherein the interface table entry is used for describing a precondition for calling the preset exception handling interface, and the precondition comprises preset exception type information and preset exception grade information;
matching the identified abnormal type and abnormal grade with the precondition in the acquired interface table entry;
if the exception type and the exception level accord with the precondition in the interface table entry, calling a corresponding preset exception handling interface to handle exception.
In one embodiment, the invoking a preset exception handling interface to handle the exception according to the exception type and the exception level includes:
and calling a preset exception handling interface according to the exception type and the exception grade, and handling the exception through a preset handling rule corresponding to the preset exception handling interface.
The foregoing storage medium of the present invention includes: various media that can store program codes, such as a magnetic disk, an optical disk, and a Read-Only Memory (ROM).
The elements of all embodiments of the present invention may be implemented by a general purpose Integrated Circuit, such as a CPU (Central Processing Unit), or by an ASIC (Application Specific Integrated Circuit).
The steps in the exception handling method of the embodiment of the invention can be sequentially adjusted, combined and deleted according to actual needs.
The units in the exception handling device of the embodiment of the invention can be merged, divided and deleted according to actual needs.
While the invention has been described with reference to specific embodiments, the invention is not limited thereto, and various equivalent modifications and substitutions can be easily made by those skilled in the art within the technical scope of the invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (5)

1. A method of exception handling, the method comprising:
determining a log file corresponding to an application program;
monitoring an abnormal event thrown by the application program through a data collection component in a flash collection system and collecting timestamp information when the abnormal event occurs, wherein the timestamp information comprises a time node when the abnormal event is thrown by the application program, and the time node corresponds to system time on the application program;
positioning the log file according to the timestamp information and finding abnormal information corresponding to the abnormality of the application program, wherein the timestamp information collected by the flash collection system when the abnormality occurs is used for positioning the abnormal information in the log file;
acquiring abnormal keywords corresponding to the abnormal information by using a grep command of the shell script;
identifying an abnormal type and an abnormal grade according to the abnormal keyword;
acquiring an interface table entry corresponding to a preset exception handling interface, wherein the interface table entry is used for describing a precondition for calling the preset exception handling interface, the precondition comprises preset exception type information and preset exception grade information, the interface table entry is configured in a self-defined exception handling interface Handler or a default exception handling interface DefaultHandler in advance, and a mapping relation between the exception type and the exception grade and the preset exception handling interface is established by configuring the interface table entry;
matching the identified abnormal type and abnormal grade with the precondition in the acquired interface table entry;
and if the exception type and the exception level accord with the precondition in the interface table entry, calling a corresponding preset exception handling interface to handle the exception.
2. The method of claim 1, wherein said invoking a pre-set exception handling interface to handle exceptions according to said exception type and exception level comprises:
and calling a preset exception handling interface according to the exception type and the exception grade, and handling the exception through a preset handling rule corresponding to the preset exception handling interface.
3. An exception handling apparatus, the apparatus comprising:
the determining unit is used for determining the log file corresponding to the application program;
the recording unit is used for monitoring an abnormal event thrown by the application program through a data collecting component in a flash collecting system and collecting timestamp information when the abnormal event occurs, wherein the timestamp information comprises a time node when the abnormal event is thrown by the application program, and the time node corresponds to system time on the application program;
the searching subunit is configured to locate the log file according to the timestamp information and search for abnormal information corresponding to the abnormality of the application program, where the timestamp information collected by the flash collection system when the abnormality occurs is used to locate the abnormal information in the log file;
the acquiring unit is used for acquiring the abnormal keyword corresponding to the abnormal information by using a grep command of the shell script;
the identification unit is used for identifying the abnormal type and the abnormal grade according to the abnormal keyword;
the device comprises an acquisition unit and a processing unit, wherein the acquisition unit is further used for acquiring an interface table entry corresponding to a preset exception handling interface, the interface table entry is used for describing a precondition for calling the preset exception handling interface, the precondition comprises preset exception type information and preset exception grade information, the interface table entry is configured in a self-defined exception handling interface Handler or a default exception handling interface Default Handler in advance, and a mapping relation between the exception type and the exception grade and the preset exception handling interface is established by configuring the interface table entry;
the matching unit is used for matching the identified exception type and exception grade with the acquired precondition in the interface table entry;
and the processing subunit is used for calling a corresponding preset exception handling interface to handle exception if the exception type and the exception level accord with the precondition in the interface table entry.
4. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the exception handling method according to any of claims 1-2 when executing the computer program.
5. A computer-readable storage medium, characterized in that the computer-readable storage medium stores one or more computer programs executable by one or more processors to implement the exception handling method of any one of claims 1-2.
CN201811021610.4A 2018-09-03 2018-09-03 Exception handling method, exception handling device, computer equipment and storage medium Active CN109240886B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811021610.4A CN109240886B (en) 2018-09-03 2018-09-03 Exception handling method, exception handling device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811021610.4A CN109240886B (en) 2018-09-03 2018-09-03 Exception handling method, exception handling device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109240886A CN109240886A (en) 2019-01-18
CN109240886B true CN109240886B (en) 2023-04-18

Family

ID=65060405

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811021610.4A Active CN109240886B (en) 2018-09-03 2018-09-03 Exception handling method, exception handling device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109240886B (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111597093B (en) * 2019-02-20 2024-04-16 阿里巴巴集团控股有限公司 Exception handling method, device and equipment thereof
CN111176874B (en) * 2019-12-23 2022-04-12 京东科技控股股份有限公司 Processing method, device and equipment for abnormal exit of application program and storage medium
CN113112316A (en) * 2019-12-24 2021-07-13 阿里巴巴集团控股有限公司 Exception handling method and device
CN111061644B (en) * 2019-12-25 2021-04-30 南京大学 Method and device for detecting and positioning abnormal throwing processing defects
CN111405546B (en) * 2020-03-03 2023-12-08 Oppo广东移动通信有限公司 Call abnormity processing method and device
CN113448827A (en) * 2020-03-26 2021-09-28 北京沃东天骏信息技术有限公司 Test data processing method and device
CN112416640A (en) * 2020-11-16 2021-02-26 武汉联影医疗科技有限公司 Exception handling method and device, computer equipment and storage medium
CN112685045A (en) * 2020-12-28 2021-04-20 北京达佳互联信息技术有限公司 Page source file processing method and device, electronic equipment and storage medium
CN113114510B (en) * 2021-04-22 2022-07-15 中国科学技术大学 Network fault information synchronization method and device
CN113422697B (en) * 2021-06-21 2023-03-24 深信服科技股份有限公司 Tracking method, device, electronic equipment and readable storage medium
CN113672574A (en) * 2021-07-12 2021-11-19 国网河北省电力有限公司营销服务中心 Log processing method, electronic device and computer-readable storage medium
CN113590373A (en) * 2021-08-10 2021-11-02 平安普惠企业管理有限公司 Processing method, device and equipment based on application version release and storage medium
CN113836004B (en) * 2021-08-30 2024-02-27 山东有人物联网股份有限公司 Application program positioning analysis method, device, equipment and storage medium
CN114401160B (en) * 2022-01-19 2022-12-02 腾讯科技(深圳)有限公司 Data processing method, device, server, terminal and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102385508A (en) * 2010-09-03 2012-03-21 金蝶软件(中国)有限公司 Exception handling method and device and software system
CN103377094A (en) * 2012-04-12 2013-10-30 金蝶软件(中国)有限公司 Abnormity monitoring method and abnormity monitoring device
CN106844139A (en) * 2016-12-19 2017-06-13 广州视源电子科技股份有限公司 A kind of log file analysis method and device
CN106911519A (en) * 2017-04-10 2017-06-30 北京搜狐新媒体信息技术有限公司 A kind of data acquisition monitoring method and device
CN108306879A (en) * 2018-01-30 2018-07-20 福建师范大学 The real-time abnormal localization method of distribution based on Web session streams

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102385508A (en) * 2010-09-03 2012-03-21 金蝶软件(中国)有限公司 Exception handling method and device and software system
CN103377094A (en) * 2012-04-12 2013-10-30 金蝶软件(中国)有限公司 Abnormity monitoring method and abnormity monitoring device
CN106844139A (en) * 2016-12-19 2017-06-13 广州视源电子科技股份有限公司 A kind of log file analysis method and device
CN106911519A (en) * 2017-04-10 2017-06-30 北京搜狐新媒体信息技术有限公司 A kind of data acquisition monitoring method and device
CN108306879A (en) * 2018-01-30 2018-07-20 福建师范大学 The real-time abnormal localization method of distribution based on Web session streams

Also Published As

Publication number Publication date
CN109240886A (en) 2019-01-18

Similar Documents

Publication Publication Date Title
CN109240886B (en) Exception handling method, exception handling device, computer equipment and storage medium
US7913233B2 (en) Performance analyzer
CN107800757B (en) User behavior recording method and device
CN104156275A (en) Method and device for exception handling of Android platform
CN109885453B (en) Big data platform monitoring system based on stream data processing
CN109726091B (en) Log management method and related device
CN107357731A (en) Process produces monitoring, analysis and the processing method of core dump problems
CN109460307B (en) Micro-service calling tracking method and system based on log embedded point
CN110647472A (en) Breakdown information statistical method and device, computer equipment and storage medium
CN111367760A (en) Log collection method and device, computer equipment and storage medium
CN113485999A (en) Data cleaning method and device and server
CN110941530A (en) Method and device for acquiring monitoring data, computer equipment and storage medium
US9916220B2 (en) Smart logging of trace data for storage systems
CN111061802A (en) Power data management processing method and device and storage medium
CN109992476A (en) A kind of analysis method of log, server and storage medium
CN110727565B (en) Network equipment platform information collection method and system
CN112241362A (en) Test method, test device, server and storage medium
CN114500249B (en) Root cause positioning method and device
CN115510035A (en) Log data processing method, device, equipment and storage medium
CN112685370B (en) Log collection method, device, equipment and medium
CN112650613B (en) Error information processing method and device, electronic equipment and storage medium
KR102256894B1 (en) Method, Server and Computer Program for Crash Report Grouping
CN115237669A (en) Data backup method, data recovery method, data backup device, data recovery device and electronic equipment
CN105391602A (en) Data acquisition test method and device
CN111611142A (en) Information collection method, device and storage medium

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
GR01 Patent grant
GR01 Patent grant