로그인
Sign in
syslog.conf설정하기

syslog.conf는 syslog가 내보내는 메시지를 어떻게 처리할 것인가를 설정하는 syslog 컨피그 파일이다.

syslog.conf 화일은 일반적으로 /etc 디렉토리에 있다.
syslog.conf 는 텍스트로 구성되어 있으며 다음과 같은 형식을 가진다.

facility.level target

facility는 메시지를 보내는 프로그램의 유형으로서 다음과 같이 몇가지 종류가 있다. sendmail은 mail유형에 속한다.

--
facilitu   메시지를 발생시키는 프로그램 유형
user     사용자 프로세스
kern    커널이 발생한 메시지
mail    메일 시스템에서 발생한 메시지
daemon telnetd, ftpd등과 같이 데먼이 발생한 메시지
auth    login과 같이 인증프로그램유형이 발행한 메시지
lpr      프린터 유형의 프로그램이 발생한 메시지
news   유스넷 뉴스 프로그램 유형이 발생한 메시지
uucp    UUCP시스템이 발생한 메시지
cron    cron , at과 같은 프로그램이 발생한 메시지
local 0-7        여분으로 남겨둔 유형
mark   syslogd 에 의해 만들어지는 날짜유형
--

level은 위험의 정도를 가르키며 설정된 위험의 정도보다 높아야 에러를 내보낸다. 레벨의 유형은 다음과 같다.
--
level    의미
emerg  모든 사용자에게 전달되어야 할 위험한 상황
alert    즉각적인 조정이 있어야 할 상황
crit     약간 조정을 미루어도 급하지 않은 상황
err     기타 에러
warning 경고 메시지
notice   특별한 주의를 기하나 에러는 아닌 메시지
info     통계, 정보 메시지
debug   프고그램을 디버깅할 때 발생하는 메시지
none    메시지를 보내지 말라는 지시
--

target는 메시지를 어디에 보낼것인가를 지정하는 것이다. 타겟의 유형으로는 다음 네가지가 있다.
--
@host  host에 지정된 호스트로 메시지를 보냄
/file    file에 내용을 추가
user    지정된 사용자의 스크린으로 메시지를 보냄
*       현재 로긴되어 있는 모든 사용자의 스크린으로 메시지를 보냄
--

그럼 예를 하나 들어보자.
mail.info        /var/log/syslog


mail은 facility이고 info는 level, /var/log/syslog는 target을 가르킨다. 다시 말하면 메일에서 발생한 에러메세지가 info에서 지정한 위험보다 높거나 같을 겅우 /var/log/syslog의 파일에 내용을 적으라는 컨피그이다.
전형적인 /etc/syslog.conf를 살펴보자.

*.err;kern.debug;user.none        /dev/console
*.err;kern.debug;user.none        /var/adm/message
auth.notice                      @authhost
mail.info                        /var/log/syslog
*.emert;user.none                *

syslog.conf는 여러행의 facility.level로 구성되어 있으며 행은 ;문자로 구분되어 있다. 처음 두행은 모든facilty에 대해 err수준, 커널이 발생하는 메시지에 대해 debug레벨수준, user에서는 레벨0(레벨이 0이면 아무메세지도 없음)을 기준으로 해당레벨보다 높은 위험에 대해서만 스크린과 /var/adm/message에 기록하도록 하고 있다.

세 번째 행은 인증메세지를 (로긴이 실패하였거나 등등) authhost 라는 호스트에 보내도록 하고 있다.

네 번째는 메일유형, 즉 센드메일과 같은 프로그램이 발생한 메시지중 info이상의 위험이 있는 메시지를 /var/log/syslog에 기록하도록 하고 있다.

마지막 행은 모든 facility유형에 대해 emerg이상의 위험이 있을 때 user facility를 제외하고 로긴되어 있는 모든 사용자에게 기록하도록 하고 있다.

facility는 다음과 같이 구분할 수도 있다.

mail,daemon.info


이것은 다음과 같다.
mail.info;daemon.info


6-2-2 statistics
sendmail.cf에 statics를 지정하는 것으로 두 개가 있다.
처음에는 옵션사항으로 O StatusFile=/etc/sendmail.ct (=OS/etc/sendmail.st) 과 O LogLevel=9 (=OL9)으로 설정하는 부분이 있다.

sendmail.st 파일

센드메일을 보내고 받은 메일에 대해 자세한 정보를 기록해둔다. 이러한 정보를 기록할 파일을 지정할 때 옵션란에 O StatusFile=/etc/sendmail.st와 같은 행을 두어 센드메일이 통계에 관한 정보를 기록하도록 한다.

센드메일을 설치할 때 /etc/sendmail.st 파일이 없는 경우도 있다 이경우는 루트로 로긴해서 touch /etc/sendmail.st의 명령으로 파일을 생성하면 된다.

sendmail.st화일은 sendmail소스를 풀면 mailstats디렉토리가 생긴다.
BSD시스템을 제외하고는 Makefile.dist를 편집하여 make하면 mailstats라는
실행화일이 만들어 진다. 이 mailstats화일은 sendmail.st화일을 읽어 적절한 형태로 보여준다.

suny:~/sendmail-8.8.5/mailstats$ mailstats
Statistics from Sun Apr  6 14:59:38 1997
M msgsfr bytes_from  msgsto   bytes_to  Mailer
3   1082       4174K   2959      12684K  local
5   2453      12283K   1104       4511K  esmtp
========================================
T   3535      16457K   4063      17195K

M은 Mailer, msgsfr = message from, bytes_from=받은 메일의 크기, msgsto=messages to, bytes_to는 보낸 메일의 크기를 나타낸다. 위의 예에서 로컬메일러는 수신은 1082번에 크기는 4174킬로바이트를 수신하였고 보내는 메일은 2959번에 12684킬로바이트을 메일을 통해 보냈다는 것을 알수 있다.

mailstats은 sendmail.st화일의 내용을 보여주지만 sendmail.st화일의 크기를 0으로 만들지는 않는다. sendmail.st는 가만히 놔두면 계속 커지므로 mailstats로 확인한후 크기를 cp /dev/null /etc/sendmail.st 명령으로 0의 크기로 만들필요가 있다. 이와 같은 일은 cron을 이용하면 된다. (센드메일은 sendmail.st화일의 크기가 0이면 이때부터 다시 통계정보를 모집한다. )

다음과 같은 쉘프로그래밍을 하여 mailstats.script라는 파일로 실행속성을 주어 저장하자.

--
#!/bin/sh
ST=/etc/sendmail.st
MS=/usr/sbin/mailstats
if [ -s $ST -a -f $MS ]; then
        $MS | mail -s "Daily mail stats" postmaster
        cp /dev/null $ST
fi
exit 0
--


이 쉘스크립트를 실행시키면 우선 sendmail.st의 크기가 0인지 검사하여 0이 아니면 mailstats 프로그램을 실행하고 그 결과를 postmaster에게 보낸다. 다음 sendmail.st화일의 크기를 0으로 만들어 준다. 이 쉘스크립트 이름을 mailststs.script라고 하고 crontab에 다음행을 추가(crontab -e root 명령실행)한다.
0 0 * * * sh /usr/sbin/mailstats.script >/dev/null 2>&1



6-2-3 syslog가 내보낸 내용을 활용
syslog는 메일에 관해 여러 정보를 내보낸다. 이 정보를 자신의 취향에 알맞게 이용하면 메일 시스템을 관리하는데 매우 편리하다. 보통은 쉘스크립트로 충분한데 좀더 복잡한 프로그래밍을 하려면 perl을 이용하는게 좋다. (펼은 인터넷이 나오면서 유명해진 것으로 www.perl.com에 접속하면 많은 정보를 얻을 수 있다)

센드메일에서 넘어와 syslog가 기록하는 메시지는 다음과 같은 형식으로 되어있다.

month day time host sendmail[pid]: ident: from=sender, size=bytes,....

--
Apr 20 18:18:20 suny sendmail[30680]: SAA30680:
from=<owner-www-forum@www-kr.org>, size=1585, class=0, pri=31585, nrcpts=1,
msgid=<3359DA2F.2289@codinet.com>, proto=SMTP, relay=cair.kaist.ac.kr [143.248.186.2]
--


> 이를 이용하는 몇가지 프로그램이 있다.
ssl script

ssl 스크립트는 Tom Christiansen이 만들었으며 ftp://convex.com/pub/perl/script/ssl.Z에서 구할수 있다. 이것은 사용자별로 메일통계를 내준다. convex.com에 있는 버전은 8.8이전 버전을 기준으로 만들어서 사용하는데 에러가 난다. 새로운 버전은 ftp://ftp.his.com/pub/brad/sendmail/ssl 에서 찾을 수 있다. 사용방법은 ssl /var/adm/messages와 같이 지정하면 사용자별로 메일 통계가 나온다.

syslog-stat.pl

은 Paul Vixie가 만들었으며 syslog화일을 요일별로 관리할 경우(syslog.0 syslog.1.... syslog.6) 모든 syslog화일을 읽어 메일통계를 내준다.

메일통계는 센드메일 faq에 정확이 나온다.

Date: November 24, 1996
Subject: Q4.7 -- How can I summarize the statistics generated by

sendmail in the syslog?

이질문은 Brayan Costales가 쓴 센드메일 319페이지에 나온다.

syslog-stat.pl 스크립트의 수정버전은 ftp://ftp.his.com/pub/brad/sendmail/syslog_stat에 있다. 또한 ssl의 수정버전은 ftp://ftp.is.co.za/networking/mail/tools와 ftp://ftp.his.com/pub/brad/sendmail/ssl에서 구할수 있다. Bryan Beecher이 만든 프로그램이 있는데 이는 ftp://ftp.his.com/pub/brad/sendmail/smptstats에서 구할수 있다.

만일 POP통계에 관심이 있으면 ftp://ftp.his.com/pub/brad/sendmail/popstats에서 Bryan Beecher이 만든 프로그램을 구할 수 있다.

그 밖에 메일에 관해 새로운 프로그램이 있나 찾아보려면 ftp://ftp.nuri.net/pub/CPAN/scripts/mailstuff 에서 각종 정보를 구할수 있다.

또한 "Sendmail Statistics Project"가 있으며 웹주소는 http://www.josnet.se/projects/ssp로 접속하면 된다. 하지만 들어가보면 이 프로젝트가 활동을 안하는지 결과만 보여주고 만다.

[원문]

This question is addressed on page 319 of _sendmail_ by Bryan Costales.

An updated version of this syslog-stat.pl script (so that it understands the log format used in version 8 sendmail) is at <ftp://ftp.his.com/pub/brad/sendmail/syslog_stats>. The updated version of ssl has been uploaded to the SMTP Resources Directory (in <ftp://ftp.is.co.za/networking/mail/tools/>), as well as <ftp://ftp.his.com/pub/brad/sendmail/ssl>. There is also another program (written by Bryan Beecher) at <ftp://ftp.his.com/pub/brad/sendmail/smtpstats>.

If you're interested in summarizing POP statistics, there is <ftp://ftp.his.com/pub/brad/sendmail/popstats>, also written by Bryan Beecher.

To see what else is available today, check the Comprehensive Perl Archive Network <ftp://ftp.funet.fi/pub/languages/perl/CPAN/CPAN> or <ftp://ftp.cis.ufl.edu/pub/perl/CPAN/CPAN> for the site nearest you. For the scripts themselves, look under CPAN/scripts/mailstuff/ at any CPAN site. For more information, see the comp.lang.perl.* FAQs at <ftp://ftp.cis.ufl.edu:/pub/perl/faq/FAQ> or <ftp://rtfm.mit.edu:/pub/usenet/comp.lang.perl.*/>.

There is also the "Sendmail Statistics Project" which has a web page at <http://www.josnet.se/projects/ssp/>. Although they have examples online of what the output might look like, it now appears that this project is either dead or at least indefinitely on hold. Still, you may be able to talk to the authors in order to get what code from them you can.

If you're interested in using these kinds of tools to help you do some near real-time monitoring of your system, you might be interested in MEWS (Mail Early Warning System). From the README:

        If you've ever written a perl script to parse sendmail
        log files looking for errors, MEWS might be of interest to
        you. If you've ever thought about writing a perl script to
        munge sendmail log files, cringed a little and hurriedly
        came up with an excuse not to do it, read on.

        If you don't have a Solaris 2.5 machine, you can probably
        stop reading here.

        The Mail Early Warning System (MEWS) gives postmasters
        immediate notification of trouble sp
조회 수 :
3446
추천 수 :
11 / 0
등록일 :
2008.02.26
11:26:28 (*.236.3.225)
엮인글 :
http://bestceok.com/xe/index.php?mid=unix_com&document_srl=2735&act=trackback&key=cf7
게시글 주소 :
http://bestceok.com/xe/index.php?mid=unix_com&document_srl=2735
List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 자주 사용하는 명령어 제비게릴라 2019-06-27 179
72 console 에 뿌려지는 message를 file로 받고자 합니다. 하록 2008-03-04 550
» syslog.conf설정하기 하록 2008-02-26 3446
70 OS백업을 받을때 /data가 있는 쪽만 빼고 vg00전체를 다 받고자 할때... 하록 2008-02-13 487
69 ll 명령어로 알파벳 대소문자 구분없이 정렬해서 출력하기... 하록 2008-02-01 530
68 ndd로 fin_wait_2 를 지울때 "invalid argument" message나올때 하록 2008-02-01 906
67 glance 기간별 평균 구하기... 하록 2008-01-29 593
66 glance 한달 평균 구하기... 하록 2008-01-29 463
65 LVM 방법 하록 2007-12-18 1352
64 shell command상에서는 잘 돌아가는데 cron을 통하면 작업이 잘 안 될때.. 하록 2007-12-05 529
63 cron log file에 return code가 나오는데 code number 의 의미 하록 2007-12-05 695
62 tftp서버 구축하기 하록 2007-12-05 478
61 100BT card의 speed와 duplex mode를 바꾸는 방법 하록 2007-12-05 913
60 TCP error에는 어떤 것이 있고 그 의미 하록 2007-12-05 1081
59 netstat -a'로 보아 어떤 port는 fin_wait2에 빠져 사용할 수 없는데 조치방법 하록 2007-12-05 447
58 automatic ftp 를 설정하는 방법 하록 2007-12-05 407
57 Disk Array 1개에서 alter Path로 디스크가 2개 보일때 루트 미러링 잡는 방법 하록 2007-09-12 599
56 dd 사용법 [5] 하록 2007-08-13 1972
55 리눅스 rsh 설정 방법 하록 2007-03-05 3297
54 Trust system에서 패스워드 삭제... 하록 2007-02-15 638
53 LSOF 설치 및 사용가이드 하록 2006-12-04 766