반응형

# kill all INTF-FLAP messages...
if $msg contains 'INTF-FLAP' then /dev/null
&~
## Cisco ACS Accounting...
if ($fromhost-ip=='172.17.16.20') and ($programname == 'CSCOacs_TACACS_Accounting') then /var/log/tacacs_acct.log
&~
## CiscoACS 5.4 TACACS Authentication
if ($fromhost-ip=='172.17.16.20') and ($programname == 'CSCOacs_Passed_Authentications') then /var/log/tacacs_auth.log
&~

# Logging for Chicago issues...
if $fromhost-ip startswith '172.17.25' then /var/log/net/chicago.log
& ~
# Logging for Dallas issues...
if $fromhost-ip startswith '172.17.27' then /var/log/net/dallas.log
& ~
# Logging for firewall...
if $fromhost-ip=='172.17.4.4' then @10.14.12.12
if $fromhost-ip=='172.17.4.4' then /var/log/net/firewall.log

 

if $fromhost-ip == '192.168.152.137' then {
        action(type="omfile" file="/var/log/remotefile02")
        stop
    }

 

if $fromhost-ip startswith '192.0.1.' then /var/log/network1.log
& ~

 

 

 

 

 

 

 

 

 

 

 

 

// rsyslog 커스텀 하는 방법

http://www.loggly.com/ultimate-guide/centralizing-apache-logs/

반응형
반응형

 

RegExTester_VB_NET.zip

 

프로그램 사용법

 

위 프로그램을 실행 시키고 Text에 303-456-1234를 입력한다.

 

Req.Expression 에 정규 표현식을 써주고 Apply 해주면된다.

 

 

 

 

정규 표현식

 

[0-9]        -> 0부터 9까지의 숫자를 찾아라

 

[01235]     -> 01235 만 찾는다.

 

\d            -> 숫자를 잡아줌

 

\D            -> 숫자 이외의 문자를 잡아줌

 

.               -> 아무 문자나 찾을 수 있다. (행의 끝에 오는 개행 문자는 제외)

 

(\d)\d\1  -> (\d)는 첫 번째 숫자를 찾은 후 그 값을 기억 예제에서는 3

                      \d는 다음 숫자를 찾고 기억해두지 않는다 예제에서는 0

                      \1은 기억해둔 숫자를 가리킨다. 예제에서는 3이다.

 

 

< 수량자 >  수량자 앞에는 무엇인가 있어야 한다. 없으면 에러남

?                -> ?는 하나 이하라는 뜻  -? 인 경우 하이픈이 한 번 나오거나 안 나온다는 말이다.

 -> 3?는 3이 한번 나오거나 안 나온다는 말

 -> [.-]? 는 .이나 - 이 한 번 이하로

 

+               -> +는 하나 이상이라는 뜻 -+ 인경우 하이픈이 하나 이상 나와야함

 -> 3+는 3이 한번 이상 나와야함

 

*               -> *는 0 이상이라는 뜻 -* 인경우

</수량자 >

 

\d{3}        -> 숫자가 3개 연속으로 붙어 있는거

 

                     

 

반응형
반응형

국내 전화번호

 

0[2-6]{1,2}(\)|-)?[2-9]\d{3,4}-?\d{4}

 

지역 번호는 0으로 시작하고 2~6까지의 숫자로 이뤄지며, 국번은 2~9 사이 숫자로 시작하며 세 자리 혹은 네자리이다.

 

1. 0으로 시작

2. 2~6 사이가 1개 이상 2개 이하

3. ) 또는 -가 있거나 없거나

4. 2~9사이 1개

5. 0~9사이가 3개 이상 4개 이하

6. 0~9 사이가 4자리

 

 

이메일 주소 확인

 

^[a-zA-Z0-9.-_]+@([a-zA-Z0-0-_]{2,63}\.)+[a-zA-Z]{2,4}$

 

1. ^문장의 시작부터 $ 끝까지 체크

2. 대소문자 구분 없이 a-z, 0-9, . ,-,_의 1개 이상

3. @

4. 대소문자 구분 없이 a-z, 0-9, . ,-,_의 2글자 이상 63자 이하의 글자가 오며 점(.)은 1개 이상

5. 대소문자 구분 없이 a-z의 2개 이상 4개 이상

 

 

IP 주소 체크

 

( ( 25[0-5] | 2[0-4][0-9] | [01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)

 

1. 250 ~ 251 또는 200 ~ 249 또는 0 ~ 199 \. 정확히 3번

2. 250 ~ 251 또는 200 ~ 249 또는 0 ~ 199  1번

 

URL

 

^https?://([\w-]+.)+(/[\w-./?&%=]*)?$

 

1. ^문장의 시작부터 $ 끝까지 체크

2. http로 시작하고 s는 있거나 없거나

3. :// 체크

4. zA-Z0-9등 \w에 매칭되는 문자와 -은 1번 이상

5. 점(.)

6. 4,5번의 조합이 1번 이상

7. /이후 \w에 매칭되는 문자와 -./?&%-조합의 0번 이상이 있거나 없거나

 

 

반응형
반응형

http://stackoverflow.com/questions/26595620/how-to-install-ruby-2-1-4-on-ubuntu-14-04 => 우분투 ruby 설치

http://qiita.com/y_matsuwitter/items/901065962edb7ea8c6ec => GEM path 설정

 

출처: http://neverstoplearning.tistory.com/entry/%EB%A1%9C%EA%B7%B8%EC%88%98%EC%A7%91%EA%B8%B0-fluentd-on-redhat-enterprise-linux-6

 

 

mysql 로 출력을 설정하기 위한 플러그인을 설치합니다.

 

# td-agent-gem install fluent-plugin-mysql

# td-agent-gem list --local | grep fluent-plugin-mysql

fluent-plugin-mysql (0.0.7)

 

 

 

데이터 베이스와 테이블을 생성합니다. 테스트니 그냥 컬럼 하나만 만듭니다.

 

# mysql -uroot

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database application_log;

mysql> use application_log;

mysql> CREATE TABLE `access_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `text` char(100) DEFAULT NULL,
  PRIMARY KEY (`id`)
);

 

 

이제 td-agent 설정 파일을 생성합니다.

 

 

# emacs /etc/td-agent/td-agent.conf 

 

 

아파치 로그에서 agent 값을 생성된 컬럼에 넣도록 합니다. 한 라인 전체를 넣을 수도 있습니다. (document 페이지에 가면 입력, 처리, 출력 관련 내용이 있습니다.) 

 

## read apache logs continuously and tags td.apache.access
<source>
  type tail                    # tail 명령어로 소스에서 로그를 가져옴
  format apache2         # 로그 포맷은 apache2
  path /var/log/httpd/access_log  # 로그 파일 위치
  pos_file /var/log/td-agent/apache.pos
  tag apache.access    # 태그 지정
</source>

## File output
## match tag=local.** and write to file
<match apache.access>
  type mysql                  # 출력은 mysql
  host localhost             # 호스트는 로컬
  #port 3306                   # 디폴트 3306
  database application_log      # DB명
  username root             # 유저
  #password ""              
  key_names agent         # 로그 추출 필드
  sql INSERT INTO access_log (text) VALUES (?)    # 실행 SQL
  flush_interval 1s          # 실행 간격
</match> 

 

 

이제 기본적인 설정이 모두 끝났습니다. 웹 서버와 fluentd 데몬을 구동합니다.

 

 

# /etc/init.d/httpd start

# /etc/init.d/td-agent start

 

 

td-agent 구동시 에러가 발생된다면 conf 파일에 잘못 쓴 부분이 있는지 확인합니다.

 

웹서버에 접근하면 아래와 같이 DB에 로그가 적재되게 됩니다.

 

 

이상. fluentd 시작하기 였습니다. ^^

 

 

반응형

+ Recent posts