MYSQL trigger 질문이 있습니다..

   조회 5647   추천 0    

mikrotik 에서 패킷 스니퍼 기능으로 ubuntu 16.04 서버에 패킷을 보낸후 suricata로 분석하고 barnyard2 로 db에 저장

db에 저장된 값을 php 스크립트를 이용하여 미크로틱 api기능을이용해서 블럭 어드레스에 추가하는 기능입니다.. 다른것은 다 진행되는데 mysql 트리거 에서 문법오류가 납니다 ㅠㅠ

확인 가능하신분 계시면 확인부탁드립니다..

 http://forum.mikrotik.com/viewtopic.php?t=111727


CREATE TRIGGER `after_iphdr_insert` AFTER INSERT ON `iphdr`
  FOR EACH ROW BEGIN
  DECLARE this_event INT(11) default 0;
  DECLARE this_event_signature INT(10) default 0;
  DECLARE this_event_timestamp TIMESTAMP;
  DECLARE this_sig INT(10) default 0;
  DECLARE this_sig_name VARCHAR(256) default "";
  DECLARE this_sig_gid INT(10) default 0;
  DECLARE timeout VARCHAR(12) default "";
  DECLARE interested INT default 0;
  DECLARE direction VARCHAR(3) default "";
  DECLARE ip_src VARCHAR(64) default "";
  DECLARE ip_dst VARCHAR(64) default "";
  SELECT event.id, event.signature, event.timestamp
  INTO this_event, this_event_signature, this_event_timestamp
  FROM event
  WHERE event.sid = NEW.sid and event.cid = NEW.cid;  
  SELECT signature.sig_sid, signature.sig_gid, signature.sig_name 
  INTO this_sig, this_sig_gid, this_sig_name
  FROM signature
  WHERE signature.sig_id = this_event_signature;
  SELECT count(*), sigs_to_block.src_or_dst, sigs_to_block.timeout
  INTO interested, direction, timeout
  FROM sigs_to_block
  WHERE this_sig_name LIKE CONCAT(sigs_to_block.sig_name, '%');
  IF (interested > 0) THEN
   IF (direction = "src") THEN
      INSERT INTO block_queue
   SET que_ip_adr = inet_ntoa(NEW.ip_src),
          que_timeout = timeout,
          que_sig_name = this_sig_name,
          que_sig_gid = this_sig_gid,
          que_sig_sid = this_sig,
          que_event_timestamp = this_event_timestamp;
    ELSE
      INSERT INTO block_queue
   SET que_ip_adr = inet_ntoa(NEW.ip_dst),
          que_timeout = timeout,
          que_sig_name = this_sig_name,
          que_sig_gid = this_sig_gid,
          que_sig_sid = this_sig,
          que_event_timestamp = this_event_timestamp;
    END IF;
  END IF;
END


현재 mysql 5.7버전 사용하고 있습니다

짧은글 일수록 신중하게.
정재호02 2016-09
알아서 해결했습니다만.. 혹시 저와같이 구축하신분이 있다가 막히신다면 저에게 쪽지를 남겨주세요
NeOpLe 2016-09
MySQL trigger 도 많이 변했네요.


QnA
제목Page 2259/5727
2015-12   1776417   백메가
2014-05   5251399   정은준1
2016-09   6921   루이스
2016-09   5241   주황별
2016-09   7702   컴박
2016-09   5648   정재호02
2016-09   4375   미수맨
2016-09   12063   FreeBSD
2016-09   4719   서울사람
2016-09   4462   박기현2016
2016-09   5002   jang
2016-09   7047   허인구마틴
2016-09   5205   늘파란
2016-09   4729   iron19
2016-09   4370   장동건2014
2016-09   4446   킵고잉
2016-09   6010   송진홍
2016-09   4750   클래식
2016-09   19702   AplPEC
2016-09   5648   허인구마틴
2016-09   5005   hyunsemo
2016-09   4732   송진현