mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-16 12:10:46 +01:00
When a to-be-monitored file is being rotated, some messages may be lost or duplicated. In case of duplication, many file lines may be duplicated depending on actual timing. The whole bug was primarily timing depenedent in general. It most often was visible in practice when the monitored file was very frequently rotated (we had some report with every few seconds). Note that while we try hard to not lose any messages, input file rotation always has some loss potential. This is inevitable if the monitored file is being truncated. Also note that this bugfix affects imfile, only. It has nothing to do and no relation to rsyslog output files being rotated on HUP. closes: https://github.com/rsyslog/rsyslog/issues/4797
83 lines
2.1 KiB
Bash
Executable File
83 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# This is part of the rsyslog testbench, licensed under ASL 2.0
|
|
. $srcdir/diag.sh check-inotify-only
|
|
. ${srcdir:=.}/diag.sh init
|
|
check_command_available logrotate
|
|
export NUMMESSAGES=10000
|
|
export RETRIES=50
|
|
|
|
# Write logrotate config file
|
|
echo '"./'$RSYSLOG_DYNNAME'.input*.log"
|
|
{
|
|
#daily
|
|
rotate 60
|
|
missingok
|
|
notifempty
|
|
sharedscripts
|
|
postrotate
|
|
kill -HUP $(cat '$RSYSLOG_DYNNAME'.inputfilegen_pid)
|
|
endscript
|
|
#olddir /logs/old
|
|
|
|
}' > $RSYSLOG_DYNNAME.logrotate
|
|
|
|
|
|
generate_conf
|
|
add_conf '
|
|
$WorkDirectory '$RSYSLOG_DYNNAME'.spool
|
|
|
|
global( debug.whitelist="on"
|
|
debug.files=["imfile.c", "stream.c"]
|
|
)
|
|
|
|
module(load="../plugins/imfile/.libs/imfile" mode="inotify" PollingInterval="2")
|
|
|
|
input(type="imfile" File="./'$RSYSLOG_DYNNAME'.input*.log" Tag="file:"
|
|
Severity="error" Facility="local7" addMetadata="on" reopenOnTruncate="on")
|
|
|
|
$template outfmt,"%msg:F,58:2%\n"
|
|
if $msg contains "msgnum:" then
|
|
action(type="omfile" file="'$RSYSLOG_OUT_LOG'" template="outfmt")
|
|
'
|
|
startup
|
|
|
|
./inputfilegen -m $NUMMESSAGES -S 5 -B 500 -f $RSYSLOG_DYNNAME.input.log &
|
|
INPUTFILEGEN_PID=$!
|
|
echo "$INPUTFILEGEN_PID" > $RSYSLOG_DYNNAME.inputfilegen_pid
|
|
|
|
|
|
|
|
./msleep 1
|
|
logrotate --state $RSYSLOG_DYNNAME.logrotate.state -f $RSYSLOG_DYNNAME.logrotate
|
|
./msleep 20
|
|
echo INPUT FILES:
|
|
ls -li $RSYSLOG_DYNNAME.input*
|
|
logrotate --state $RSYSLOG_DYNNAME.logrotate.state -f $RSYSLOG_DYNNAME.logrotate
|
|
./msleep 20
|
|
echo INPUT FILES:
|
|
ls -li $RSYSLOG_DYNNAME.input*
|
|
logrotate --state $RSYSLOG_DYNNAME.logrotate.state -f $RSYSLOG_DYNNAME.logrotate
|
|
echo INPUT FILES:
|
|
ls -li $RSYSLOG_DYNNAME.input*
|
|
echo ls ${RSYSLOG_DYNNAME}.spool:
|
|
ls -li ${RSYSLOG_DYNNAME}.spool
|
|
echo INPUT FILES:
|
|
ls -li $RSYSLOG_DYNNAME.input*
|
|
|
|
# generate more input after logrotate into new logfile
|
|
#./inputfilegen -m $TESTMESSAGES -i $TESTMESSAGES >> $RSYSLOG_DYNNAME.input.1.log
|
|
#ls -l $RSYSLOG_DYNNAME.input*
|
|
|
|
#msgcount=$((2* TESTMESSAGES))
|
|
#wait_file_lines $RSYSLOG_OUT_LOG $msgcount $RETRIES
|
|
wait_file_lines
|
|
|
|
touch $RSYSLOG_DYNNAME.input.log
|
|
./msleep 1000
|
|
|
|
shutdown_when_empty
|
|
wait_shutdown
|
|
seq_check
|
|
#seq_check 0 $TESTMESSAGESFULL
|
|
exit_test
|