We have the request to not only print the line, which contains the matching pattern, but the following / preceding line too. check_logfiles does not seem to support this out of the box.
Our current idea is
- run a pre-check and a post-check script, which reads the byte position before and after the check from the seek file.
- gather the checked part from the log using
tail -c (..)and
head -c (..)and using the file positions from above.
- feed the result to
grep -A 1or
grep -B 1.
Could this work? Are there more elegant solution, e.g. by using a different command / plugin? We assume a log file, which is growing slowly and does not rotate.