howdy folks,
I want to monitor a log file for a specific event and grab an iostat the moment the event is detected. The bash function below works fine until the file gets renamed (logfile.nnn.txt), gzipped (logfile.nnn.txt.gz), moved (mv logfile.nnn.txt.gz ./backup_logs) and re-created (touch logfile.txt). Once it's truncated it ceases to work.
tail -f logfile.txt | while read INFILE
do
[[ "${INFILE}" == *"event_12345"* ]]
&& iostat -t >> iostat_when_process_times_out.txt
&& beep
done
Need solution so that I can still monitor the log for the event and capture an iostats when it happens. Any help would be greatly appreciated. Thanks.