我有一个Proftpd v1.3.2服务器,我需要将每个日志(系统日志+ auths日志+ xferlogs )发送到远程系统日志服务器。 它适用于系统+授权日志。 但是,即使从configuration文件中删除了“ TransferLog ”,Proftpd仍然会打开/var/log/xferloglogging转移(我使用lsof进行检查),并向syslog服务器(我使用tcpdump进行检查)发送任何内容。
如何告诉proftpd将xferlogs发送到远程系统日志服务器?
好的,我find了一个解决scheme:使用fifo。 在/etc/proftpd/proftpd.conf :
#SystemLog /var/log/proftpd/proftpd.log #ControlsLog /var/log/proftpd/controls.log TransferLog /var/log/xferlog.fifo
然后 :
mknod /var/log/xferlog.fifo p chmod 666 /var/log/xferlog.fifo
还有一个像这样的Perl脚本(从networking上发现的几个脚本中得到启发)在另一端倾听:
#!/usr/bin/perl -w use strict; use File::Basename qw(basename); use Sys::Syslog qw(:DEFAULT setlogsock); $|=1; my $fifo_file = "/var/log/xferlog.fifo"; my $syslog_facility = 'daemon'; my $syslog_level = 'info'; my $program = "xfer_ftp"; unless (-p $fifo_file) { unlink $fifo_file; system('mknod', $fifo_file, 'p') && die "can't mknod $fifo_file: $!"; system('chmod', '666', $fifo_file) && die "can't chown $fifo_file: $!"; } my $fifo_fh; open($fifo_fh, "+< $fifo_file") or die "The FIFO file \"$fifo_file\" is missing, and this program can't run without it.:$!"; setlogsock 'unix'; openlog($program, 'pid', $syslog_facility); # just keep reading from the fifo and processing the events we read while (<$fifo_fh>) { chomp; syslog($syslog_level, $_); } closelog(); # should never really come down here ... close $fifo_fh; exit(0);
如果你有一个更清洁的解决scheme… 🙂
你可能正在使用标准的rsyslog。 我build议看看使用syslog-ng,你可以很好地控制你的日志。
这里是我用于远程日志logging的一个例子。 更重要的是,使用TCP也可以使你的日志隧道更复杂一些,但是显示出灵活性。
如果不需要,filter可以控制从日志中提取的内容,或者将某些types过滤到某些文件。 以下示例通常会将所有日志logging为date格式,但远程发送副本。
希望这可以帮助。
@version: 3.0 #First, set some global options. options { long_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no); owner("root"); group("adm"); perm(0640); stats_freq(0); bad_hostname("^gconfd$"); keep_hostname(yes); check_hostname(yes); }; source inputs { file("/proc/kmsg" program_override("kernel: ")); unix-stream("/dev/log"); internal(); udp(); tcp(max_connections(100)); }; destination remote { udp("remotesyslog.serversomewhere.com" port(514)); }; destination logpile { file("/var/log/eit/$YEAR-$MONTH-$DAY/$FACILITY" owner(root) group(root) perm(0600) create_dirs(yes) dir_perm(0700)); }; log { source(inputs); destination(logpile); destination(remote); };