LogAnalyzer message parser 소스 코드

2015. 10. 6. 21:09·프로젝트 관련 조사/로그 관련
반응형

<?php
/*
   *********************************************************************
   * LogAnalyzer - http://loganalyzer.adiscon.com
   * -----------------------------------------------------------------   *
   * Drupal MSG Parser is used to split Drupal fields if found
   * in the msg
   *                                                   *
   * LogAnalyzer is free software: you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * LogAnalyzer is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with LogAnalyzer. If not, see <http://www.gnu.org/licenses/>.
   *
   * A copy of the GPL can be found in the file "COPYING" in this
   * distribution.
   *********************************************************************
*/

// --- Avoid directly accessing this file!
if ( !defined('IN_PHPLOGCON') )
{
   die('Hacking attempt');
   exit;
}
// ---

// --- Basic Includes
require_once($gl_root_path . 'classes/enums.class.php');
require_once($gl_root_path . 'classes/msgparser.class.php');
require_once($gl_root_path . 'include/constants_errors.php');
require_once($gl_root_path . 'include/constants_logstream.php');
// ---

class MsgParser_drupal extends MsgParser {

   // Public Information properties
   public $_ClassName = 'Drupal Format';
   public $_ClassDescription = 'This is a parser for a special format which can be created with Drupal.';
   public $_ClassRequiredFields = null;
   public $_ClassHelpArticle = "http://www.drupal.org";

   // Constructor
   public function MsgParser_eventlog() {
      return; // Nothing
   }

   /**
   * ParseLine
   *
   * @param arrArguments array in&out: properties of interest. There can be no guarantee the logstream can actually deliver them.
   * @return integer Error stat
   */
   public function ParseMsg($szMsg, &$arrArguments)
   {
      global $content, $fields;

      //trim the msg first to remove spaces from begin and end
      $szMsg = trim($szMsg);

      // Sample (Drupal syslog module):
      // http://beta2.kinonation.com|1354838305|system|208.57.201.113|http://beta2.kinonation.com/admin/modules/list/confirm|http://beta2.kinonation.com/admin/modules|1||syslog module installed.
      // Source:                        
      // %host%|%id%|%module%|%IP%|%URL%|%URL2%|%id2%|%dontknow%|%msg%%$CRLF%
      if ( preg_match("/(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)$/", $szMsg, $out ) )
      {
         // Copy parsed properties!
         $arrArguments[SYSLOG_HOST] = $out[1];
         $arrArguments[SYSLOG_PROCESSID] = $out[2];
         $arrArguments[SYSLOG_WEBLOG_USERAGENT] = $out[3];
         $arrArguments[SYSLOG_WEBLOG_REFERER] = $out[4];
         $arrArguments[SYSLOG_WEBLOG_QUERYSTRING] = $out[5];
         $arrArguments[SYSLOG_WEBLOG_URL] = $out[6];
         $arrArguments[SYSLOG_EVENT_USER] = $out[7];
//         $arrArguments[SYSLOG_WEBLOG_PVER] = $out[8];
         $arrArguments[SYSLOG_MESSAGE] = $out[9];

         if ( $this->_MsgNormalize == 1 )
         {
            //Init tmp msg
            $szTmpMsg = "";

            // Create Field Array to prepend into msg! Reverse Order here
            $myFields = array( SYSLOG_MESSAGE, SYSLOG_EVENT_USER, SYSLOG_WEBLOG_URL, SYSLOG_WEBLOG_QUERYSTRING, SYSLOG_WEBLOG_REFERER, SYSLOG_WEBLOG_USERAGENT, SYSLOG_PROCESSID, SYSLOG_HOST );

            foreach ( $myFields as $myField )
            {
               // Set Field Caption
               if ( isset($fields[$myField]['FieldCaption']) )
                  $szFieldName = $fields[$myField]['FieldCaption'];
               else
                  $szFieldName = $myField;

               // Append Field into msg
               $szTmpMsg = $szFieldName . ": '" . $arrArguments[$myField] . "'\n" . $szTmpMsg;
            }

            // copy finished MSG back!
            $arrArguments[SYSLOG_MESSAGE] = $szTmpMsg;

         }
      }
      else
      {
         // return no match in this case!
         return ERROR_MSG_NOMATCH;
      }
      // If we reached this position, return success!
      return SUCCESS;
   }
}

?>

반응형
저작자표시 (새창열림)

'프로젝트 관련 조사 > 로그 관련' 카테고리의 다른 글

로그관련 법규 - 산업기술 유출 방지법  (0) 2015.10.07
보안장비 -> 아마존 서버 로그 전송  (0) 2015.10.07
LogAnalyzer Sources 설정  (0) 2015.10.06
로그 DB 설계 - 1  (0) 2015.10.05
loganalyzer 설치  (0) 2015.09.26
'프로젝트 관련 조사/로그 관련' 카테고리의 다른 글
  • 로그관련 법규 - 산업기술 유출 방지법
  • 보안장비 -> 아마존 서버 로그 전송
  • LogAnalyzer Sources 설정
  • 로그 DB 설계 - 1
호레
호레
창업 / IT / 육아 / 일상 / 여행
    반응형
  • 호레
    Unique Life
    호레
  • 전체
    오늘
    어제
    • 분류 전체보기
      • 법률
        • 기본
        • 개인정보보호법
        • 정보통신망법
        • 전자금융거래법
        • 전자금융감독규정
        • 신용정보법
        • 온라인투자연계금융업법
      • 창업
        • 외식업 관련
        • 임대업 관련
        • 유통업 관련
        • 세무 관련
        • 마케팅 관련
        • 기타 지식
        • 트렌드
        • Youtube
      • IT기술 관련
        • 모바일
        • 윈도우
        • 리눅스
        • MAC OS
        • 네트워크
        • 빅데이터 관련
        • A.I 인공지능
        • 파이썬_루비 등 언어
        • 쿠버네티스
        • 기타 기술
      • 퍼블릭 클라우드 관련
        • Azure
        • GCP
        • AWS
      • 정보보안 관련
        • QRadar
        • Splunk
        • System
        • Web
      • 기타
        • 세상 모든 정보
        • 서적
      • 게임 관련
        • 유니티
      • 부동산
      • 맛집 찾기
        • 강남역
        • 양재역
        • 판교역
        • ★★★★★
        • ★★★★
        • ★★★
        • ★★
        • ★
      • 결혼_육아 생활
        • 리얼후기
        • 일상
        • 육아
        • 사랑
        • Food
      • 영어
        • 스피킹
        • 문법
        • 팝송
        • 영화
      • K-컨텐츠
        • 드라마
        • 영화
        • 예능
      • 독서
      • 프로젝트 관련 조사
        • 시스템 구축
        • 로그 관련
        • 웹
        • APT
        • 모의 해킹
        • DB
        • 허니팟
        • 수리카타
        • 알고리즘
        • FDS
      • 기업별 구내 식당 평가
        • 한국관광공사
        • KT telecop
        • KT M&S
        • KT powertel
        • KT cs 연수원
        • 진에어
      • 대학 생활
        • 위드윈연구소
        • 진로 고민
        • 채용정보
        • 자동차
        • 주식
        • 악성코드
        • 게임 보안
      • 쉐어하우스
  • 블로그 메뉴

    • 홈
    • 게임 관련
    • IT 기술 관련
    • 태그
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    수제버거존맛
    수제버거
    상호관세
    판교
    판교맛집
    무역전쟁
    점심
    대통령
    AWS
    마케팅
    돈까스
    보안가이드
    런치
    맛집
    유니티
    복리후생
    이재곧죽습니다
    판교역
    쥬쥬랜드
    수제버거맛집
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.0
호레
LogAnalyzer message parser 소스 코드
상단으로

티스토리툴바