syslogを1箇所で管理したいため、rsyslogに受信設定を行う。
# diff rsyslog.conf rsyslog.conf.org
18,20c18,20
< $ModLoad imudp
< $UDPServerRun 514
< $AllowedSender UDP ,127.0.0.1,192.168.10.0/24 --- > #$ModLoad imudp
> #$UDPServerRun 514
>
22,24c22,24
< $ModLoad imtcp
< $InputTCPServerRun 514
< $AllowedSender TCP, 127.0.0.1.192.168.10.0/24 --- > #$ModLoad imtcp
> #$InputTCPServerRun 514
>
rsyslog設定を読み直す。
# killall rsyslogd
rtx1200のログを転送する設定
syslog host [rsyslog_host ip address]
syslog facility local6
syslog notice on
転送されたlogは、全て/var/log/syslogに出てくるので、切り分けをする。
mkdir -p /var/log/recived
chown syslog:adm /var/log/recived
# vi 10-reviced.conf
:hostname, isequal, "router.home.local" /var/log/recived/rtx1200.log
& ~ ← /var/log/syslogに記録したくない為
# killall rsyslogd
切り分けできているか、確認
tail -f /var/log/recived/rtx1200.log
Apr 14 15:50:34 router.home.local [IKE] receive heartbeat message from xxx.xxx.xxx.xxx
Apr 14 15:50:34 router.home.local [IKE] still connected : no message
Apr 14 15:50:34 router.home.local [IKE] receive heartbeat message from xxx.xxx.xxx.xxx
Apr 14 15:50:34 router.home.local [IKE] still connected : no message
Apr 14 15:50:34 router.home.local [IKE] receive heartbeat message from xxx.xxx.xxx.xxx
Apr 14 15:50:34 router.home.local [IKE] still connected : no message
つらつら受信している。
本体ログには、記録されていない。
logrotateの設定
/var/log/recived/*.logが新たに増えたので、logrotateに加える。
cat /etc/logrotate.d/recived
/var/log/recived/*.log {
weekly
missingok
rotate 52
compress
notifempty
create 640 syslog adm
sharedscripts
}
logrotateはcronで動いているので、cronを再起動
service cron restart
動作確認をする。
logrotate -d /etc/logrotate.d/recived
# logrotate -d /etc/logrotate.d/recived
reading config file /etc/logrotate.d/recived
Handling 1 logs
rotating pattern: /var/log/recived/*.log weekly (52 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/recived/rtx1200.log
log does not need rotating
まだlogが溜まってないから、rotationする必要が無いと。
暫くしたら、rotateしたlogがあるか、確認してみる。