rsyslog/tests/testsuites/omprog-feedback-bin.sh
Joan Sala c196e8f054 omprog: add feedback timeout and keep-alive feature
Restart the program if it does not respond within timeout.
New setting 'confirmTimeout' (default 10 seconds).

Allow the program to provide keep-alive feedback when a
message requires long-running processing.

Improve efficiency when reading feedback line (use buffer).

Retry interrupted writes/reads to/from pipe.

New setting 'reportFailures' for reporting error messages
from the program.

Report child termination when writing to pipe.

Minor refactor: renamed writePipe function to sendMessage,
renamed readPipe to readStatus.
2018-09-03 22:05:30 +02:00

34 lines
589 B
Bash
Executable File

#!/bin/bash
outfile=$RSYSLOG_OUT_LOG
status="OK"
echo "<= $status" >> $outfile
echo "$status"
retry_count=0
read line
while [[ -n "$line" ]]; do
message=${line//$'\n'}
echo "=> $message" >> $outfile
if [[ $message == *04* || $message == *07* ]]; then
if [[ $retry_count < 2 ]]; then
status="Error: could not process log message"
let "retry_count++"
else
status="OK"
retry_count=0
fi
else
status="OK"
fi
echo "<= $status" >> $outfile
echo "$status"
read line
done
exit 0