Skip to content

Instantly share code, notes, and snippets.

@betagan
Created July 3, 2015 11:07
Show Gist options
  • Save betagan/3bf1356adb98b580e91a to your computer and use it in GitHub Desktop.
Save betagan/3bf1356adb98b580e91a to your computer and use it in GitHub Desktop.
test script to reproduce check_logfiles bug concerning wrong rotation handling for files with same timestamp
#!/bin/sh
CLCMD="./check_logfiles --logfile=my.log --rotation=my.log.gz --criticalpattern=ERROR"
echo ">>> cleaning up, removing my.log and my.log.gz, creating empty my.log and initialize run check_logfiles"
rm -f my.log.gz my.log
echo "OK some dummy text" > my.log
sleep 1
$CLCMD
echo ">>> append an ERROR line"
printf "ERROR dummy\n" >> my.log
sleep 1
echo ">>> running check_logfiles for the first time (should and does return CRITICAL)"
$CLCMD
echo ">>> performing log rotation and put one OK line in the new logfile"
gzip -c my.log > my.log.gz && echo "OK" > my.log
sleep 1
echo ">>> running check_logfiles for the second time (should and does return OK)"
$CLCMD
echo ">>> append a second OK line to the logfile"
printf "OK some dummy text\n" >> my.log
sleep 1
echo ">>> running check_logfiles for the third time (should return OK BUT DOES RETURN CRITICAL INSTEAD!!"
$CLCMD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment