Log file monitoring (check_logfiles) should print following line

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 1 or 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.

Many thanks!

Hi @hpreusse!

Sounds more complicated than patching/reporting to the plugin upstream.

Best,
A/K

I would not like to patch the upstream code to make sure new version does not destroy my integrations. Regarding reporting: do you have experiences in reporting bugs to upstream? I did not find a tracking system. Thanks!

Just search for the plugin name on GitHub.

I’v opened Multiple line output · Issue #67 · lausser/check_logfiles · GitHub. Let’s see if there will be progress.