[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN107908555A - A kind of method for detecting abnormality and its terminal of SQL scripts - Google Patents

A kind of method for detecting abnormality and its terminal of SQL scripts Download PDF

Info

Publication number
CN107908555A
CN107908555A CN201711085996.0A CN201711085996A CN107908555A CN 107908555 A CN107908555 A CN 107908555A CN 201711085996 A CN201711085996 A CN 201711085996A CN 107908555 A CN107908555 A CN 107908555A
Authority
CN
China
Prior art keywords
sql
sql scripts
consumption
scripts
value
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.)
Granted
Application number
CN201711085996.0A
Other languages
Chinese (zh)
Other versions
CN107908555B (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

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)
  • Debugging And Monitoring (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention is suitable for technical field of data processing, there is provided a kind of method for detecting abnormality and its terminal of SQL scripts, including:Obtain target SQL scripts and consume characteristic value in multiple default timing nodes corresponding first, and generate history characteristic curve of consumption;If there are the coordinate points that the first consumption characteristic value is more than default threshold value, it is determined that the duration that the first consumption characteristic value is more than;If the duration is more than default bound-time threshold value, the corresponding derivative value of each coordinate points in the duration is obtained;If there are the corresponding derivative value of the coordinate points to be more than default derivative threshold, judge that target SQL scripts are abnormal script.The present invention solves the abnormality detection technology of existing SQL scripts, it is necessary to which administrator carries out manual analysis to SQL language, and detection efficiency is relatively low, and relies on administrator and have higher technical merit, so that the problem of improving the cost of maintenance.

Description

A kind of method for detecting abnormality and its terminal of SQL scripts
Technical field
The invention belongs to technical field of data processing, more particularly to a kind of method for detecting abnormality and its terminal of SQL scripts.
Background technology
SQL scripts are widely used in network service field, therefore the height of SQL script operational efficiency decides that service please The reaction rate asked, if the operation of SQL scripts is abnormal, will cause at Client-initiated service request needs the long period Reason and the situation of request stacking.Therefore, how the abnormal conditions of SQL scripts are used for quickly detecting and be particularly important.And For the abnormality detection technology of existing SQL scripts, it is necessary to which administrator carries out manual analysis to SQL language, detection efficiency is relatively low, and Relying on administrator has higher technical merit, so as to improve the cost of maintenance.
The content of the invention
In view of this, it is existing to solve an embodiment of the present invention provides a kind of method for detecting abnormality and its terminal of SQL scripts For the abnormality detection technology of some SQL scripts, it is necessary to which administrator carries out manual analysis to SQL language, detection efficiency is relatively low, and according to Rely administrator that there is higher technical merit, so that the problem of improving the cost of maintenance.
The first aspect of the embodiment of the present invention provides a kind of method for detecting abnormality of SQL scripts, the SQL scripts it is different Normal detection method includes:
Obtain the running state parameter of each SQL scripts;
According to the running state parameter of each SQL scripts, it is special to calculate corresponding first consumption of each SQL scripts Value indicative;Wherein, the first consumption characteristic value is used to represent occupancy situation of the SQL scripts to device resource;
By the corresponding first consumption characteristic value of each SQL scripts by being ranked up from big to small, and choose top n the The corresponding SQL scripts of one consumption characteristic value, generation script consumption exception list;Wherein, the N is less than SQL script numbers Positive integer;
Instruction is chosen according to the target script received, is consumed from the script and target SQL scripts is determined in exception list;
Obtain the target SQL scripts and consume characteristic value in multiple default timing nodes corresponding first, and generate and go through History characteristic curve of consumption;
If there are the seat that the described first consumption characteristic value is more than default threshold value in the history characteristic curve of consumption Punctuate, then based on the history characteristic curve of consumption, determine that the first consumption characteristic value is more than holding for default threshold value The continuous time;
If the duration is more than default bound-time threshold value, each coordinate points pair in the duration are obtained The derivative value answered;
If there are the corresponding derivative value of the coordinate points to be more than default derivative threshold, the target SQL feet are judged This is abnormal script.
The second aspect of the embodiment of the present invention provides a kind of terminal device, including memory, processor and is stored in In the memory and the computer program that can run on the processor, when the processor performs the computer program Realize following steps:
Obtain the running state parameter of each SQL scripts;
According to the running state parameter of each SQL scripts, it is special to calculate corresponding first consumption of each SQL scripts Value indicative;Wherein, the first consumption characteristic value is used to represent occupancy situation of the SQL scripts to device resource;
By the corresponding first consumption characteristic value of each SQL scripts by being ranked up from big to small, and choose top n the The corresponding SQL scripts of one consumption characteristic value, generation script consumption exception list;Wherein, the N is less than SQL script numbers Positive integer;
Instruction is chosen according to the target script received, is consumed from the script and target SQL scripts is determined in exception list;
Obtain the target SQL scripts and consume characteristic value in multiple default timing nodes corresponding first, and generate and go through History characteristic curve of consumption;
If there are the seat that the described first consumption characteristic value is more than default threshold value in the history characteristic curve of consumption Punctuate, then based on the history characteristic curve of consumption, determine that the first consumption characteristic value is more than holding for default threshold value The continuous time;
If the duration is more than default bound-time threshold value, each coordinate points pair in the duration are obtained The derivative value answered;
If there are the corresponding derivative value of the coordinate points to be more than default derivative threshold, the target SQL is judged Script is abnormal script.
The third aspect of the embodiment of the present invention provides a kind of computer-readable recording medium, the computer-readable storage Media storage has computer program, and the computer program realizes following steps when being executed by processor:
Obtain the running state parameter of each SQL scripts;
According to the running state parameter of each SQL scripts, it is special to calculate corresponding first consumption of each SQL scripts Value indicative;Wherein, the first consumption characteristic value is used to represent occupancy situation of the SQL scripts to device resource;
By the corresponding first consumption characteristic value of each SQL scripts by being ranked up from big to small, and choose top n the The corresponding SQL scripts of one consumption characteristic value, generation script consumption exception list;Wherein, the N is less than SQL script numbers Positive integer;
Instruction is chosen according to the target script received, is consumed from the script and target SQL scripts is determined in exception list;
Obtain the target SQL scripts and consume characteristic value in multiple default timing nodes corresponding first, and generate and go through History characteristic curve of consumption;
If there are the seat that the described first consumption characteristic value is more than default threshold value in the history characteristic curve of consumption Punctuate, then based on the history characteristic curve of consumption, determine that the first consumption characteristic value is more than holding for default threshold value The continuous time;
If the duration is more than default bound-time threshold value, each coordinate points pair in the duration are obtained The derivative value answered;
If there are the corresponding derivative value of the coordinate points to be more than default derivative threshold, the target SQL is judged Script is abnormal script.
Implementing a kind of method for detecting abnormality of SQL scripts provided in an embodiment of the present invention and its terminal has below beneficial to effect Fruit:
The embodiment of the present invention determines this by obtaining the running state parameter of SQL scripts by the running state parameter Expenditure Levels of the SQL scripts within the default period, obtain the first consumption characteristic value, and then it is maximum to choose consumption for terminal device N number of SQL scripts, further determine that above-mentioned SQL scripts whether there is abnormal conditions, thus terminal device will be larger according to consuming N number of SQL scripts generation script consumption exception list, and extracted from script abnormal consumption list receive target script choosing The corresponding SQL scripts of instruction fetch obtain the corresponding history Expenditure Levels of target SQL scripts as target SQL scripts, raw Into history characteristic curve of consumption, and by relevant decision threshold, identify whether the history characteristic curve of consumption reflects the mesh SQL scripts are marked there are abnormal conditions, if so, then identifying that the script is abnormal script.With the abnormality detection side of existing SQL scripts Method is compared, and the embodiment of the present invention investigates the abnormal conditions of SQL scripts without the administrator of database manually, terminal device Automatically generate one and there is the larger script abnormal consumption list of abnormal probability, reduce the detection range of administrator, and according to The target SQL scripts of the selection of administrator, the whether abnormal testing result of output, carries out anomalous identification without user, carries significantly The high accuracy rate and the speed of response of abnormality detection.On the other hand, since the process of abnormality detection mainly passes through terminal device Complete, the technical merit requirement for administrator is relatively low, so as to also reduce the maintenance cost of database.
Brief description of the drawings
To describe the technical solutions in the embodiments of the present invention more clearly, below will be to embodiment or description of the prior art Needed in attached drawing be briefly described, it should be apparent that, drawings in the following description be only the present invention some Embodiment, for those of ordinary skill in the art, without having to pay creative labor, can also be according to these Attached drawing obtains other attached drawings.
Fig. 1 is that a kind of method for detecting abnormality for the SQL scripts that first embodiment of the invention provides realizes flow chart;
Fig. 2 is a kind of specific implementation flow chart of the method for detecting abnormality for SQL scripts that second embodiment of the invention provides;
Fig. 3 is the specific implementation stream of the method for detecting abnormality S101 for SQL scripts that third embodiment of the invention provides a kind of Cheng Tu;
Fig. 4 is the specific implementation stream of the method for detecting abnormality S102 for SQL scripts that fourth embodiment of the invention provides a kind of Cheng Tu;
Fig. 5 is the specific implementation stream of the method for detecting abnormality S103 for SQL scripts that fifth embodiment of the invention provides a kind of Cheng Tu;
Fig. 6 is a kind of structure diagram of the abnormality detection terminal for SQL scripts that one embodiment of the invention provides;
Fig. 7 is a kind of schematic diagram for terminal device that one embodiment of the invention provides.
Embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, with reference to the accompanying drawings and embodiments, it is right The present invention is further elaborated.It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, and It is not used in the restriction present invention.
The embodiment of the present invention determines this by obtaining the running state parameter of SQL scripts by the running state parameter Expenditure Levels of the SQL scripts within the default period, obtain the first consumption characteristic value, and then it is maximum to choose consumption for terminal device N number of SQL scripts, further determine that above-mentioned SQL scripts whether there is abnormal conditions, thus terminal device will be larger according to consuming N number of SQL scripts generation script consumption exception list, and extracted from script abnormal consumption list receive target script choosing The corresponding SQL scripts of instruction fetch obtain the corresponding history Expenditure Levels of target SQL scripts as target SQL scripts, raw Into history characteristic curve of consumption, and by relevant decision threshold, identify whether the history characteristic curve of consumption reflects the mesh SQL scripts are marked there are abnormal conditions, if so, then identify that the script is abnormal script, the abnormal inspection for solving existing SQL scripts For survey technology, it is necessary to which administrator carries out manual analysis to SQL language, detection efficiency is relatively low, and relies on administrator with higher Technical merit, so that the problem of improving the cost of maintenance.
In embodiments of the present invention, the executive agent of flow is the abnormality detection terminal of SQL scripts, and terminal device includes hand The terminals such as machine, computer equipment, tablet computer, server, especially, the terminal device are specially one and are put in Database Systems In SQL scripts detection terminal, by obtaining the operating condition of each SQL scripts in the database, and perform abnormality detection Operation.Fig. 1 shows the flow chart of realizing of the method for detecting abnormality for the SQL scripts that first embodiment of the invention provides, and detailed description is such as Under:
In S101, the running state parameter of each SQL scripts is obtained.
In the present embodiment, the trigger condition of abnormality detection includes triggering and automatic trigger both of which manually.Wherein, Trigger manually and be specially:Administrator generates an abnormality detection enabled instruction on the terminal device, or by user terminal to end End equipment sends an abnormality detection enabled instruction, if after terminal device receives the abnormality detection enabled instruction, performs The relevant operation of S101.And automatic trigger is specially:Terminal device is provided with abnormality detection and starts opportunity, if terminal device detects Matched to current state with default abnormality detection startup opportunity, then perform the relevant operation of S101.
Alternatively, in this embodiment, it can be a default detection cycle that the abnormality detection, which starts opportunity, terminal device Monitoring that current time meets the detection cycle, then performing the relevant operation of S101.The abnormality detection startup opportunity may be used also Think an operation threshold value, such as resources occupation rate, terminal device is monitoring that the current time operation of terminal to be detected disappears Consumption value is greater than or equal to default operation threshold value, then performs the relevant operation of S101.Since the consumption of equipment is excessive, generally Caused by being due to SQL script exceptions, therefore can be used as trigger condition by running the situation of consumption, the side triggered with the cycle Formula is compared, and can reduce unnecessary testing process, so as to improve the resource utilization of equipment.
In the present embodiment, SQL scripts can be run in the database with terminal device, in this case, terminal to be detected Terminal device as provided in an embodiment of the present invention, that is, detect each SQL scripts in local data base and whether there is abnormal conditions; SQL scripts can also run with other database servers outside terminal device, in this case, terminal device i.e. be used as one Independent detection terminal, the SQL scripts monitored in the database server whether there is abnormal conditions.Especially, terminal device A Database Systems can also be detected, multiple database servers, and each database server are included in the Database Systems Corresponding SQL scripts are extracted from same SQL scripts resources bank and carry out inquiry operation.Wherein, deposited in SQL scripts resources bank Multiple SQL scripts are contained, for meeting that the query demand of different user, such as user need to inquire about the season relevant number of bonus According to then by calling the first SQL scripts to be inquired about;User needs to count the continuation of insurance situation of vehicle insurance client, then by calling the Two SQL scripts are inquired about.
In the present embodiment, terminal device instructs or meets corresponding detection trigger condition in the detection for receiving user When, the running state parameter of each SQL scripts will be obtained respectively, especially, comprising more in the running state parameter of the SQL scripts A parameter item, each parameter item correspond to a parameter value, characterize different operation characteristics respectively.Wherein, the running of the SQL scripts State parameter includes but not limited to:Calculation resources take parameter, average operating time parameter, content and take parameter and call secondary Number.When operation resource occupation parameter specially calls the SQL scripts, execution one query flow, the calculation resources of required consumption, Alternatively, which can be represented with the average occupancy number of CPU.
In S102, according to the running state parameter of each SQL scripts, it is corresponding to calculate each SQL scripts First consumption characteristic value;Wherein, the first consumption characteristic value is used to represent occupancy feelings of the SQL scripts to device resource Condition.
In the present embodiment, terminal device, will be according to each fortune after the running state parameter of each SQL scripts is obtained Row state parameter obtains the Expenditure Levels of SQL scripts, therefore the multiple ginsengs that will be included in the corresponding running state parameter of SQL scripts Numerical value, imported into default consumption Feature Conversion model, special to calculate its corresponding first consumption by running state parameter Value indicative, passes through the Expenditure Levels of the first consumption characteristic value SQL scripts.
Alternatively, in the present embodiment, which can be a hash function, and terminal device is by described in The operating state parameter of SQL scripts is input in the hash function, then according to the parameter area where parameters value, is obtained One corresponding first consumption characteristic value.
Alternatively, in the present embodiment, which is specially a consumption level.In this case, terminal Equipment is in addition to obtaining the running state parameter of the current SQL scripts of user, the average operating status ginseng of the acquisition SQL scripts Number, current running state parameter is compared with mean state parameter, determines current consumption level.The consumption level bag Include but be not limited to:" being far below mean consumption ", " being less than mean consumption ", " maintenance normal level ", " being higher than mean consumption " and " being far above mean consumption ", terminal device can intuitively know the Expenditure Levels of each SQL scripts by showing the consumption level, Improve the information acquisition efficiency of user.
In S103, by the corresponding first consumption characteristic value of each SQL scripts by being ranked up from big to small, and select Top n first is taken to consume the corresponding SQL scripts of characteristic value, generation script consumption exception list;Wherein, the N is less than SQL feet The positive integer of this number.
In the present embodiment, terminal device is after the corresponding first consumption characteristic value of each SQL scripts is calculated, by basis The size of first consumption characteristic value is ranked up, and wherein the first consumption characteristic value numerical value is bigger, then it represents that its resource occupation is got over More, consumption is bigger, and the first consumption characteristic value numerical value is smaller, then it represents that its resource occupation is smaller, and consumption is also smaller, especially Ground, larger SQL scripts its corresponding run time of the first consumption characteristic value are longer.Therefore, after above-mentioned sequence, terminal is set It is standby to obtain a SQL resource consumption sequence, and according to default N values, the larger N number of SQL feet of numerical value are intercepted from the sequence This, i.e., the corresponding SQL scripts of above-mentioned top n first consumption characteristic value, generation script consumption exception list, and by showing mould Block is shown, or script consumption list directly is sent to the corresponding user terminal of database administrator.
In the present embodiment, the numerical value of the N can be configured according to the demand of user, can be according to being included in system The quantity of SQL scripts determines the numerical value of the N.For example, from SQL script resources banks, the SQL scripts for extracting 10% generate abnormal disappear List is consumed, then terminal device obtains the script quantity included in the SQL script resources first, and passes through default ratio value, meter Calculate the N values.Especially, which can configure corresponding N values according to the difference of the currently monitored time., may for the rush hour Need to carry out fine SQL scripts abnormality detection, then the N values are larger;And it is larger for free time, the idling-resource of system, because This can carry out rough SQL scripts abnormality detection, then the N values are smaller.
In the present embodiment, if the first consumption characteristic value there are multiple SQL scripts is identical, thus the SQL scripts of selection Number M is more than default N values, and in this case, above-mentioned M SQL scripts can be generated script consumption exception list by terminal device, and The M SQL script that consumption feature is larger is included in the list;Terminal device can also by the detection pattern according to user setting, From M SQL script, N number of SQL scripts are chosen.Specifically, since the running state parameter in different SQL scripts is comprising more A parameter item, therefore can be ranked up according to the size of the numerical value of parameter item, determine N number of SQL scripts.For example, the N values are 3, and The third-largest SQL scripts of consumption figures have 2, therefore it is 4 to choose obtained SQL scripts number, the first big SQL scripts, second largest SQL scripts and two SQL scripts for being locked in a tie for third big.At this time, when terminal device obtains current detection pattern to run Between mode of priority, then according to the operation time of running state parameter in two SQL for being locked in a tie for third big scripts, choose numerical value compared with A big SQL script, as the SQL scripts of abnormal consumption, with the first two SQL scripts generation script consumption exception list.
In S104, instruction is chosen according to the target script received, is consumed from the script and mesh is determined in exception list Mark SQL scripts.
In the present embodiment, user can check that the script consumes exception list, from this by the display module of terminal device One or more SQL scripts are chosen in list as target SQL scripts, wherein, target SQL scripts are specially to prejudge the SQL Script is abnormal script, but needs further to be detected the script of confirmation.Certainly, terminal device can also pass through default foot This Algorithms of Selecting, from script abnormal consumption list, chooses target SQL scripts, can also be successively to above-mentioned script abnormal consumption All SQL scripts in list are investigated one by one.Specifically, which can be:According to each SQL The history consumption characteristic value of script, determines the variance of each SQL scripts in script consumption exception list, then calculates this acquisition The first consumption characteristic value and script history consumption characteristic value difference, which is compared with variance, if difference Less than or equal to the variance, then prove that this first consumption characteristic value within normal domain of walker, is identified as non-targeted SQL Script;If conversely, the difference is more than the variance, target SQL scripts are identified as.
In the present embodiment, terminal device will obtain target script selection after receiving target script and choosing instruction The script mark included in instruction, and the script is identified into the script mark with each SQL scripts in script consumption exception list Knowledge is matched, and is determined that the selection instructs corresponding SQL scripts, is identified as target SQL scripts.
In the present embodiment, script mark can be the sequence number in the filename of SQL scripts, script numbering, list, User be can also be when choosing target SQL scripts in consuming exception list from script on the touch-control module of terminal device, triggering Position coordinates.
In S105, obtain the target SQL scripts and consume characteristic value in multiple default timing nodes corresponding first, And generate history characteristic curve of consumption.
In the present embodiment, terminal device records have the history run of each SQL scripts.Terminal device will be with default Time interval obtain the running state parameter of each SQL scripts, and be stored in the corresponding history log of each SQL scripts In.When user needs to obtain the history run of the SQL scripts, can be determined by directly acquiring the history log The situation of change of its corresponding running state parameter.
In the present embodiment, terminal device is each default by the history log of the SQL scripts to be prestored according to this, acquisition The corresponding running state parameter of timing node, and running state parameter is converted into the first consumption characteristic value, so as to be somebody's turn to do The history consumption record of the corresponding first consumption characteristic value of SQL scripts.Especially, which can be default Parameter acquisition cycle, i.e., each default time interval corresponding time point.
In the present embodiment, terminal device will be using the first consumption characteristic value as ordinate, and time point is abscissa, generation one A reference axis, and according to the corresponding first consumption characteristic value of each timing node, history characteristic curve of consumption is drawn out, and pass through Display module exports the history characteristic curve of consumption, so that user checks.
Alternatively, terminal device may be used also in addition to generating the history characteristic curve of consumption on the first consumption characteristic value According to each running state parameter, to generate the corresponding indicatrix of different running state parameters.For example, the running state parameter Comprising average operation duration, then terminal device can generate one it is bent on the corresponding history run temporal characteristics of average operation duration Line.Then whether terminal device can determine target SQL scripts by the corresponding curve distinguished number of the running state parameter For abnormal script.
In S106, judge to be more than default disappear with the presence or absence of the described first consumption characteristic value in history characteristic curve of consumption Consume the coordinate points of threshold value.
In S107, if there are the described first consumption characteristic value in the history characteristic curve of consumption to be more than default consumption The coordinate points of threshold value, then based on the history characteristic curve of consumption, determine that the first consumption characteristic value is more than default consumption The duration of threshold value.
In the present embodiment, terminal device can judge special with the presence or absence of the first consumption in the history characteristic curve of consumption first Value indicative is more than the coordinate points of default threshold value.If in the history characteristic curve of consumption, there are above-mentioned coordinate points, then it represents that mesh The consumption of SQL scripts is marked beyond normal consumption scope, it is necessary to conclude that the abnormal conditions are because the external world such as network environment Factor and the shake produced, or because target SQL scripts need further to judge, and hold in itself in abnormal caused The relevant operation of row S108;If conversely, in history characteristic curve of consumption, it is small that any coordinate points corresponding first consume characteristic value In the default threshold value, then it represents that target SQL scripts are constantly in normal working status, therefore identify the SQL feet This is normal SQL scripts.
In the present embodiment, which can voluntarily be set by user, can be the default value of system.It is excellent Selection of land, the default threshold value are related to the mean consumption value of target SQL scripts.Specifically, terminal device obtains first Obtained in each test point first consumption characteristic value of target SQL scripts, and mean consumption value is obtained, by default Weighting coefficient and mean consumption value, obtain the threshold value.By the above-mentioned means, the threshold value disappears by the first of history Consumption characteristic value is iterated calculating, it is achieved thereby that the dynamic of threshold value adjusts, then improves the accuracy rate of abnormality detection.
In S108, judge whether the duration is more than default bound-time threshold value.
In S109, if the duration is more than default bound-time threshold value, obtain each in the duration The corresponding derivative value of a coordinate points.
In the present embodiment, terminal device will detect after determining that target SQL scripts have the abnormal coordinate points of consumption The duration of the abnormal consumption, judges whether the abnormal consumption is saltus step shake.Therefore it is bent that history consumption feature will be obtained The first consumption characteristic value is more than the duration of default threshold value in line, and by the duration and default bound-time Threshold value is compared.If the duration is less than or equal to bound-time threshold value, then it represents that the consumption belongs to saltus step shake extremely, And caused by non-targeted SQL scripts exception, since script is usually an abnormal process of lasting consumption extremely;If this continues Time is more than bound-time threshold value, then it represents that the situation of consumption exception is the abnormal process of a lasting consumption, therefore will be into The threshold determination of row next step.
In the present embodiment, which refers specifically to the first threshold value of continuous coordinate points and is all higher than presetting The threshold value corresponding duration, if in history consumption curve there are two sections of discontinuous curves, and wherein coordinate points First consumption figures is all higher than threshold value, then calculates two sections of curves corresponding duration respectively, that is, obtained for the first duration And second duration.And the first duration and the second duration are judged with bound-time threshold value respectively. Therefore, if history characteristic curve of consumption corresponds to multiple duration, any duration is more than default bound-time threshold value, Then perform the relevant operation of S110.
In S110, judge whether that the corresponding derivative value of the coordinate points is more than default derivative threshold.
In S111, if there are the corresponding derivative value of the coordinate points to be more than default derivative threshold, institute is judged It is abnormal script to state target SQL scripts.
In the present embodiment, terminal device will obtain the corresponding derivative value of each coordinate points in the duration, due to leading Numerical value can represent the consumption pace of change of target SQL scripts, so that it is determined that the first consumption characteristic value is slowly to change Or it is mutation rapidly.If the derivative value is smaller, then it represents that the Expenditure Levels of target SQL files are slowly soaring or slow Decline, be then probably due to calling generating heat in full load condition or hardware for the corresponding terminal device of target SQL files, and lead Cause consumption gradually increase, and and non-targeted SQL files it is extremely caused;If the derivative value is larger, then it represents that target SQL files Expenditure Levels be drastically soaring or be drastically to decline, cause the situation occur it is larger be probably due to SQL files occur it is prominent Become, as caused by normal condition is changed into abnormality.Therefore, if the derivative value in the duration there are a coordinate points is more than Default derivative threshold, then it represents that the SQL scripts are abnormal script;If conversely, the duration of target SQL scripts is corresponding In curve, the derivative value there is no any coordinate points is more than default derivative threshold, then it represents that target SQL is normal script.
Especially, if the first consumption figures in S109 there are the discontinuous curve of multistage is more than default threshold value, Only choose the relevant operation that duration curve corresponding more than default bound-time performs S110.
Above as can be seen that a kind of method for detecting abnormality of SQL scripts provided in an embodiment of the present invention is by obtaining SQL feet This running state parameter, and the Expenditure Levels of the SQL scripts within the default period are determined by the running state parameter, The first consumption characteristic value is obtained, then terminal device chooses the maximum N number of SQL scripts of consumption, further determines that above-mentioned SQL scripts With the presence or absence of abnormal conditions, thus terminal device will consume exception list according to the maximum N number of SQL scripts generation script of consumption, And the target script received is extracted from script abnormal consumption list and chooses the corresponding SQL scripts of instruction as target SQL feet This, and then the corresponding history Expenditure Levels of target SQL scripts are obtained, history characteristic curve of consumption is generated, and by relevant Decision threshold, identifies whether the history characteristic curve of consumption reflects target SQL scripts there are abnormal conditions, if so, then knowing The script is not abnormal script.Compared with the method for detecting abnormality of existing SQL scripts, the embodiment of the present invention is without database Administrator investigates the abnormal conditions of SQL scripts manually, and it is larger that terminal device automatically generates the abnormal probability of a presence Script abnormal consumption list, reduces the detection range of administrator, and the target SQL scripts of the selection according to administrator, output Whether abnormal testing result, carry out anomalous identification without user, substantially increase the accuracy rate and response speed of abnormality detection Rate.On the other hand, since the process of abnormality detection is mainly completed by terminal device, for administrator technical merit requirement compared with It is low, so as to also reduce the maintenance cost of database.
Fig. 2 shows a kind of specific implementation stream of the method for detecting abnormality for SQL scripts that second embodiment of the invention provides Cheng Tu.It is shown in Figure 2, relative to embodiment described in Fig. 1, a kind of method for detecting abnormality of SQL scripts provided in this embodiment In further include S201 and S202, it is specific that details are as follows:
Further, if there are the corresponding derivative value of the coordinate points to be more than default derivative threshold described, sentence After the fixed target SQL scripts is abnormal scripts, further include:
In S201, the version change file of the target SQL scripts in the duration is obtained.
In the present embodiment, terminal device judge target SQL scripts for abnormal script after, it is necessary to its abnormal conditions into Row is repaired.For SQL scripts, after causing script to be abnormal the content alteration for being typically due to script, with database There is processing logic conflict in version or other application, thus cause script can not normal operation, therefore, can pass through and obtain change text Part simultaneously reduces the changed content in change file, realizes and abnormal reparation is carried out to SQL scripts.
In the present embodiment, terminal device detects that consumption exception occurs within the duration for SQL scripts, that is, when representing this Between in section probably due to target SQL scripts are there occurs version change, so as to cause database calling the SQL scripts after changing When, it may appear that consume abnormal situation.Thus, terminal device will obtain the corresponding version of target SQL scripts within the duration This change file.It should be noted that the quantity of the version change file can be one, i.e., only occur in duration Version change, can also at least two, i.e., there occurs multiple version change in duration.Wherein, a version Multiple changed contents can be included in this change file, i.e. version change of user's progress corresponds to multiple interior in the SQL scripts Appearance is adjusted or optimizes.
Alternatively, in the present embodiment, if not corresponding version change file, at this time terminal device in the duration It can obtain in the preset time section before the duration, the corresponding version change file of target SQL scripts.Terminal device When judging version change file is not present in the duration, it is possible to be before the duration there occurs version change, because This, whether terminal device will elapse default time interval forward on the basis of the duration, obtain in the time interval and deposit In the version change file of target SQL scripts, if in the presence of obtaining the version change file and perform the operation of S202.
In S202, the version change file is gradually reduced according to the inverted order of the creation time of the version change file Changed content, and the current running state parameter of the target SQL scripts is monitored, until the current running state parameter pair The the first consumption characteristic value answered is less than or equal to the threshold value.
In the present embodiment, terminal device when getting version change file, it is necessary to being wrapped in the version change file The changed content contained is progressively repaired, and reduction process is the corresponding inverse process of change process, thus is needed according to version The inverted order of the creation time of change file, successively reduces changed content therein one by one, to keep reduction process file Handle the reasonability of logic.
In the present embodiment, terminal device will obtain target SQL files after reducing and exist after one changed content of every reduction Running state parameter in preset time, and its corresponding first consumption characteristic value is calculated according to the running state parameter, if should First consumption characteristic value is less than or equal to default threshold value, then it represents that abnormal conditions have repaired success, terminate the phase of S202 Close operation;If conversely, the first consumption characteristic value carries out going back for next changed content still greater than default threshold value Original, repeats aforesaid operations.
In the present embodiment, if after the changed content to the file that has altered more carries out restoring operation, target SQL files Consumption characteristic value still in higher level, at this time, terminal device, which can generate one, manually to be repaired support directive instruction and pushes to this The corresponding processing account of Database Systems, so that the processing account carries out target SQL scripts abnormal reparation.
In embodiments of the present invention, terminal device is realized to exception by reducing the changed content in target SQL scripts The purpose that SQL scripts are repaired, repairs so as to fulfill automatic abnormality detection and automatically to abnormal, improves abnormal place Manage efficiency and response speed.
The specific implementation stream of the method for detecting abnormality S101 for the SQL scripts that Fig. 3 third embodiment of the invention provides a kind of Cheng Tu.It is shown in Figure 3, relative to embodiment described in Fig. 1, a kind of method for detecting abnormality of SQL scripts provided in this embodiment Middle S101 includes S301~S303, and specific details are as follows:
Further, the running state parameter for obtaining each SQL scripts, including:
In S301, whether monitoring current time meets default abnormality detection trigger timing.
Terminal device before each SQL scripts are obtained, it is necessary to judge its trigger timing, in the present embodiment, Terminal device is triggered and is consumed the detection triggering mode that triggering is combined using opportunity.First, terminal device will be obtained and monitored Whether current time matches with default abnormality detection trigger timing, and especially, which touches for a cycle Hair opportunity, or user's pre-set multiple time points.When terminal device judges that current time is triggered with abnormality detection Opportunity matches, then the relevant operation of S302 is performed, conversely, holding state is then kept, to reduce the consumption of electricity.
In S302, if current time meets default abnormality detection trigger timing, it is current to obtain terminal to be detected Resources occupation rate.
In the present embodiment, terminal device is then obtained when knowing that current time matches with abnormality detection trigger timing The current resources occupation rate of the terminal to be detected.Wherein, terminal to be detected is specially:Call the terminal of each SQL scripts.If The terminal device of the present embodiment is integrated in database server, and the database server calls each SQL scripts, then at this In the case of, terminal to be detected is terminal device provided in this embodiment;, should if terminal device is an independent detection terminal Terminal to be detected is to call the database server of each SQL scripts.
In the present embodiment, the terminal device resources occupation rate current by terminal to be detected is obtained, if terminal to be detected is An independent terminal, that is, the database server for calling each SQL scripts are same server, then can be directly by the terminal Resources occupation rate as the corresponding resources occupation rate of the terminal to be detected;If terminal to be detected is multiple database server groups Into Database Systems, then the resources occupation rate be whole Database Systems resources occupation rate.Especially, if terminal device collection Into in database server, then the resources occupation rate of terminal device local is obtained.
In the present embodiment, terminal device is provided with an occupancy threshold, when the resources occupation rate got is accounted for more than this During with rate threshold value, then it represents that there may be the situation of SQL scripts exception, performs the operation of S303;If the conversely, resource got Occupancy is less than or equal to occupancy threshold, then it represents that current SQL scripts operation is substantially at normal condition, and not up to need to be into The rank of row abnormality processing, therefore S301 will be returned, wait the arrival on next detection opportunity.Alternatively, in the present embodiment, The occupancy threshold can change according to the passage of time, such as idle period, call SQL scripts number and number compared with It is few, therefore its corresponding occupancy threshold can be relatively low, and the full marks period, call the number of SQL scripts and number more, Therefore its corresponding occupancy threshold can be higher.
In S303, judge whether resources occupation rate is more than default occupancy threshold.
In S304, if the resources occupation rate is more than default occupancy threshold, each SQL scripts are obtained Running state parameter.
In the present embodiment, terminal device then judges when detecting that resources occupation rate is more than default occupancy threshold There may be abnormal script in current SQL scripts, therefore the operation that abnormality detection will be performed.
In embodiments of the present invention, by setting abnormality detection opportunity and occupancy threshold, so that there may be different During normal situation, the operation of automated execution abnormality detection, so as to avoid unnecessary testing process, improves the utilization of resources of terminal Rate.
Fig. 4 shows the specific reality of the method for detecting abnormality S102 for SQL scripts that fourth embodiment of the invention provides a kind of Existing flow chart.It is shown in Figure 4, relative to the embodiments of Fig. 1 to 3, a kind of abnormal inspection of SQL scripts provided in this embodiment According to the running state parameter of each SQL scripts described in survey method, calculate each SQL scripts corresponding first and disappear Consume characteristic value first and consume the consumption characteristic value of characteristic value first, comprising S401 and S402, details are as follows:
Further, the running state parameter includes:Calculation resources take parameter, average operating time parameter, memory Take parameter and number of run;The running state parameter according to each SQL scripts, calculates each SQL feet This corresponding first consumption characteristic value, including:
In S401, the corresponding weighted value of each running state parameter is determined.
In the present embodiment, the running state parameter of each SQL scripts of terminal device acquisition includes polytype parameter, Respectively calculation resources take parameter, average operating time parameter, EMS memory occupation parameter and number of run, different running shapes The corresponding weighted value of state parameter differs, therefore terminal device is firstly the need of determining the corresponding weight of each running state parameter Value, and according to the corresponding consumption Feature Conversion model of above-mentioned weighted value generation.
Alternatively, in the present embodiment, terminal device can adjust each running state parameter according to current detection pattern Corresponding weighted value.For example, if current detection pattern is run time mode of priority, average operating time parameter is corresponding Weighted value is larger, and suitably adjusts the weighted value of other running state parameters;If current detection pattern is memory mode of priority, Then the corresponding weighted value of EMS memory occupation parameter is larger, so that the first consumption characteristic value can more effectively represent corresponding detection mould The Expenditure Levels of formula.
In S402, the corresponding calculation resources of each SQL scripts are taken into parameter, the average operating time Parameter, the EMS memory occupation parameter and the number of run, are directed into consumption characteristic value transformation model, calculate respectively each The SQL scripts corresponding first consume characteristic value, and the consumption characteristic value transformation model is specially:
Ex=α1Ct(SQL)+α2T(SQL)+α3Buff(SQL)+α4Q(SQL)
Wherein, Ex consumes characteristic value, α for the first of SQL scripts1、α2、α3And α4It is corresponding for each running state parameter Weighted value, Ct (SQL) are that the calculation resources of SQL scripts take parameter, and T (SQL) is the average operating time parameter of SQL scripts, Buff (SQL) is the EMS memory occupation parameter of SQL scripts, and Q (SQL) is the number of run of SQL scripts.
In the present embodiment, terminal device leads the corresponding parameter value of multiple running state parameters acquired in S101 Enter into consumption Feature Conversion model in corresponding position, and by the consumption characteristic value transformation model, joined by operating status Number calculates corresponding first consumption characteristic value.
In embodiments of the present invention, by the way that the multiple running state parameters acquired are imported into default consumption feature In transformation model, the conversion to the first consumption characteristic value by running state parameter is realized, improve the meter of the first consumption characteristic value Calculate efficiency.
Fig. 5 shows the specific reality of the method for detecting abnormality S103 for SQL scripts that fifth embodiment of the invention provides a kind of Existing flow chart.It is shown in Figure 5, relative to embodiment described in Fig. 1, a kind of abnormality detection of SQL scripts provided in this embodiment Method S103 comprises the following steps, and details are as follows:
Further, the N number of SQL scripts for choosing the first consumption characteristic value maximum, generation script consumption exception list, Including:
In S501, the time point at current time is obtained.
In the present embodiment, terminal device can also in addition to obtaining and showing current time corresponding first consumption characteristic value Contrast shows the second consumption characteristic value that same date current point in time is not corresponding, so that user can be according to the first consumption characteristic value And second consumption characteristic value determine this first consumption characteristic value whether be abnormal consumption.
In the present embodiment, which is specially a time numerical value, and such as 16:30, then it represents that for 30 minutes same day 16 point this One detection moment.Certainly, terminal device can represent the time point by other forms, such as 4:The forms such as 30pm, differ herein One limits.
In S502, the time point corresponding second consumption feature of the N number of SQL scripts in not same date is extracted Value.
In the present embodiment, terminal device will obtain the time point corresponding first consumption characteristic value in not same date, And mean consumption characteristic value is calculated as the second consumption characteristic value based on the multiple first consumption characteristic values, for representing at this Time point, conventional Expenditure Levels of the database server when calling the SQL scripts.Wherein, selection day issue can be by user Set, or a system default value.
For example, current time is the 16 of August 10 days:30, then terminal device can obtain August 1 day to during August 9 days, it is each 16:The consumption characteristic value of corresponding SQL scripts when 30, and the second consumption characteristic value is calculated according to above-mentioned standard characteristic value.
In S503, according to the first of N number of SQL scripts the consumption characteristic value and the second consumption characteristic value, divide The consumption floating grade of N number of SQL scripts is not calculated.
In the present embodiment, terminal device is by according to the first of each SQL scripts the consumption characteristic value and corresponding Second consumption characteristic value, calculates the corresponding consumption floating grade of the SQL scripts, so as to obtain consumption floating of N number of SQL scripts etc. Level, judges that the first current consumption characteristic value whether in rational domain of walker, facilitates whether user determines the SQL scripts For abnormal SQL scripts.Alternatively, the calculation of the floating grade is:Calculate the first consumption characteristic value and second feature Ratio, is identified as the consumption floating grade of SQL scripts by the ratio between value.
In S504, it is different that the script consumption is generated according to the consumption floating grade and the first consumption characteristic value Chang Liebiao.
In the present embodiment, terminal device is special by the floating grade according to each SQL scripts and corresponding first consumption Value indicative, generation script consumption exception list, wherein each first consumption characteristic value consumes floating grade with it and is located at same consumption In exception record, display is compared.Table 1 gives a kind of consumption exception list provided in this embodiment.As it can be seen that script is entitled The SQL scripts of wazd_saqs exceed mean consumption 900%, then very it is big may the script be in abnormality, can perform into one The unusual determination of step.
Sequence number SQL script names First consumption characteristic value Floating grade
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 embodiments of the present invention, shown by the way that the first consumption figures and floating grade are carried out contrast, so as to side Just user quickly judges that the SQL scripts whether in normal domain of walker, improve the efficiency of abnormality detection.
It is to be understood that the size of the sequence number of each step is not meant to the priority of execution sequence, each process in above-described embodiment Execution sequence should determine that the implementation process without tackling the embodiment of the present invention forms any limit with its function and internal logic It is fixed.
Fig. 6 shows a kind of structure diagram of the abnormality detection terminal for SQL scripts that one embodiment of the invention provides, should The each unit that the abnormality detection terminal of SQL scripts includes is used to perform each step in the corresponding embodiments of Fig. 1.Referring specifically to The associated description in embodiment corresponding to Fig. 1 and Fig. 1.For convenience of description, it illustrate only part related to the present embodiment.
Referring to Fig. 6, the abnormality detection terminal of the SQL scripts includes:
Running state parameter acquiring unit 61, for obtaining the running state parameter of each SQL scripts;
First consumption figures computing unit 62, for the running state parameter according to each SQL scripts, calculates each institute State the corresponding first consumption characteristic value of SQL scripts;Wherein, the first consumption characteristic value is used to represent that the SQL scripts pair are set The occupancy situation of standby resource;
Consume exception list generation unit 63, for will the corresponding first consumption characteristic value of each SQL scripts by from Arrive greatly it is small be ranked up, and choose top n first and consume the corresponding SQL scripts of characteristic value, generation script consumption exception list;Its In, the N is the positive integer less than SQL script numbers;
Target SQL scripts determination unit 64, for choosing instruction according to the target script received, consumes from the script Target SQL scripts are determined in exception list;
History characteristic curve of consumption generation unit 65, for obtaining target SQL scripts segmentum intercalaris when multiple default The corresponding first consumption characteristic value of point, and generate history characteristic curve of consumption;
Duration acquiring unit 66, if for there are the described first consumption characteristic value in the history characteristic curve of consumption More than the coordinate points of default threshold value, then based on the history characteristic curve of consumption, the first consumption characteristic value is determined More than the duration of default threshold value;
Curve derivative acquiring unit 67, if being more than default bound-time threshold value for the duration, obtains institute State the corresponding derivative value of each coordinate points in the duration;
Abnormal script identifying unit 68, if to be more than default derivative for there are the corresponding derivative value of the coordinate points Threshold value, then judge the target SQL scripts for abnormal script.
Alternatively, the abnormality detection terminal of the SQL scripts, further includes:
Version change file obtaining unit, for obtaining the version change of the target SQL scripts in the duration File;
Changed content reduction unit, the inverted order for the creation time according to the version change file gradually reduce the version The changed content of this change file, and the current running state parameter of the target SQL scripts is monitored, until the current fortune The corresponding first consumption characteristic value of row state parameter is less than or equal to the threshold value.
Alternatively, the running state parameter acquiring unit 61 includes:
Triggered time monitoring unit, for monitoring whether current time meets default abnormality detection trigger timing;
Resources occupation rate acquiring unit, if meeting default abnormality detection trigger timing for current time, acquisition is treated The current resources occupation rate of detection terminal;
Detection starts identifying unit, if being more than default occupancy threshold for the resources occupation rate, obtains each The running state parameter of the SQL scripts.
Alternatively, the running state parameter includes:Calculation resources take parameter, average operating time parameter, memory and account for With parameter and number of run;The first consumption figures computing unit 62 includes:
Operating parameter weight determining unit, for determining the corresponding weighted value of each running state parameter;
Characteristic value transformation model import unit is consumed, for the corresponding calculation resources of each SQL scripts to be accounted for With parameter, the average operating time parameter, the EMS memory occupation parameter and the number of run, consumption characteristic value is directed into Transformation model, calculates the corresponding first consumption characteristic value of each SQL scripts, the consumption characteristic value transformation model respectively Specially:
Ex=α1Ct(SQL)+α2T(SQL)+α3Buff(SQL)+α4Q(SQL)
Wherein, Ex consumes characteristic value, α for the first of SQL scripts1、α2、α3And α4It is corresponding for each running state parameter Weighted value, Ct (SQL) are that the calculation resources of SQL scripts take parameter, and T (SQL) is the average operating time parameter of SQL scripts, Buff (SQL) is the EMS memory occupation parameter of SQL scripts, and Q (SQL) is the number of run of SQL scripts.
Alternatively, the script consumption exception list generation 63, including:
Current time acquiring unit, for obtaining the time point at current time;
Second consumption characteristic value acquiring unit, for extracting the time point pair of the N number of SQL scripts in not same date The the second consumption characteristic value answered;
Floating grade acquiring unit is consumed, for according to the first of N number of SQL scripts the consumption characteristic value and described the Two consumption characteristic values, calculate the consumption floating grade of N number of SQL scripts respectively;
Script consumes exception list encapsulation unit, for according to the consumption floating grade and the first consumption feature Value generates the script consumption exception list.
Therefore, the abnormality detection terminal of SQL scripts provided in an embodiment of the present invention again may be by obtaining SQL scripts Running state parameter, and the Expenditure Levels of the SQL scripts within the default period are determined by the running state parameter, obtain First consumption characteristic value, then terminal device, which is chosen, consumes maximum N number of SQL scripts, whether further determines that above-mentioned SQL scripts There are abnormal conditions, thus terminal device is by according to consuming larger N number of SQL scripts generation script consumption exception list, and from The target script that receives is extracted in script abnormal consumption list choose and instruct corresponding SQL scripts as target SQL scripts, into And the corresponding history Expenditure Levels of target SQL scripts are obtained, history characteristic curve of consumption is generated, and pass through relevant decision threshold Value, identifies whether the history characteristic curve of consumption reflects target SQL scripts there are abnormal conditions, if so, then identifying the foot This is abnormal script.Compared with the method for detecting abnormality of existing SQL scripts, administrator of the embodiment of the present invention without database The abnormal conditions of SQL scripts are investigated manually, it is different that terminal device automatically generates the larger script of the abnormal probability of a presence Often consumption list, reduces the detection range of administrator, and the target SQL scripts of the selection according to administrator, and whether output is different Normal testing result, carries out anomalous identification without user, substantially increases the accuracy rate and the speed of response of abnormality detection.It is another Aspect, since the process of abnormality detection is mainly completed by terminal device, the technical merit requirement for administrator is relatively low, so that Also reduce the maintenance cost of database.
Fig. 7 is a kind of schematic diagram for terminal device that another embodiment of the present invention provides.As shown in fig. 7, the embodiment Terminal device 7 includes:Processor 70, memory 71 and it is stored in the memory 71 and can be transported on the processor 70 Capable computer program 72, such as the abnormality detecting program of SQL scripts.When the processor 70 performs the computer program 72 Realize the step in the method for detecting abnormality embodiment of above-mentioned each SQL scripts, such as the S101 to S108 shown in Fig. 1.Alternatively, The processor 70 realizes the function of each unit in above-mentioned each device embodiment, such as Fig. 6 when performing the computer program 72 The shown function of module 61 to 68.
Exemplary, the computer program 72 can be divided into one or more units, one or more of Unit is stored in the memory 71, and is performed by the processor 70, to complete the present invention.One or more of lists Member can complete the series of computation machine programmed instruction section of specific function, which is used to describe the computer journey Implementation procedure of the sequence 72 in the terminal device 7.For example, the computer program 72 can be divided into running state parameter Acquiring unit, the first consumption figures computing unit, consumption exception list generation unit, target SQL scripts determination unit, history consumption Indicatrix generation unit, duration acquiring unit, curve derivative acquiring unit and abnormal script identifying unit, each unit Concrete function is as follows:
Running state parameter acquiring unit, for obtaining the running state parameter of each SQL scripts;
First consumption figures computing unit, for the running state parameter according to each SQL scripts, calculates each described The corresponding first consumption characteristic value of SQL scripts;Wherein, the first consumption characteristic value is used to represent the SQL scripts to equipment The occupancy situation of resource;
Exception list generation unit is consumed, is pressed for each SQL scripts corresponding first to be consumed characteristic value from big It is ranked up to small, and chooses N number of SQL feet that top n first consumes the corresponding first consumption characteristic value maximum of characteristic value This, generation script consumption exception list;Wherein, the N is the positive integer less than SQL script numbers;
Target SQL script determination units, for choosing instruction according to the target script received, consume different from the script Target SQL scripts are determined in Chang Liebiao;
History characteristic curve of consumption generation unit, for obtaining the target SQL scripts in multiple default timing nodes Corresponding first consumption characteristic value, and generate history characteristic curve of consumption;
Duration acquiring unit, if for there are the described first consumption characteristic value is big in the history characteristic curve of consumption In the coordinate points of default threshold value, then based on the history characteristic curve of consumption, determine that the first consumption characteristic value is big In the duration of default threshold value;
Curve derivative acquiring unit, if being more than default bound-time threshold value for the duration, obtain described in The corresponding derivative value of each coordinate points in duration;
Abnormal script identifying unit, if to be more than default derivative threshold for there are the corresponding derivative value of the coordinate points Value, then judge the target SQL scripts for abnormal script.
The terminal device 7 can be that the calculating such as desktop PC, notebook, palm PC and cloud server are set It is standby.The terminal device may include, but be not limited only to, processor 70, memory 71.It will be understood by those skilled in the art that Fig. 7 The only example of terminal device 7, does not form the restriction to terminal device 7, can include than illustrating more or fewer portions Part, either combines some components or different components, such as the terminal device can also include input-output equipment, net Network access device, bus etc..
Alleged processor 70 can be central processing unit (Central Processing Unit, CPU), can also be Other general processors, digital signal processor (Digital Signal Processor, DSP), application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field- Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic, Discrete hardware components etc..General processor can be microprocessor or the processor can also be any conventional processor Deng.
The memory 71 can be the internal storage unit of the terminal device 7, such as the hard disk of terminal device 7 or interior Deposit.The memory 71 can also be the External memory equipment of the terminal device 7, such as be equipped with the terminal device 7 Plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, dodges Deposit card (Flash Card) etc..Further, the memory 71 can also both include the storage inside list of the terminal device 7 Member also includes External memory equipment.The memory 71 is used to store needed for the computer program and the terminal device Other programs and data.The memory 71 can be also used for temporarily storing the data that has exported or will export.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, can also That unit is individually physically present, can also two or more units integrate in a unit.Above-mentioned integrated list Member can both be realized in the form of hardware, can also be realized in the form of SFU software functional unit.
If the integrated module/unit realized in the form of SFU software functional unit and as independent production marketing or In use, it can be stored in a computer read/write memory medium.Based on such understanding, the present invention realizes above-mentioned implementation All or part of flow in example method, can also instruct relevant hardware to complete, the meter by computer program Calculation machine program can be stored in a computer-readable recording medium, the computer program when being executed by processor, it can be achieved that on The step of stating each embodiment of the method..Wherein, the computer program includes computer program code, the computer program Code can be source code form, object identification code form, executable file or some intermediate forms etc..Computer-readable Jie Matter can include:Can carry any entity or device of the computer program code, recording medium, USB flash disk, mobile hard disk, Magnetic disc, CD, computer storage, read-only storage (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium etc..It is it should be noted that described The content that computer-readable medium includes can carry out appropriate increasing according to legislation in jurisdiction and the requirement of patent practice Subtract, such as in some jurisdictions, according to legislation and patent practice, computer-readable medium does not include electric carrier signal and electricity Believe signal.
Embodiment described above is merely illustrative of the technical solution of the present invention, rather than its limitations;Although with reference to foregoing reality Example is applied the present invention is described in detail, it will be understood by those of ordinary skill in the art that:It still can be to foregoing each Technical solution described in embodiment is modified, or carries out equivalent substitution to which part technical characteristic;And these are changed Or replace, the essence of appropriate technical solution is departed from the spirit and scope of various embodiments of the present invention technical solution, should all Within protection scope of the present invention.

Claims (10)

  1. A kind of 1. method for detecting abnormality of SQL scripts, it is characterised in that including:
    Obtain the running state parameter of each SQL scripts;
    According to the running state parameter of each SQL scripts, the corresponding first consumption feature of each SQL scripts is calculated Value;Wherein, the first consumption characteristic value is used to represent occupancy situation of the SQL scripts to device resource;
    By the corresponding first consumption characteristic value of each SQL scripts by being ranked up from big to small, and choose top n first and disappear Consume the corresponding SQL scripts of characteristic value, generation script consumption exception list;Wherein, the N is just whole less than SQL script numbers Number;
    Instruction is chosen according to the target script received, is consumed from the script and target SQL scripts is determined in exception list;
    Obtain the target SQL scripts and consume characteristic value in multiple default timing nodes corresponding first, and generate history and disappear Consume indicatrix;
    If there are described first in the history characteristic curve of consumption to consume coordinate points of the characteristic value more than default threshold value, Then be based on the history characteristic curve of consumption, determine it is described first consumption characteristic value be more than default threshold value it is lasting when Between;
    If the duration is more than default bound-time threshold value, it is corresponding to obtain each coordinate points in the duration Derivative value;
    If there are the corresponding derivative value of the coordinate points to be more than default derivative threshold, the target SQL scripts are judged For abnormal script.
  2. 2. method for detecting abnormality according to claim 1, it is characterised in that if there are the coordinate points to correspond to described Derivative value be more than default derivative threshold, then after judging the target SQL scripts for abnormal script, further include:
    Obtain the version change file of the target SQL scripts in the duration;
    The changed content of the version change file is gradually reduced according to the inverted order of the creation time of the version change file, and is supervised The current running state parameter of the target SQL scripts is surveyed, until corresponding first consumption of the current running state parameter Characteristic value is less than or equal to the threshold value.
  3. 3. method for detecting abnormality according to claim 1, it is characterised in that the operation shape for obtaining each SQL scripts State parameter, including:
    Whether monitoring current time meets default abnormality detection trigger timing;
    If current time meets default abnormality detection trigger timing, the current resources occupation rate of terminal to be detected is obtained;
    If the resources occupation rate is more than default occupancy threshold, the running state parameter of each SQL scripts is obtained.
  4. 4. according to claim 1-3 any one of them method for detecting abnormality, it is characterised in that the running state parameter bag Include:Calculation resources take parameter, average operating time parameter, EMS memory occupation parameter and number of run;
    The running state parameter according to each SQL scripts, it is special to calculate corresponding first consumption of each SQL scripts Value indicative, including:
    Determine the corresponding weighted value of each running state parameter;
    The corresponding calculation resources of each SQL scripts are taken into parameter, the average operating time parameter, the memory Parameter and the number of run are taken, consumption characteristic value transformation model is directed into, calculates each SQL scripts pair respectively The the first consumption characteristic value answered, the consumption characteristic value transformation model are specially:
    Ex=α1Ct(SQL)+α2T(SQL)+α3Buff(SQL)+α4Q(SQL)
    Wherein, Ex consumes characteristic value, α for the first of SQL scripts1、α2、α3And α4For the corresponding weight of each running state parameter Value, Ct (SQL) be SQL scripts calculation resources take parameter, T (SQL) be SQL scripts average operating time parameter, Buff (SQL) it is the EMS memory occupation parameter of SQL scripts, Q (SQL) is the number of run of SQL scripts.
  5. 5. method for detecting abnormality according to claim 1, it is characterised in that the selection top n first consumes characteristic value Corresponding SQL scripts, generation script consumption exception list, including:
    Obtain the time point at current time;
    Extract the time point corresponding second consumption characteristic value of the N number of SQL scripts in not same date;
    According to the first of N number of SQL scripts the consumption characteristic value and the second consumption characteristic value, calculate respectively described N number of The consumption floating grade of SQL scripts;
    According to the consumption floating grade and the first consumption characteristic value generation script consumption exception list.
  6. 6. a kind of terminal device, it is characterised in that the terminal device includes memory, processor and is stored in the storage In device and the computer program that can run on the processor, the processor are realized as follows when performing the computer program Step:
    Obtain the running state parameter of each SQL scripts;
    According to the running state parameter of each SQL scripts, the corresponding first consumption feature of each SQL scripts is calculated Value;Wherein, the first consumption characteristic value is used to represent occupancy situation of the SQL scripts to device resource;
    By the corresponding first consumption characteristic value of each SQL scripts by being ranked up from big to small, and choose top n first and disappear Consume the corresponding SQL scripts of characteristic value, generation script consumption exception list;Wherein, the N is just whole less than SQL script numbers Number;
    Instruction is chosen according to the target script received, is consumed from the script and target SQL scripts is determined in exception list;
    Obtain the target SQL scripts and consume characteristic value in multiple default timing nodes corresponding first, and generate history and disappear Consume indicatrix;
    If there are described first in the history characteristic curve of consumption to consume coordinate points of the characteristic value more than default threshold value, Then be based on the history characteristic curve of consumption, determine it is described first consumption characteristic value be more than default threshold value it is lasting when Between;
    If the duration is more than default bound-time threshold value, it is corresponding to obtain each coordinate points in the duration Derivative value;
    If there are the corresponding derivative value of the coordinate points to be more than default derivative threshold, the target SQL scripts are judged For abnormal script.
  7. 7. terminal device according to claim 6, it is characterised in that if being led described there are the coordinate points are corresponding Numerical value is more than default derivative threshold, then after judging the target SQL scripts for abnormal script, described in the processor execution Following steps are also realized during computer program:
    Obtain the version change file of the target SQL scripts in the duration;
    The changed content of the version change file is gradually reduced according to the inverted order of the creation time of the version change file, and is supervised The current running state parameter of the target SQL scripts is surveyed, until corresponding first consumption of the current running state parameter Characteristic value is less than or equal to the threshold value.
  8. 8. terminal device according to claim 6, it is characterised in that the operating status ginseng for obtaining each SQL scripts Number, including:
    Whether monitoring current time meets default abnormality detection trigger timing;
    If current time meets default abnormality detection trigger timing, the current resources occupation rate of terminal to be detected is obtained;
    If the resources occupation rate is more than default occupancy threshold, the running state parameter of each SQL scripts is obtained.
  9. 9. according to claim 6-8 any one of them terminal devices, it is characterised in that the running state parameter includes:Fortune Calculate resource occupation parameter, average operating time parameter, EMS memory occupation parameter and number of run;
    The running state parameter according to each SQL scripts, it is special to calculate corresponding first consumption of each SQL scripts Value indicative, including:
    Determine the corresponding weighted value of each running state parameter;
    The corresponding calculation resources of each SQL scripts are taken into parameter, the average operating time parameter, the memory Parameter and the number of run are taken, consumption characteristic value transformation model is directed into, calculates each SQL scripts pair respectively The the first consumption characteristic value answered, the consumption characteristic value transformation model are specially:
    Ex=α1Ct(SQL)+α2T(SQL)+α3Buff(SQL)+α4Q(SQL)
    Wherein, Ex consumes characteristic value, α for the first of SQL scripts1、α2、α3And α4For the corresponding weight of each running state parameter Value, Ct (SQL) be SQL scripts calculation resources take parameter, T (SQL) be SQL scripts average operating time parameter, Buff (SQL) it is the EMS memory occupation parameter of SQL scripts, Q (SQL) is the number of run of SQL scripts.
  10. 10. a kind of computer-readable recording medium, the computer-readable recording medium storage has computer program, its feature exists In when the computer program is executed by processor the step of realization such as any one of claim 1 to 5 the method.
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 true CN107908555A (en) 2018-04-13
CN107908555B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109726364A (en) * 2018-07-06 2019-05-07 平安科技(深圳)有限公司 Electricity consumption method for detecting abnormality, 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 (3)

* 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
US20150200862A1 (en) * 2011-05-24 2015-07-16 Citrix Systems, Inc. Systems and methods for analyzing network metrics
CN105391729A (en) * 2015-11-30 2016-03-09 中国航天科工集团第二研究院七〇六所 Web loophole automatic mining method based on fuzzy test

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150200862A1 (en) * 2011-05-24 2015-07-16 Citrix Systems, Inc. Systems and methods for analyzing network metrics
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

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109726364A (en) * 2018-07-06 2019-05-07 平安科技(深圳)有限公司 Electricity consumption method for detecting abnormality, device, terminal and computer readable storage medium
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

Also Published As

Publication number Publication date
CN107908555B (en) 2020-01-14

Similar Documents

Publication Publication Date Title
CN105281981B (en) The data traffic monitoring method and device of network service
CN101841565B (en) Database cluster system load balancing method and database cluster system
CN110163474A (en) A kind of method and apparatus of task distribution
CN108198408B (en) Self-adaptive anti-electricity-stealing monitoring method and system based on electricity information acquisition system
CN106228386A (en) A kind of information-pushing method and device
CN108090225A (en) Operation method, device, system and the computer readable storage medium of database instance
CN106407830A (en) Detection method and device of cloud-based database
CN107798038A (en) Data response method and data response apparatus
CN106407244A (en) Multi-database-based data query method, system and apparatus
CN108269087A (en) The processing method and processing device of location information
CN107622102A (en) Entity card number generation method and terminal device
CN112365070A (en) Power load prediction method, device, equipment and readable storage medium
CN107908555A (en) A kind of method for detecting abnormality and its terminal of SQL scripts
CN108255703A (en) A kind of fault repairing method and its terminal of SQL scripts
CN107704317A (en) Smart machine and its application management method and the device with store function
CN109885384B (en) Task parallelism optimization method and device, computer equipment and storage medium
CN108255710B (en) Script abnormity detection method and terminal thereof
CN107797924A (en) A kind of method for detecting abnormality and its terminal of SQL scripts
CN111008078A (en) Batch processing method, device and equipment of data and computer storage medium
CN108255704A (en) A kind of script calls the exception response method and its terminal of event
CN110232590B (en) Scheme generation method and equipment
CN107957942B (en) SQL script fault repairing method and terminal thereof
CN114202339A (en) Early warning processing method and device
CN111815339A (en) Marketing information pushing method and equipment
CN109670980A (en) A kind of processing method, system and the equipment of the business datum that charges

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