CN107908555B - SQL script abnormity detection method and terminal thereof - Google Patents

SQL script abnormity detection method and terminal thereof Download PDF

Info

Publication number
CN107908555B
CN107908555B CN201711085996.0A CN201711085996A CN107908555B CN 107908555 B CN107908555 B CN 107908555B CN 201711085996 A CN201711085996 A CN 201711085996A CN 107908555 B CN107908555 B CN 107908555B
Authority
CN
China
Prior art keywords
sql
script
consumption
sql script
consumption characteristic
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
CN201711085996.0A
Other languages
Chinese (zh)
Other versions
CN107908555A (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 Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China 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 Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201711085996.0A priority Critical patent/CN107908555B/en
Publication of CN107908555A publication Critical patent/CN107908555A/en
Application granted granted Critical
Publication of CN107908555B publication Critical patent/CN107908555B/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/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention is suitable for the technical field of data processing, and provides an abnormality detection method of an SQL script and a terminal thereof, wherein the abnormality detection method comprises the following steps: acquiring first consumption characteristic values of a target SQL script corresponding to a plurality of preset time nodes, and generating a historical consumption characteristic curve; if a coordinate point with a first consumption characteristic value larger than a preset consumption threshold value exists, determining the duration time of the first consumption characteristic value larger than the preset consumption threshold value; if the duration is greater than a preset jump time threshold, acquiring derivative values corresponding to the coordinate points in the duration; and if the derivative value corresponding to the coordinate point is larger than a preset derivative threshold value, judging that the target SQL script is an abnormal script. The invention solves the problems that the existing abnormal detection technology of the SQL script needs an administrator to manually analyze the SQL language, the detection efficiency is lower, and the maintenance cost is improved because the administrator has higher technical level.

Description

SQL script abnormity detection method and terminal thereof
Technical Field
The invention belongs to the technical field of data processing, and particularly relates to an abnormality detection method of an SQL script and a terminal thereof.
Background
The SQL script is widely applied to the field of network services, so the operation efficiency of the SQL script determines the reaction rate of the service request, and if the SQL script is abnormal in operation, the service request initiated by the user needs a long time to be processed and the request is accumulated. Therefore, how to quickly detect the abnormal condition of the SQL script is very important. The existing SQL script abnormity detection technology needs an administrator to perform manual analysis on an SQL language, the detection efficiency is low, and the technology level is high depending on the administrator, so that the maintenance cost is increased.
Disclosure of Invention
In view of this, embodiments of the present invention provide an abnormality detection method for an SQL script and a terminal thereof, so as to solve the problems that an administrator needs to perform manual analysis on an SQL language in the existing abnormality detection technology for the SQL script, the detection efficiency is low, and the administrator has a high technical level, so that the maintenance cost is increased.
A first aspect of an embodiment of the present invention provides an abnormality detection method for an SQL script, where the abnormality detection method for the SQL script includes:
acquiring running state parameters of each SQL script;
calculating a first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script; the first consumption characteristic value is used for representing the occupation condition of the SQL script on the equipment resource;
sequencing the first consumption characteristic values corresponding to the SQL scripts from large to small, selecting the SQL scripts corresponding to the first N first consumption characteristic values, and generating a script consumption exception list; wherein N is a positive integer less than the number of SQL scripts;
according to a received target script selection instruction, determining a target SQL script from the script consumption exception list;
acquiring first consumption characteristic values of the target SQL script corresponding to a plurality of preset time nodes, and generating a historical consumption characteristic curve;
if a coordinate point with the first consumption characteristic value larger than a preset consumption threshold value exists in the historical consumption characteristic curve, determining the duration time of the first consumption characteristic value larger than the preset consumption threshold value based on the historical consumption characteristic curve;
if the duration is greater than a preset jump time threshold, acquiring derivative values corresponding to all coordinate points in the duration;
and if the derivative value corresponding to the coordinate point is larger than a preset derivative threshold value, judging that the target SQL script is an abnormal script.
A second aspect of the embodiments of the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the following steps when executing the computer program:
acquiring running state parameters of each SQL script;
calculating a first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script; the first consumption characteristic value is used for representing the occupation condition of the SQL script on the equipment resource;
sequencing the first consumption characteristic values corresponding to the SQL scripts from large to small, selecting the SQL scripts corresponding to the first N first consumption characteristic values, and generating a script consumption exception list; wherein N is a positive integer less than the number of SQL scripts;
according to a received target script selection instruction, determining a target SQL script from the script consumption exception list;
acquiring first consumption characteristic values of the target SQL script corresponding to a plurality of preset time nodes, and generating a historical consumption characteristic curve;
if a coordinate point with the first consumption characteristic value larger than a preset consumption threshold value exists in the historical consumption characteristic curve, determining the duration time of the first consumption characteristic value larger than the preset consumption threshold value based on the historical consumption characteristic curve;
if the duration is greater than a preset jump time threshold, acquiring derivative values corresponding to all coordinate points in the duration;
and if the derivative value corresponding to one coordinate point is larger than a preset derivative threshold, judging that the target SQL script is an abnormal script.
A third aspect of embodiments of the present invention provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of:
acquiring running state parameters of each SQL script;
calculating a first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script; the first consumption characteristic value is used for representing the occupation condition of the SQL script on the equipment resource;
sequencing the first consumption characteristic values corresponding to the SQL scripts from large to small, selecting the SQL scripts corresponding to the first N first consumption characteristic values, and generating a script consumption exception list; wherein N is a positive integer less than the number of SQL scripts;
according to a received target script selection instruction, determining a target SQL script from the script consumption exception list;
acquiring first consumption characteristic values of the target SQL script corresponding to a plurality of preset time nodes, and generating a historical consumption characteristic curve;
if a coordinate point with the first consumption characteristic value larger than a preset consumption threshold value exists in the historical consumption characteristic curve, determining the duration time of the first consumption characteristic value larger than the preset consumption threshold value based on the historical consumption characteristic curve;
if the duration is greater than a preset jump time threshold, acquiring derivative values corresponding to all coordinate points in the duration;
and if the derivative value corresponding to one coordinate point is larger than a preset derivative threshold, judging that the target SQL script is an abnormal script.
The method for detecting the abnormality of the SQL script and the terminal thereof have the following beneficial effects that:
the method comprises the steps of obtaining an operation state parameter of an SQL script, determining the consumption condition of the SQL script in a preset time period through the operation state parameter to obtain a first consumption characteristic value, then selecting N SQL scripts with the largest consumption by a terminal device, further determining whether the SQL script has an abnormal condition, generating a script consumption abnormal list by the terminal device according to the N SQL scripts with the larger consumption, extracting the SQL script corresponding to a received target script selection instruction from the script abnormal consumption list to serve as a target SQL script, further obtaining the historical consumption condition corresponding to the target SQL script, generating a historical consumption characteristic curve, identifying whether the historical consumption characteristic curve reflects the abnormal condition of the target SQL script through a relevant judgment threshold value, and if so, identifying the script as the abnormal script. Compared with the existing SQL script abnormality detection method, the method and the device do not need an administrator of the database to manually check the abnormal conditions of the SQL script, the terminal device automatically generates a script abnormality consumption list with high abnormality probability, the detection range of the administrator is reduced, the detection result of whether the SQL script is abnormal or not is output according to the target SQL script selected by the administrator, the user does not need to identify the abnormality, and the accuracy and the response rate of abnormality detection are greatly improved. On the other hand, the process of the abnormity detection is mainly completed through the terminal equipment, so that the requirement on the technical level of an administrator is low, and the maintenance cost of the database is reduced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only 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 inventive exercise.
Fig. 1 is a flowchart illustrating an implementation of an abnormality detection method for an SQL script according to a first embodiment of the present invention;
fig. 2 is a flowchart of a specific implementation of an abnormality detection method for an SQL script according to a second embodiment of the present invention;
fig. 3 is a flowchart of a specific implementation of the method S101 for detecting an abnormality of an SQL script according to a third embodiment of the present invention;
fig. 4 is a flowchart illustrating a specific implementation of the method S102 for detecting an abnormality of an SQL script according to a fourth embodiment of the present invention;
fig. 5 is a flowchart illustrating a specific implementation of the method S103 for detecting an exception of an SQL script according to a fifth embodiment of the present invention;
fig. 6 is a block diagram of an abnormality detection terminal for an SQL script according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the invention obtains a first consumption characteristic value by obtaining the running state parameter of the SQL script and determining the consumption condition of the SQL script in a preset time period by the running state parameter, then the terminal device selects N SQL scripts with the largest consumption, and further determines whether the SQL script has abnormal conditions, so that the terminal device generates a script consumption abnormal list according to the N SQL scripts with larger consumption, extracts the SQL script corresponding to the received target script selection instruction from the script abnormal consumption list as the target SQL script, further obtains the historical consumption condition corresponding to the target SQL script, generates a historical consumption characteristic curve, and identifies whether the historical consumption characteristic curve reflects the abnormal condition of the target SQL script by a relevant judgment threshold value, if so, identifies the script as the abnormal script, thereby solving the abnormal detection technology of the existing SQL script, the method has the advantages that the manager is required to perform manual analysis on the SQL language, the detection efficiency is low, and the manager is depended to have a high technical level, so that the maintenance cost is increased.
In the embodiment of the present invention, the execution subject of the process is an abnormality detection terminal of the SQL script, the terminal device includes a mobile phone, a computer device, a tablet computer, a server, and other terminals, and particularly, the terminal device is a detection terminal of the SQL script placed in a database system, and the abnormality detection operation is executed by obtaining the operation condition of each SQL script in the database. Fig. 1 shows a flowchart of an implementation of the method for detecting an exception of an SQL script according to the first embodiment of the present invention, which is detailed as follows:
in S101, the running state parameters of each SQL script are acquired.
In the present embodiment, the trigger conditions for anomaly detection include two modes, manual trigger and automatic trigger. Wherein, the manual trigger specifically is: the administrator generates an abnormality detection starting instruction on the terminal device, or sends an abnormality detection starting instruction to the terminal device through the user terminal, and if the terminal device receives the abnormality detection starting instruction, the terminal device executes the relevant operation of S101. The automatic triggering specifically comprises: and the terminal equipment is provided with an abnormality detection starting time, and if the terminal equipment detects that the current state is matched with the preset abnormality detection starting time, the related operation of S101 is executed.
Optionally, in this implementation, the time for starting the anomaly detection may be a preset detection period, and when the terminal device monitors that the current time meets the detection period, the terminal device executes the relevant operation of S101. The abnormal detection starting time may also be an operation consumption threshold, for example, a resource occupancy rate, and if the terminal device monitors that the operation consumption value of the terminal to be detected at the current time is greater than or equal to the preset operation consumption threshold, the relevant operation of S101 is executed. Because the consumption of the equipment is overlarge, generally caused by the abnormality of the SQL script, the unnecessary detection process can be reduced by using the consumption running condition as the trigger condition compared with the periodic trigger mode, and the resource utilization rate of the equipment is improved.
In this embodiment, the SQL script may run in a database of the terminal device, and in this case, the terminal device to be detected is the terminal device provided in the embodiment of the present invention, that is, whether each SQL script in the local database has an abnormal condition is detected; the SQL script may also be run in another database server besides the terminal device, in which case, the terminal device is an independent detection terminal to monitor whether the SQL script in the database server is abnormal. Particularly, the terminal device can also detect a database system, wherein the database system comprises a plurality of database servers, and each database server extracts a corresponding SQL script from the same SQL script resource library to perform query operation. The SQL script resource library is stored with a plurality of SQL scripts and used for meeting the query requirements of different users, for example, if the users need to query data related to quarter bonus, the query is carried out by calling a first SQL script; and if the user needs to count the continuous guarantee condition of the car insurance client, the user queries by calling a second SQL script.
In this embodiment, when receiving a detection instruction of a user or meeting a corresponding detection trigger condition, a terminal device respectively obtains an operation state parameter of each SQL script, and in particular, the operation state parameter of the SQL script includes a plurality of parameter items, each parameter item corresponds to one parameter value, and different operation characteristics are respectively represented. The operation state parameters of the SQL script include, but are not limited to: an operation resource occupation parameter, an average running time parameter, a content occupation parameter and calling times. The running resource occupation parameter is specifically an operation resource that needs to be consumed by executing one query flow when the SQL script is called, and optionally, the running resource occupation parameter may be represented by an average number of occupied CPUs.
In S102, calculating a first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script; and the first consumption characteristic value is used for expressing the occupation condition of the SQL script on the equipment resource.
In this embodiment, after acquiring the running state parameters of each SQL script, the terminal device acquires the consumption condition of the SQL script according to each running state parameter, so that a plurality of parameter values included in the running state parameters corresponding to the SQL script are imported into a preset consumption feature conversion model, so as to calculate a first consumption feature value corresponding to the SQL script through the running state parameters, and represent the consumption condition of the SQL script through the first consumption feature value.
Optionally, in this embodiment, the consumption characteristic conversion model may be a hash function, and the terminal device inputs the operating state parameter of the SQL script into the hash function, and then obtains a corresponding first consumption characteristic value according to a parameter range in which each parameter value is located.
Optionally, in this embodiment, the first consumption characteristic value is specifically a consumption level. In this case, the terminal device obtains the average running state parameter of the SQL script in addition to the running state parameter of the current SQL script of the user, compares the current running state parameter with the average running state parameter, and determines the current consumption level. The consumption levels include, but are not limited to: the SQL script consumption state can be intuitively known by the terminal equipment through displaying the consumption level, and the information acquisition efficiency of the user is improved.
In S103, sequencing the first consumption characteristic values corresponding to the SQL scripts from big to small, selecting the SQL scripts corresponding to the first N first consumption characteristic values, and generating a script consumption exception list; and N is a positive integer less than the number of SQL scripts.
In this embodiment, after calculating the first consumption characteristic values corresponding to the respective SQL scripts, the terminal device sorts the first consumption characteristic values according to their magnitudes, where a larger value of the first consumption characteristic value indicates that the resource occupies more and the consumption is larger, and a smaller value of the first consumption characteristic value indicates that the resource occupies less and the consumption is smaller, and particularly, a longer running time corresponding to the SQL script with a larger first consumption characteristic value is. Therefore, after the sequencing, the terminal device obtains an SQL resource consumption sequence, and intercepts N SQL scripts with larger values from the sequence according to a preset N value, that is, the SQL scripts corresponding to the first N first consumption feature values, generates a script consumption exception list, and displays the script consumption exception list through a display module, or directly sends the script consumption list to a user terminal corresponding to a database administrator.
In this embodiment, the value of N may be set according to the requirement of the user, and may be determined according to the number of SQL scripts included in the system. For example, 10% of SQL scripts are extracted from the SQL script resource library to generate an abnormal consumption list, and the terminal device first obtains the number of scripts included in the SQL script resource and calculates the N value according to a preset proportional value. In particular, the N value may be configured according to different current monitoring times. For busy time, fine SQL script exception detection may be required, and the N value is large; for the idle time, the idle resources of the system are large, so that the rough SQL script abnormality detection can be carried out, and the N value is small.
In this embodiment, if there are a plurality of SQL scripts whose first consumption feature values are the same, and therefore the number M of selected SQL scripts is greater than the preset N value, in this case, the terminal device may generate a script consumption exception list from the M SQL scripts, where the list includes M SQL scripts with larger consumption features; the terminal equipment can also select N SQL scripts from the M SQL scripts according to the detection mode set by the user. Specifically, because the operating state parameters in different SQL scripts include a plurality of parameter items, the N SQL scripts can be determined by sorting the values of the parameter items. For example, the N value is 3, and there are 2 SQL scripts with the third largest consumption value, so the number of the selected SQL scripts is 4, the first SQL script with the third largest size, the second SQL script with the second largest size, and the two parallel SQL scripts with the third largest size. At this time, the terminal device acquires that the current detection mode is the running time priority mode, selects an SQL script with a larger value as the abnormally consumed SQL script according to the running time value of the running state parameter in the two parallel third largest SQL scripts, and generates a script consumption abnormal list with the first two SQL scripts.
In S104, according to the received target script selection instruction, determining a target SQL script from the script consumption exception list.
In this embodiment, a user may view the script consumption exception list through a display module of the terminal device, and select one or more SQL scripts from the list as target SQL scripts, where the target SQL scripts are specifically scripts that are predicted to be exception scripts but need to be further detected and confirmed. Of course, the terminal device may also select a target SQL script from the script abnormal consumption list through a preset script selection algorithm, or may sequentially check all SQL scripts in the script abnormal consumption list one by one. Specifically, the preset script selection algorithm may be: determining the variance of each SQL script in the script consumption exception list according to the historical consumption characteristic value of each SQL script, then calculating the difference value between the first consumption characteristic value obtained this time and the historical consumption characteristic value of the script, comparing the difference value with the variance, and if the difference value is less than or equal to the variance, proving that the first consumption characteristic value at this time is in a normal floating range and identifying the first consumption characteristic value as a non-target SQL script; otherwise, if the difference is greater than the variance, the target SQL script is identified.
In this embodiment, after receiving a target script selection instruction, the terminal device obtains a script identifier included in the target script selection instruction, matches the script identifier with script identifiers of each SQL script in the script consumption exception list, determines an SQL script corresponding to the selection instruction, and identifies the SQL script as a target SQL script.
In this embodiment, the script identifier may be a file name, a script number, and a serial number in a list of the SQL script, or a position coordinate triggered when the user selects the target SQL script from the script consumption exception list on the touch module of the terminal device.
In S105, first consumption feature values of the target SQL script corresponding to a plurality of preset time nodes are obtained, and a historical consumption feature curve is generated.
In this embodiment, the terminal device records the historical operating conditions of each SQL script. The terminal equipment acquires the running state parameters of each SQL script at preset time intervals and stores the running state parameters in the historical running records corresponding to each SQL script. When a user needs to acquire the historical operating condition of the SQL script, the change condition of the corresponding operating state parameter can be determined by directly acquiring the historical operating record.
In this embodiment, the terminal device obtains the running state parameters corresponding to each preset time node according to the pre-stored historical running record of the SQL script, and converts the running state parameters into the first consumption characteristic value, so as to obtain the historical consumption record of the first consumption characteristic value corresponding to the SQL script. In particular, the preset time node may be a preset parameter acquisition period, that is, a time point corresponding to each preset time interval.
In this embodiment, the terminal device generates a coordinate axis by using the first consumption characteristic value as a vertical coordinate and the time point as a horizontal coordinate, draws a historical consumption characteristic curve according to the first consumption characteristic value corresponding to each time node, and outputs the historical consumption characteristic curve through the display module, so that the user can view the historical consumption characteristic curve conveniently.
Optionally, the terminal device may generate a characteristic curve corresponding to different operation state parameters according to each operation state parameter, in addition to the historical consumption characteristic curve related to the first consumption characteristic value. For example, if the operating state parameter includes an average operating time, the terminal device may generate a historical operating time characteristic corresponding to the average operating time. And then the terminal equipment can determine whether the target SQL script is an abnormal script or not through a curve discrimination algorithm corresponding to the running state parameter.
In S106, it is determined whether a coordinate point in the historical consumption characteristic curve where the first consumption characteristic value is greater than a preset consumption threshold exists.
In S107, if there is a coordinate point in the historical consumption characteristic curve where the first consumption characteristic value is greater than a preset consumption threshold, a duration that the first consumption characteristic value is greater than the preset consumption threshold is determined based on the historical consumption characteristic curve.
In this embodiment, the terminal device first determines whether a coordinate point in the historical consumption characteristic curve exists, where the first consumption characteristic value is greater than a preset consumption threshold value. If the coordinate point exists in the historical consumption characteristic curve, it indicates that the consumption of the target SQL script exceeds the normal consumption range, and it needs to determine whether the abnormal situation is jitter caused by external factors such as network environment, or is caused by the abnormality of the target SQL script, that is, it needs to further determine, and execute the relevant operation of S108; on the contrary, if the first consumption characteristic value corresponding to any coordinate point in the historical consumption characteristic curve is smaller than the preset consumption threshold value, the target SQL script is always in a normal working state, and therefore the SQL script is identified as a normal SQL script.
In this embodiment, the preset consumption threshold may be set by the user, and may be a default value of the system. Preferably, the preset consumption threshold is related to an average consumption value of the target SQL script. Specifically, the terminal device first obtains a first consumption characteristic value of the target SQL script obtained at each detection point, obtains an average consumption value, and obtains the consumption threshold value through a preset weighting coefficient and the average consumption value. Through the mode, the consumption threshold is subjected to iterative calculation through the historical first consumption characteristic value, so that the dynamic adjustment of the consumption threshold is realized, and the accuracy of the abnormal detection is improved.
In S108, it is determined whether the duration is greater than a preset transition time threshold.
In S109, if the duration is greater than a preset transition time threshold, a derivative value corresponding to each coordinate point in the duration is obtained.
In this embodiment, after determining that the target SQL script has a coordinate point with abnormal consumption, the terminal device detects the duration of the abnormal consumption, and determines whether the abnormal consumption is jump jitter. Therefore, the duration of the historical consumption characteristic curve in which the first consumption characteristic value is greater than the preset consumption threshold value is obtained, and the duration is compared with the preset jump time threshold value. If the duration is less than or equal to the jump time threshold, the consumption abnormity belongs to jump jitter, and is not caused by the abnormity of the target SQL script, and the script abnormity is generally a process of continuous consumption abnormity; if the duration is greater than the transition time threshold, the consumption anomaly is a continuous consumption anomaly process, and therefore the next threshold determination is performed.
In this embodiment, the duration specifically refers to a duration that the first consumption threshold of the continuous coordinate point is greater than the duration corresponding to the preset consumption threshold, and if two discontinuous curves exist in the historical consumption curve and the first consumption value of the coordinate point is greater than the consumption threshold, the durations corresponding to the two curves are respectively calculated, that is, the first duration and the second duration are obtained. And the first duration and the second duration are respectively judged with a jump time threshold. Therefore, if the historical consumption characteristic curve corresponds to a plurality of durations, and any duration is greater than the preset transition time threshold, the relevant operation of S110 is performed.
In S110, it is determined whether a derivative value corresponding to one of the coordinate points is greater than a preset derivative threshold.
In S111, if there is a derivative value corresponding to one coordinate point that is greater than a preset derivative threshold, it is determined that the target SQL script is an abnormal script.
In this embodiment, the terminal device obtains the derivative value corresponding to each coordinate point in the duration, and determines whether the first consumption characteristic value changes slowly or suddenly because the derivative value can represent the consumption change speed of the target SQL script. If the derivative value is smaller, it indicates that the consumption of the target SQL file is slowly rising or slowly falling, and it may be caused by calling the terminal device corresponding to the target SQL file in a full load state or heating hardware, which results in gradually increasing consumption, but not caused by abnormality of the target SQL file; if the derivative value is larger, it indicates that the consumption condition of the target SQL file is sharply ascending or sharply descending, and the larger occurrence of the condition may be caused by the SQL file being changed from a normal state to an abnormal state due to a sudden change. Therefore, if the derivative value of a coordinate point in the duration is greater than the preset derivative threshold, the SQL script is represented as an abnormal script; on the contrary, if the derivative value of any coordinate point does not exist in the curve corresponding to the duration of the target SQL script and is greater than the preset derivative threshold, it indicates that the target SQL script is a normal script.
Specifically, if the first consumption value of the multi-segment discontinuous curve existing in S109 is greater than the preset consumption threshold, only the curve having the duration greater than the preset transition time is selected to perform the correlation operation of S110.
It can be seen from the above that, in the method for detecting an abnormality of an SQL script according to the embodiments of the present invention, the running state parameter of the SQL script is obtained, the running state parameter determines the consumption of the SQL script in a preset time period to obtain a first consumption characteristic value, then the terminal device selects the N SQL scripts with the largest consumption to further determine whether the SQL script has an abnormal condition, so that the terminal device generates a script consumption abnormal list according to the N SQL scripts with the largest consumption, extracts the SQL script corresponding to the received target script selection instruction from the script abnormal consumption list as the target SQL script, further obtains the historical consumption corresponding to the target SQL script, generates a historical consumption characteristic curve, and identifies whether the historical consumption characteristic curve reflects the abnormal condition of the target SQL script by the relevant determination threshold value, if yes, the script is identified as an abnormal script. Compared with the existing SQL script abnormality detection method, the method and the device do not need an administrator of the database to manually check the abnormal conditions of the SQL script, the terminal device automatically generates a script abnormality consumption list with high abnormality probability, the detection range of the administrator is reduced, the detection result of whether the SQL script is abnormal or not is output according to the target SQL script selected by the administrator, the user does not need to identify the abnormality, and the accuracy and the response rate of abnormality detection are greatly improved. On the other hand, the process of the abnormity detection is mainly completed through the terminal equipment, so that the requirement on the technical level of an administrator is low, and the maintenance cost of the database is reduced.
Fig. 2 is a flowchart illustrating a specific implementation of an abnormality detection method for an SQL script according to a second embodiment of the present invention. Referring to fig. 2, with respect to the embodiment shown in fig. 1, the method for detecting an abnormality of an SQL script provided in this embodiment further includes S201 and S202, which are detailed as follows:
further, after the determining that the target SQL script is an abnormal script if the derivative value corresponding to the coordinate point is greater than a preset derivative threshold value, the method further includes:
in S201, a version change file of the target SQL script within the duration is obtained.
In this embodiment, after determining that the target SQL script is an abnormal script, the terminal device needs to repair the abnormal situation. For the SQL script, the cause of the exception of the script is generally that after the content of the script is changed, there is a processing logic conflict with the version of the database or other applications, so that the script cannot run normally.
In this embodiment, the terminal device detects that the SQL script is abnormally consumed within the duration, that is, it indicates that the version of the target SQL script is changed in the time period, so that the database may be abnormally consumed when the changed SQL script is called. Therefore, the terminal device will acquire the version change file corresponding to the target SQL script within the duration. It should be noted that the number of the version change files may be one, that is, only one version change occurs in the duration, or at least two, that is, multiple version changes occur in the duration. The version change file may include a plurality of changed contents, that is, a user may adjust or optimize a plurality of contents in the SQL script by making a version change once.
Optionally, in this embodiment, if there is no corresponding version change file within the duration, at this time, the terminal device may obtain the version change file corresponding to the target SQL script within a preset time interval before the duration. When the terminal device determines that the version change file does not exist within the duration, it may be that the version change occurs before the duration, and therefore, the terminal device shifts forward a preset time interval with the duration as a reference to acquire whether the version change file of the target SQL script exists within the time interval, and if so, acquires the version change file and executes the operation of S202.
In S202, the changed content of the version change file is successively restored in the reverse order of the creation time of the version change file, and the current running state parameter of the target SQL script is monitored until the first consumption characteristic value corresponding to the current running state parameter is less than or equal to the consumption threshold.
In this embodiment, when acquiring the version change file, the terminal device needs to gradually repair the change content included in the version change file, and the restoring process is a reverse process corresponding to the change process, so that the change content in the version change file needs to be restored one by one in sequence according to the reverse order of the creation time of the version change file, so as to keep the rationality of the file processing logic in the restoring process.
In this embodiment, after each time a change content is restored, the terminal device obtains an operating state parameter of the restored target SQL file within a preset time, and calculates a corresponding first consumption characteristic value according to the operating state parameter, if the first consumption characteristic value is less than or equal to a preset consumption threshold, it indicates that the abnormal condition is successfully repaired, and terminates the related operation of S202; otherwise, if the first consumption characteristic value is still larger than the preset consumption threshold value, the next modified content is restored, and the operation is repeatedly executed.
In this embodiment, if the consumption characteristic value of the target SQL file is still at a higher level after the restoration operation is performed on the changed content of the plurality of changed files, at this time, the terminal device may generate a manual repair support instruction to be pushed to the processing account corresponding to the database system, so that the processing account performs exception repair on the target SQL script.
In the embodiment of the invention, the terminal equipment restores the abnormal SQL script by restoring the changed content in the target SQL script, thereby realizing automatic abnormality detection and automatic abnormality restoration, and improving the processing efficiency and the response speed of the abnormality.
Fig. 3 is a flowchart illustrating a specific implementation of the method S101 for detecting an abnormality of an SQL script according to a third embodiment of the present invention. Referring to fig. 3, with respect to the embodiment shown in fig. 1, S101 in the method for detecting an abnormality of an SQL script provided in this embodiment includes S301 to S303, which are detailed as follows:
further, the acquiring the running state parameters of each SQL script includes:
in S301, it is monitored whether the current time meets a preset anomaly detection trigger time.
Before acquiring each SQL script, the terminal device needs to determine the trigger time, and in this embodiment, the terminal device adopts a detection trigger mode combining time trigger and consumption trigger. Firstly, the terminal device acquires whether the monitored current time is matched with a preset abnormal detection trigger time, and particularly, the abnormal detection trigger time is a periodic trigger time and also can be a plurality of time points preset by a user. When the terminal device determines that the current time matches the abnormality detection trigger time, the relevant operation of S302 is executed, otherwise, the terminal device remains in the standby state to reduce the consumption of the electric quantity.
In S302, if the current time meets a preset abnormal detection trigger time, the current resource occupancy rate of the terminal to be detected is obtained.
In this embodiment, when the terminal device learns that the current time matches the anomaly detection trigger time, the current resource occupancy rate of the terminal to be detected is obtained. The terminal to be detected specifically comprises: and calling the terminal of each SQL script. If the terminal device of this embodiment is integrated in a database server and the database server calls each SQL script, in this case, the terminal to be detected is the terminal device provided in this embodiment; and if the terminal equipment is an independent detection terminal, the terminal to be detected is the database server for calling each SQL script.
In this embodiment, the terminal device obtains the current resource occupancy rate of the terminal to be detected, and if the terminal to be detected is a single terminal, that is, if the database servers calling the SQL scripts are all the same server, the resource occupancy rate of the terminal can be directly used as the resource occupancy rate corresponding to the terminal to be detected; and if the terminal to be detected is a database system consisting of a plurality of database servers, the resource occupancy rate is the resource occupancy rate of the whole database system. Particularly, if the terminal device is integrated in the database server, the local resource occupancy rate of the terminal device is obtained.
In this embodiment, the terminal device sets an occupancy rate threshold, and when the obtained resource occupancy rate is greater than the occupancy rate threshold, it indicates that there may be an SQL script exception, and executes the operation of S303; on the contrary, if the acquired resource occupancy rate is less than or equal to the occupancy rate threshold, it indicates that the current SQL script is in a substantially normal state and does not reach the level at which exception handling is required, so the process returns to S301 to wait for the arrival of the next detection occasion. Optionally, in this embodiment, the occupancy threshold may change according to the passage of time, for example, the idle period, the number of times of calling the SQL script, and the number of the idle periods are small, so the corresponding occupancy threshold may be low, and the full-scale period, the number of times of calling the SQL script, and the number of the full-scale periods are large, so the corresponding occupancy threshold may be high.
In S303, it is determined whether the resource occupancy is greater than a preset occupancy threshold.
In S304, if the resource occupancy is greater than a preset occupancy threshold, the running state parameter of each SQL script is acquired.
In this embodiment, when detecting that the resource occupancy is greater than the preset occupancy threshold, the terminal device determines that an abnormal script may exist in the current SQL script, and thus will execute an operation of abnormal detection.
In the embodiment of the invention, the abnormal detection time and the occupancy rate threshold are set, so that the abnormal detection operation is automatically executed when the abnormal condition possibly exists, the unnecessary detection process is avoided, and the resource utilization rate of the terminal is improved.
Fig. 4 is a flowchart illustrating a specific implementation of the method S102 for detecting an abnormality of an SQL script according to a fourth embodiment of the present invention. Referring to fig. 4, with respect to the embodiment shown in fig. 1 to 3, in the method for detecting an abnormality of an SQL script provided in this embodiment, calculating a first consumption characteristic value and a first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script includes S401 and S402, which are detailed as follows:
further, the operating state parameters include: calculating a resource occupation parameter, an average running time parameter, a memory occupation parameter and running times; the calculating the first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script comprises the following steps:
in S401, a weight value corresponding to each of the operating state parameters is determined.
In this embodiment, the operation state parameters of each SQL script obtained by the terminal device include multiple types of parameters, which are respectively an operation resource occupation parameter, an average operation time parameter, a memory occupation parameter, and an operation frequency, and the weight values corresponding to different operation state parameters are different, so that the terminal device first needs to determine the weight value corresponding to each operation state parameter and generate a consumption feature conversion model corresponding to the weight value according to the weight value.
Optionally, in this embodiment, the terminal device may adjust the weight value corresponding to each operating state parameter according to the current detection mode. For example, if the current detection mode is the run-time priority mode, the weight value corresponding to the average run-time parameter is larger, and the weight values of other run-time parameters are appropriately adjusted; if the current detection mode is the memory priority mode, the weight value corresponding to the memory occupation parameter is larger, so that the first consumption characteristic value can more effectively represent the consumption condition of the corresponding detection mode.
In S402, importing the operation resource occupation parameter, the average operation time parameter, the memory occupation parameter, and the operation times corresponding to each SQL script into a consumption characteristic value conversion model, and respectively calculating a first consumption characteristic value corresponding to each SQL script, where the consumption characteristic value conversion model specifically includes:
Ex=α1Ct(SQL)+α2T(SQL)+α3Buff(SQL)+α4Q(SQL)
wherein Ex is the first consumption characteristic value of SQL script, alpha1、α2、α3And alpha4The weighted value corresponding to each operating state parameter, ct (SQL) is an operating resource occupation parameter of the SQL script, t (SQL) is an average operating time parameter of the SQL script, buf (SQL) is a memory occupation parameter of the SQL script, and q (SQL) is the operating frequency of the SQL script.
In this embodiment, the terminal device imports the parameter values corresponding to the plurality of operating state parameters obtained in S101 into corresponding positions in the consumption characteristic conversion model, and calculates the corresponding first consumption characteristic values through the operating state parameters by using the consumption characteristic value conversion model.
In the embodiment of the invention, the obtained multiple running state parameters are led into the preset consumption characteristic conversion model, so that the conversion from the running state parameters to the first consumption characteristic value is realized, and the calculation efficiency of the first consumption characteristic value is improved.
Fig. 5 shows a flowchart of a specific implementation of the method S103 for detecting an exception of an SQL script according to the fifth embodiment of the present invention. Referring to fig. 5, with respect to the embodiment shown in fig. 1, the method S103 for detecting an abnormality of an SQL script provided in this embodiment includes the following steps, which are detailed as follows:
further, the selecting the N SQL scripts with the largest first consumption feature value and generating the script consumption exception list includes:
in S501, a time point of the current time is acquired.
In this embodiment, the terminal device may further compare and display second consumption characteristic values corresponding to current time points on different dates, in addition to acquiring and displaying the first consumption characteristic value corresponding to the current time, so that a user may determine whether the first consumption characteristic value is abnormal consumption according to the first consumption characteristic value and the second consumption characteristic value.
In this embodiment, the time point is specifically a time value, such as 16:30, and is represented as a detection time of 16 points 30 on the day. Of course, the terminal device may represent the time point in other forms, such as 4:30pm, etc., which is not limited herein.
In S502, second consumption feature values corresponding to the time points of the N SQL scripts on different dates are extracted.
In this embodiment, the terminal device obtains first consumption characteristic values corresponding to the time point on different dates, and calculates an average consumption characteristic value based on the plurality of first consumption characteristic values as a second consumption characteristic value, which is used to represent a normal consumption situation of the database server when calling the SQL script at the time point. The number of days selected may be set by the user or may be a default value of the system.
For example, if the current time is 16:30 of 8 months and 10 days, the terminal device may obtain the consumption feature values of the SQL script corresponding to each 16:30 days from 8 months and 1 day to 8 months and 9 days, and calculate the second consumption feature value according to the standard feature value.
In S503, the consumption floating levels of the N SQL scripts are respectively calculated according to the first consumption characteristic values and the second consumption characteristic values of the N SQL scripts.
In this embodiment, the terminal device calculates the consumption floating levels corresponding to the SQL scripts according to the first consumption characteristic values of the SQL scripts and the second consumption characteristic values corresponding to the first consumption characteristic values, so as to obtain the consumption floating levels of the N SQL scripts, and determines whether the current first consumption characteristic values are within a reasonable floating range, thereby facilitating a user to determine whether the SQL scripts are abnormal SQL scripts. Optionally, the floating level is calculated by: and calculating a ratio between the first consumption characteristic value and the second characteristic value, and identifying the ratio as the consumption floating level of the SQL script.
In S504, the script consumption exception list is generated according to the consumption float level and the first consumption feature value.
In this embodiment, the terminal device generates a script consumption exception list according to the floating level of each SQL script and the corresponding first consumption characteristic value, where each first consumption characteristic value and the consumption floating level thereof are located in the same consumption exception record, and perform comparison display. Table 1 shows a consumption exception list provided by the present embodiment. It can be seen that the SQL script with the script name wazd _ saqs exceeds 900% of the average consumption, and it is very likely that the script is in an abnormal state, and further abnormality determination can be performed.
Serial number SQL script name First consumption characteristic value Grade of float
1 wazsd_saqs 42 900%
2 kuwaq_wqs_1 38 250%
3 qlewwa_wakw_a 34 52%
4 swqas_wqq1 34 98%
5 pkeusz_q 28 73%
6 ijwazw_x 15 120%
7 awnal_254_wqa 9 20%
TABLE 1
In the embodiment of the invention, the first consumption value and the floating grade are compared and displayed, so that a user can conveniently and quickly judge whether the SQL script is in a normal floating range, and the efficiency of anomaly detection is improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Fig. 6 is a block diagram illustrating a structure of an abnormality detection terminal of an SQL script according to an embodiment of the present invention, where the abnormality detection terminal of the SQL script includes units for executing steps in the embodiment corresponding to fig. 1. Please refer to fig. 1 and fig. 1 for the corresponding description of the embodiment. For convenience of explanation, only the portions related to the present embodiment are shown.
Referring to fig. 6, the abnormality detection terminal of the SQL script includes:
an operation status parameter obtaining unit 61, configured to obtain an operation status parameter of each SQL script;
a first consumption value calculating unit 62, configured to calculate, according to the running state parameter of each SQL script, a first consumption characteristic value corresponding to each SQL script; the first consumption characteristic value is used for representing the occupation condition of the SQL script on the equipment resource;
the consumption exception list generating unit 63 is configured to sort the first consumption feature values corresponding to each SQL script from large to small, select the SQL scripts corresponding to the first N first consumption feature values, and generate a script consumption exception list; wherein N is a positive integer less than the number of SQL scripts;
a target SQL script determining unit 64, configured to determine a target SQL script from the script consumption exception list according to the received target script selecting instruction;
a historical consumption characteristic curve generating unit 65, configured to obtain first consumption characteristic values of the target SQL script corresponding to a plurality of preset time nodes, and generate a historical consumption characteristic curve;
a duration obtaining unit 66, configured to determine, based on the historical consumption characteristic curve, a duration that the first consumption characteristic value is greater than a preset consumption threshold if a coordinate point exists in the historical consumption characteristic curve, where the first consumption characteristic value is greater than the preset consumption threshold;
a curve derivative obtaining unit 67, configured to obtain a derivative value corresponding to each coordinate point in the duration if the duration is greater than a preset jump time threshold;
and an abnormal script determining unit 68, configured to determine that the target SQL script is an abnormal script if there is a derivative value corresponding to one of the coordinate points that is greater than a preset derivative threshold.
Optionally, the abnormality detection terminal for the SQL script further includes:
a version change file acquiring unit, configured to acquire a version change file of the target SQL script within the duration;
and the change content restoration unit is used for gradually restoring the change content of the version change file according to the reverse order of the creation time of the version change file and monitoring the current running state parameter of the target SQL script until the first consumption characteristic value corresponding to the current running state parameter is less than or equal to the consumption threshold value.
Optionally, the operation state parameter obtaining unit 61 includes:
the trigger time monitoring unit is used for monitoring whether the current time meets a preset abnormal detection trigger time;
the resource occupancy rate acquiring unit is used for acquiring the current resource occupancy rate of the terminal to be detected if the current time meets the preset abnormal detection trigger time;
and the detection starting judgment unit is used for acquiring the running state parameters of each SQL script if the resource occupancy rate is greater than a preset occupancy rate threshold value.
Optionally, the operating state parameters include: calculating a resource occupation parameter, an average running time parameter, a memory occupation parameter and running times; the first consumption value calculation unit 62 includes:
the operation parameter weight determining unit is used for determining a weight value corresponding to each operation state parameter;
a consumption characteristic value conversion model importing unit, configured to import the operation resource occupation parameter, the average operation time parameter, the memory occupation parameter, and the operation times corresponding to each SQL script into a consumption characteristic value conversion model, and respectively calculate a first consumption characteristic value corresponding to each SQL script, where the consumption characteristic value conversion model specifically includes:
Ex=α1Ct(SQL)+α2T(SQL)+α3Buff(SQL)+α4Q(SQL)
wherein Ex is the first consumption characteristic value of SQL script, alpha1、α2、α3And alpha4The weighted value corresponding to each operating state parameter, ct (SQL) is an operating resource occupation parameter of the SQL script, t (SQL) is an average operating time parameter of the SQL script, buf (SQL) is a memory occupation parameter of the SQL script, and q (SQL) is the operating frequency of the SQL script.
Optionally, the script consuming exception list generating 63 includes:
a current time obtaining unit, configured to obtain a time point of a current time;
a second consumption characteristic value acquisition unit, configured to extract second consumption characteristic values corresponding to the time points of the N SQL scripts on different dates;
a consumption floating level obtaining unit, configured to calculate consumption floating levels of the N SQL scripts according to the first consumption characteristic values and the second consumption characteristic values of the N SQL scripts, respectively;
and the script consumption exception list packaging unit is used for generating the script consumption exception list according to the consumption floating grade and the first consumption characteristic value.
Therefore, the abnormality detection terminal for the SQL script provided in the embodiment of the present invention can also obtain the first consumption characteristic value by obtaining the running state parameter of the SQL script, and determining the consumption condition of the SQL script in the preset time period by the running state parameter, and then the terminal device selects the N SQL scripts with the largest consumption, and further determines whether the SQL script has an abnormal condition, so that the terminal device generates a script consumption abnormal list according to the N SQL scripts with larger consumption, and extracts the SQL script corresponding to the received target script selection instruction from the script abnormal consumption list as the target SQL script, and further obtains the historical consumption condition corresponding to the target SQL script, generates a historical consumption characteristic curve, and identifies whether the historical consumption characteristic curve reflects the abnormal condition of the target SQL script by the relevant determination threshold value, if yes, the script is identified as an abnormal script. Compared with the existing SQL script abnormality detection method, the method and the device do not need an administrator of the database to manually check the abnormal conditions of the SQL script, the terminal device automatically generates a script abnormality consumption list with high abnormality probability, the detection range of the administrator is reduced, the detection result of whether the SQL script is abnormal or not is output according to the target SQL script selected by the administrator, the user does not need to identify the abnormality, and the accuracy and the response rate of abnormality detection are greatly improved. On the other hand, the process of the abnormity detection is mainly completed through the terminal equipment, so that the requirement on the technical level of an administrator is low, and the maintenance cost of the database is reduced.
Fig. 7 is a schematic diagram of a terminal device according to another embodiment of the present invention. As shown in fig. 7, the terminal device 7 of this embodiment includes: a processor 70, a memory 71, and a computer program 72, such as an SQL script exception detection program, stored in the memory 71 and executable on the processor 70. The processor 70, when executing the computer program 72, implements the steps in the above-described embodiments of the abnormality detection method for each SQL script, such as S101 to S108 shown in fig. 1. Alternatively, the processor 70, when executing the computer program 72, implements the functions of the units in the above-described device embodiments, such as the functions of the modules 61 to 68 shown in fig. 6.
Illustratively, the computer program 72 may be divided into one or more units, which are stored in the memory 71 and executed by the processor 70 to accomplish the present invention. The one or more units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 72 in the terminal device 7. For example, the computer program 72 may be divided into an operating state parameter acquiring unit, a first consumption value calculating unit, a consumption abnormality list generating unit, a target SQL script determining unit, a historical consumption characteristic curve generating unit, a duration acquiring unit, a curve derivative acquiring unit, and an abnormality script determining unit, and each unit specifically functions as follows:
the operation state parameter acquisition unit is used for acquiring the operation state parameters of each SQL script;
the first consumption value calculating unit is used for calculating a first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script; the first consumption characteristic value is used for representing the occupation condition of the SQL script on the equipment resource;
the consumption exception list generating unit is used for sequencing the first consumption characteristic values corresponding to the SQL scripts from large to small, selecting N SQL scripts with the maximum first consumption characteristic values corresponding to the first N first consumption characteristic values, and generating a script consumption exception list; wherein N is a positive integer less than the number of SQL scripts;
the target SQL script determining unit is used for determining a target SQL script from the script consumption exception list according to a received target script selecting instruction;
the historical consumption characteristic curve generating unit is used for acquiring first consumption characteristic values of the target SQL script corresponding to a plurality of preset time nodes and generating a historical consumption characteristic curve;
a duration time obtaining unit, configured to determine, based on the historical consumption characteristic curve, a duration time for which the first consumption characteristic value is greater than a preset consumption threshold value if a coordinate point for which the first consumption characteristic value is greater than the preset consumption threshold value exists in the historical consumption characteristic curve;
the curve derivative acquisition unit is used for acquiring a derivative value corresponding to each coordinate point in the duration if the duration is greater than a preset jump time threshold;
and the abnormal script judging unit is used for judging that the target SQL script is an abnormal script if a derivative value corresponding to one coordinate point is larger than a preset derivative threshold.
The terminal device 7 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is merely an example of a terminal device 7 and does not constitute a limitation of the terminal device 7 and may comprise more or less components than shown, or some components may be combined, or different components, for example the terminal device may further comprise input output devices, network access devices, buses, etc.
The Processor 70 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or a memory of the terminal device 7. The memory 71 may also be an external storage device of the terminal device 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal device 7. The memory 71 is used for storing the computer program and other programs and data required by the terminal device. The memory 71 may also be used to temporarily store data that has been output or is to be output.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. . Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. An abnormality detection method for an SQL script is characterized by comprising the following steps:
acquiring running state parameters of each SQL script;
calculating a first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script; the first consumption characteristic value is used for representing the occupation condition of the SQL script on the equipment resource;
sequencing the first consumption characteristic values corresponding to the SQL scripts from large to small, selecting the SQL scripts corresponding to the first N first consumption characteristic values, and generating a script consumption exception list; wherein N is a positive integer less than the number of SQL scripts;
according to a received target script selection instruction, determining a target SQL script from the script consumption exception list;
acquiring first consumption characteristic values of the target SQL script corresponding to a plurality of preset time nodes, and generating a historical consumption characteristic curve;
if a coordinate point with the first consumption characteristic value larger than a preset consumption threshold value exists in the historical consumption characteristic curve, determining the duration time of the first consumption characteristic value larger than the preset consumption threshold value based on the historical consumption characteristic curve;
if the duration is greater than a preset jump time threshold, acquiring derivative values corresponding to all coordinate points in the duration;
and if the derivative value corresponding to one coordinate point is larger than a preset derivative threshold, judging that the target SQL script is an abnormal script.
2. The method according to claim 1, wherein after determining that the target SQL script is an abnormal script if the derivative value corresponding to one of the coordinate points is greater than a preset derivative threshold, the method further comprises:
acquiring a version change file of the target SQL script within the duration;
and gradually reducing the change content of the version change file according to the reverse order of the creation time of the version change file, and monitoring the current running state parameter of the target SQL script until the first consumption characteristic value corresponding to the current running state parameter is less than or equal to the consumption threshold value.
3. The anomaly detection method according to claim 1, wherein said obtaining the running state parameters of each SQL script comprises:
monitoring whether the current time meets a preset abnormal detection trigger time;
if the current time meets a preset abnormal detection trigger time, acquiring the current resource occupancy rate of the terminal to be detected;
and if the resource occupancy rate is greater than a preset occupancy rate threshold value, acquiring the running state parameters of each SQL script.
4. The abnormality detection method according to any one of claims 1-3, characterized in that the operating state parameters include: calculating a resource occupation parameter, an average running time parameter, a memory occupation parameter and running times;
the calculating the first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script comprises the following steps:
determining a weight value corresponding to each running state parameter;
importing the operation resource occupation parameter, the average operation time parameter, the memory occupation parameter and the operation times corresponding to each SQL script into a consumption characteristic value conversion model, and respectively calculating a first consumption characteristic value corresponding to each SQL script, where the consumption characteristic value conversion model specifically includes:
Ex=α1Ct(SQL)+α2T(SQL)+α3Buff(SQL)+α4Q(SQL)
wherein Ex is the first consumption characteristic value of SQL script, alpha1、α2、α3And alpha4The weighted value corresponding to each operating state parameter, ct (SQL) is an operating resource occupation parameter of the SQL script, t (SQL) is an average operating time parameter of the SQL script, buf (SQL) is a memory occupation parameter of the SQL script, and q (SQL) is the operating frequency of the SQL script.
5. The anomaly detection method according to claim 1, wherein the selecting the SQL scripts corresponding to the first N first consumption feature values to generate a script consumption anomaly list comprises:
acquiring a time point of the current moment;
extracting second consumption characteristic values corresponding to the time points of the N SQL scripts on different dates;
respectively calculating the consumption floating levels of the N SQL scripts according to the first consumption characteristic values and the second consumption characteristic values of the N SQL scripts;
and generating a script consumption exception list according to the consumption floating grade and the first consumption characteristic value.
6. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
acquiring running state parameters of each SQL script;
calculating a first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script; the first consumption characteristic value is used for representing the occupation condition of the SQL script on the equipment resource;
sequencing the first consumption characteristic values corresponding to the SQL scripts from large to small, selecting the SQL scripts corresponding to the first N first consumption characteristic values, and generating a script consumption exception list; wherein N is a positive integer less than the number of SQL scripts;
according to a received target script selection instruction, determining a target SQL script from the script consumption exception list;
acquiring first consumption characteristic values of the target SQL script corresponding to a plurality of preset time nodes, and generating a historical consumption characteristic curve;
if a coordinate point with the first consumption characteristic value larger than a preset consumption threshold value exists in the historical consumption characteristic curve, determining the duration time of the first consumption characteristic value larger than the preset consumption threshold value based on the historical consumption characteristic curve;
if the duration is greater than a preset jump time threshold, acquiring derivative values corresponding to all coordinate points in the duration;
and if the derivative value corresponding to one coordinate point is larger than a preset derivative threshold, judging that the target SQL script is an abnormal script.
7. The terminal device according to claim 6, wherein after determining that the target SQL script is an abnormal script if the derivative value corresponding to one of the coordinate points is greater than a preset derivative threshold, the processor executes the computer program to further implement the following steps:
acquiring a version change file of the target SQL script within the duration;
and gradually reducing the change content of the version change file according to the reverse order of the creation time of the version change file, and monitoring the current running state parameter of the target SQL script until the first consumption characteristic value corresponding to the current running state parameter is less than or equal to the consumption threshold value.
8. The terminal device according to claim 6, wherein the obtaining the running state parameters of each SQL script comprises:
monitoring whether the current time meets a preset abnormal detection trigger time;
if the current time meets a preset abnormal detection trigger time, acquiring the current resource occupancy rate of the terminal to be detected;
and if the resource occupancy rate is greater than a preset occupancy rate threshold value, acquiring the running state parameters of each SQL script.
9. The terminal device according to any of claims 6-8, wherein the operating state parameters comprise: calculating a resource occupation parameter, an average running time parameter, a memory occupation parameter and running times;
the calculating the first consumption characteristic value corresponding to each SQL script according to the running state parameter of each SQL script comprises the following steps:
determining a weight value corresponding to each running state parameter;
importing the operation resource occupation parameter, the average operation time parameter, the memory occupation parameter and the operation times corresponding to each SQL script into a consumption characteristic value conversion model, and respectively calculating a first consumption characteristic value corresponding to each SQL script, where the consumption characteristic value conversion model specifically includes:
Ex=α1Ct(SQL)+α2T(SQL)+α3Buff(SQL)+α4Q(SQL)
wherein Ex is the first consumption characteristic value of SQL script, alpha1、α2、α3And alpha4The weighted value corresponding to each operating state parameter, ct (SQL) is an operating resource occupation parameter of the SQL script, t (SQL) is an average operating time parameter of the SQL script, buf (SQL) is a memory occupation parameter of the SQL script, and q (SQL) is the operating frequency of the SQL script.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 5.
CN201711085996.0A 2017-11-07 2017-11-07 SQL script abnormity detection method and terminal thereof Active CN107908555B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711085996.0A CN107908555B (en) 2017-11-07 2017-11-07 SQL script abnormity detection method and terminal thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711085996.0A CN107908555B (en) 2017-11-07 2017-11-07 SQL script abnormity detection method and terminal thereof

Publications (2)

Publication Number Publication Date
CN107908555A CN107908555A (en) 2018-04-13
CN107908555B true CN107908555B (en) 2020-01-14

Family

ID=61842820

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711085996.0A Active CN107908555B (en) 2017-11-07 2017-11-07 SQL script abnormity detection method and terminal thereof

Country Status (1)

Country Link
CN (1) CN107908555B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109726364B (en) * 2018-07-06 2023-01-10 平安科技(深圳)有限公司 Power consumption abnormity detection method, device, terminal and computer readable storage medium
CN113407404A (en) * 2020-03-16 2021-09-17 菜鸟智能物流控股有限公司 Data processing method and device, electronic equipment and computer readable storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104715018A (en) * 2015-02-04 2015-06-17 同程网络科技股份有限公司 Intelligent SQL injection resistant method based on semantic analysis
CN105391729A (en) * 2015-11-30 2016-03-09 中国航天科工集团第二研究院七〇六所 Web loophole automatic mining method based on fuzzy test

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104012041B (en) * 2011-05-24 2018-02-09 思杰系统有限公司 system and method for analyzing network index

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104715018A (en) * 2015-02-04 2015-06-17 同程网络科技股份有限公司 Intelligent SQL injection resistant method based on semantic analysis
CN105391729A (en) * 2015-11-30 2016-03-09 中国航天科工集团第二研究院七〇六所 Web loophole automatic mining method based on fuzzy test

Also Published As

Publication number Publication date
CN107908555A (en) 2018-04-13

Similar Documents

Publication Publication Date Title
CN109800204B (en) Data distribution method and related product
CN106648747B (en) Process preloading processing method and device
WO2020093637A1 (en) Device state prediction method and system, computer apparatus and storage medium
CN107908555B (en) SQL script abnormity detection method and terminal thereof
CN109309735B (en) Connection processing method, server, system and storage medium
CN113051308A (en) Alarm information processing method, equipment, storage medium and device
CN111400126A (en) Network service abnormal data detection method, device, equipment and medium
CN112749013A (en) Thread load detection method and device, electronic equipment and storage medium
CN108255710B (en) Script abnormity detection method and terminal thereof
CN107797924B (en) SQL script abnormity detection method and terminal thereof
CN105471938B (en) Server load management method and device
CN109800085B (en) Resource configuration detection method and device, storage medium and electronic equipment
CN109885384B (en) Task parallelism optimization method and device, computer equipment and storage medium
CN107168643B (en) Data storage method and device
CN111159131A (en) Performance optimization method, device, equipment and computer readable storage medium
CN107357703B (en) Terminal application power consumption detection method and server
CN112948223A (en) Method and device for monitoring operation condition
CN114697247B (en) Fault detection method, device, equipment and storage medium of streaming media system
KR102464688B1 (en) Method and apparatus for detrmining event level of monitoring result
CN110865877A (en) Task request response method and device
CN114168439A (en) Pressure measurement control method and device for service in cluster, storage medium and terminal
CN112581150A (en) Information management method, device, equipment and storage medium
CN113961603B (en) Large-screen data display method and device, electronic equipment and storage medium
CN113688929B (en) Prediction model determining method, apparatus, electronic device and computer storage medium
CN110875981B (en) Electronic red packet processing method, electronic red packet processing device and mobile terminal

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