几乎尝试了所有事情,但仍无法找到问题的解决方案,所以想要在这种情况下寻求帮助:
我已经根据日志文件的大小配置了logrotate(v.3.7.8):
/home/test/logs/*.log {
missingok
notifempty
nodateext
size 10k
rotate 100
copytruncate
}
日志的轮换仅基于大小,只要消息到达rsyslog deamon(v.5.8.10),就会调用。配置rsyslog:
$ModLoad omprog
$ActionOMProgBinary /usr/local/bin/log_rotate.sh
$MaxMessageSize 64k
$ModLoad imuxsock
$ModLoad imklog
$ModLoad imtcp
$InputTCPServerRun 514
$template FORMATTER, "%HOSTNAME% | %msg:R,ERE,4,FIELD:(.*)\s(.*)(:::)(.*)--end%\n"
$ActionFileDefaultTemplate FORMATTER
$Escape8BitCharactersOnReceive off
$EscapeControlCharactersOnReceive off
$SystemLogRateLimitInterval 0
$SystemLogRateLimitBurst 0
$FileOwner test
$FileGroup test
$DirOwner test
$DirGroup test
# Log each module execution to separate log files and don't use the prepending module_execution_ in the log name.
$template CUSTOM_LOGS,"/home/test/logs/%programname:R,ERE,1,FIELD:^module_execution_(.*)--end%.log"
if $programname startswith 'module_execution_' then :omprog:
if $programname startswith 'module_execution_' then ?CUSTOM_LOGS
& ~
omprog调用的脚本只运行logrotate,为了测试目的,将新行发送到logrot文件:
#!/bin/bash
echo "1" >> /home/test/logrot
/usr/sbin/logrotate /etc/logrotate.conf -v
如何重现:
执行:
for i in {1..50000};做logger -t" module_execution_test" "测试消息&#34 ;;完成的;
检查:
wc -l / home / test / logrot 它会增长一段时间,但即使消息仍然到达也会停止(在旋转停止发生的时候完全挂起) - 这意味着rsyslog不再调用外部脚本
所以IMO看起来像是rsyslog或omprog插件中的一个错误。知道发生了什么事吗?
BR