...
|
...
|
@@ -21,6 +21,13 @@ BEGIN |
|
|
END$$
|
|
|
DELIMITER ;
|
|
|
|
|
|
DELIMITER $$
|
|
|
CREATE PROCEDURE `p_del_perf`(IN `date_inter` INT)
|
|
|
BEGIN
|
|
|
DELETE FROM perf_report WHERE (TO_DAYS(NOW()) - TO_DAYS(FROM_UNIXTIME(create_time/1000)))>=date_inter;
|
|
|
END$$
|
|
|
DELIMITER ;
|
|
|
|
|
|
-- test
|
|
|
DELIMITER $$
|
|
|
CREATE PROCEDURE `i_sert`(IN `date_inter` INT)
|
...
|
...
|
@@ -32,6 +39,7 @@ DELIMITER ; |
|
|
-- 删除存储过程
|
|
|
drop procedure if exists p_del_slow;
|
|
|
drop procedure if exists p_del_error;
|
|
|
drop procedure if exists p_del_perf;
|
|
|
|
|
|
-- 列出所有存储过程
|
|
|
select specific_name from mysql.proc;
|
...
|
...
|
@@ -57,6 +65,11 @@ ON SCHEDULE EVERY 1 DAY STARTS '2018-2-1 0:0:0' |
|
|
ON COMPLETION PRESERVE DISABLE
|
|
|
DO CALL p_del_error (7);
|
|
|
|
|
|
CREATE EVENT `e_del_perf_report`
|
|
|
ON SCHEDULE EVERY 1 DAY STARTS '2018-5-24 0:0:0'
|
|
|
ON COMPLETION PRESERVE DISABLE
|
|
|
DO CALL p_del_perf (7);
|
|
|
|
|
|
-- test
|
|
|
CREATE EVENT `i_second`
|
|
|
ON SCHEDULE EVERY 1 SECOND
|
...
|
...
|
@@ -72,14 +85,17 @@ SELECT event_name,event_definition,interval_value,interval_field,status FROM inf |
|
|
--开启定时任务
|
|
|
alter event e_del_slow_route on completion preserve enable;
|
|
|
alter event e_del_error_report on completion preserve enable;
|
|
|
alter event e_del_perf_report on completion preserve enable;
|
|
|
|
|
|
--关闭定时任务
|
|
|
alter event e_del_slow_route on completion preserve disable;
|
|
|
alter event e_del_error_report on completion preserve disable;
|
|
|
alter event e_del_perf_report on completion preserve disable;
|
|
|
|
|
|
--删除定时任务
|
|
|
drop event if exists e_del_slow_route;
|
|
|
drop event if exists e_del_error_report;
|
|
|
drop event if exists e_del_perf_report;
|
|
|
|
|
|
ALTER TABLE slow_duration ADD useragent varchar(200);
|
|
|
|
...
|
...
|
|