'logwatch'에 해당되는 글 2건

CentOS 7.x logwatch 로그분석 알림 유틸



리눅스의 로그를 분석해서 에러정보나 ssh 접속시도와 같은 정보를 매일 오전에 메일로 보내주는 유틸입니다.


하드디스크 용량 정보도 있어서 유용하다면 유용하고 메일을 하루에 한통씩을 받아야 하는 어쩌면 귀찮기도 합니다.


설치는 방법은 아래와 같습니다.


# yum install logwatch


설정은 크게 바꿀건 없고 메일 주소만 변경해주면 됩니다.


# vi /usr/share/logwatch/default.conf/logwatch.conf

MailTo = root


root 대신에 실제 메일주소를 입력하면 됩니다.


/etc/cron.daily 크론에 등록이 되어 있어서 매일 하루에 한번씩 실행이 됩니다.


강제로 실행하는 방법은 아래 처럼 하면 됩니다.


# /usr/sbin/logwatch --output mail


위의 명령어를 실행하면 메일로 아래 처럼 리포트 메일이 날아옵니다.


################### Logwatch 7.4.0 (03/01/11) #################### 

        Processing Initiated: Fri Mar 24 16:27:20 2017

        Date Range Processed: yesterday

                              ( 2017-Mar-23 )

                              Period is day.

        Detail Level of Output: 0

        Type of Output/Format: mail / text

        Logfiles for Host: conoha.ivps.kr

 ################################################################## 

 

 --------------------- httpd Begin ------------------------ 


 Connection attempts using mod_proxy:

    1.162.172.194 -> mx-tw.mail.gm0.yahoodns.net:25: 231 Time(s)

    195.154.226.17 -> lqak.euw1.lol.riotgames.com:443: 3 Time(s)

 

 A total of 3 sites probed the server 

    183.129.160.229

    60.191.38.77

    60.191.38.78

 

 Requests with error response codes

    400 Bad Request

       lqak.euw1.lol.riotgames.com:443: 3 Time(s)

    404 Not Found

       /favicon.ico: 14 Time(s)

       /robots.txt: 8 Time(s)

       /current_config/passwd: 4 Time(s)

       /current_config/Account1: 3 Time(s)

       /admin/i18n/readme.txt: 2 Time(s)

       /auto/4_0235.html: 1 Time(s)

       /auto/8_6858.html: 1 Time(s)

       /cgi-bin/php?-d+allow_url_include%3Don+-d+ ... atus_env%3D0+-n: 1 Time(s)

       /hot/news/0_3783.html: 1 Time(s)

       /html/5_8085.html: 1 Time(s)

       /html/7_7733.html: 1 Time(s)

       /media/7_4339.html: 1 Time(s)

       /phpmyadmin: 1 Time(s)

       /pic/news/5_4026.html: 1 Time(s)

       /shehui/6_1375.html: 1 Time(s)

       /tech/4_7891.html: 1 Time(s)

       /yule/1_6028.html: 1 Time(s)

    405 Method Not Allowed

       /webdav/: 3 Time(s)

 

 ---------------------- httpd End ------------------------- 


 

 --------------------- pam_unix Begin ------------------------ 


 sshd:

    Authentication Failures:

 

 vsftpd:

    Authentication Failures:

       unknown (202.107.219.49): 1 Time(s)

       unknown (39.33.123.228): 1 Time(s)

    Invalid Users:

       Unknown Account: 2 Time(s)

 

 

 ---------------------- pam_unix End ------------------------- 


 

 --------------------- Connections (secure-log) Begin ------------------------ 


 

 **Unmatched Entries**

 

 ---------------------- Connections (secure-log) End ------------------------- 


 

 --------------------- SSHD Begin ------------------------ 


 

 SSHD Killed: 2 Time(s)

 

 SSHD Started: 4 Time(s)

 

 Failed logins from:

 

 Illegal users from:

    undef: 1 time

 

 Login attempted when not in AllowUsers list:

 

 Users logging in through sshd:

 

 

 Received disconnect:

    11: disconnected by user : 17 Time(s)

 

 **Unmatched Entries**

 error: key_from_blob: can't read key type : 2 time(s)

 error: buffer_get_string_ret: bad string length 67108871 : 2 time(s)

 

 ---------------------- SSHD End ------------------------- 


 

 --------------------- Disk Space Begin ------------------------ 


 Filesystem      Size  Used Avail Use% Mounted on

 /dev/vda2        20G   15G  4.4G  77% /

 devtmpfs        236M     0  236M   0% /dev

 

 

 ---------------------- Disk Space End ------------------------- 


 

 ###################### Logwatch End ######################### 


조금 가공한 로그입니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

Logwatch Connection attempts using mod_proxy



로그와치 리포트에 아래와 같은 내용이 나오면 아파치 설정에서 mod_proxy 설정을 확인 하자.


 Connection attempts using mod_proxy:

    111.248.xxx.xxx -> 163mx03.mxmail.netease.com:25: 1 Time(s)



▶ httpd.conf 아파치 모듈 주석 처리 방법


#LoadModule proxy_module modules/mod_proxy.so

#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

#LoadModule proxy_http_module modules/mod_proxy_http.so

#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

#LoadModule proxy_connect_module modules/mod_proxy_connect.so


위의 모듈을 주석처리하면 된다.

그리고 아파치를 재시작 하여야 한다.



▶ httpd.conf CONNECT 막는 방법


<Location />

<Limit CONNECT>

Order deny,allow

Deny from all

</Limit>

</Location>


위 내용을 추가한 뒤에 아파치를 재시작 하면 된다.



위의 방법으로 처리 한 뒤의 로그는 아래 처럼 나온다.


mx-tw.mail.gm0.yahoodns.net 220.132.81.117 - - [05/Aug/2016:09:30:10 +0900] "CONNECT mx-tw.mail.gm0.yahoodns.net:25 HTTP/1.0" 200 73 "-" "-"

mx-tw.mail.gm0.yahoodns.net 220.132.81.117 - - [05/Aug/2016:09:51:39 +0900] "CONNECT mx-tw.mail.gm0.yahoodns.net:25 HTTP/1.0" 403 4897 "-" "-"


200 코드 값이 403 으로 바뀌었다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,