MYSQL trigger 질문이 있습니다..

   조회 5430   추천 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 3044/5708
2015-12   1673623   백메가
2014-05   5139132   정은준1
2006-09   5392   김병우
2006-05   5392   조명준
2008-07   5392   이제호
2008-01   5392   박일석
2018-11   5392   박중석
2012-10   5392   김건우
2006-10   5392   민봉기
2009-01   5392   윤치열
2013-09   5392   황혼을향해
2015-05   5392   송지만
2019-09   5392   화란
2006-03   5392   곽선호
2008-09   5392   배주규
2008-01   5392   김성범
2018-11   5392   뽀칠이
2007-03   5393   조영민
2008-11   5393   박종대
2009-01   5393   임시현
2009-01   5393   서정욱
2006-03   5393   박두진