monit

monit check file for removed content


I'm trying to check some config, which should contain combination: "^UseBridges". And i know, that file can be changed after somewhat editing via admin UI, but UI doesn't support feature i need.

So i'm trying to write monit check for it, so it will check config, and if confeg resetted, it will add some needed strings to the end of config.

I've tried next rules:

check file torrc with path "/root/t"                                                                                       if content != '^UseBridges' then alert

and

check file torrc with path "/root/t"                                                                                       if not match '^UseBridges' then alert

Both syntaxes looks correct, but doesn't work the way i expect. If i remove "!" or "not" - it works as expected. It finds string and execute action.

But if i want to check that removal of string - nothing happens.

What is wrong? Or monit doesn't support that?


Solution

  • The Monit does not support that.

    But if i want to check that removal of string - nothing happens.

    What is wrong? Or monit doesn't support that?

    Monit read the content of the file and keep the position of the last line in mind. With the next cycle additional lines are read etc.. If the file size became smaller, Monit start reading from the beginning. Monit can not find deleted lines, because Monit does not compare file, Monit check the occurrence of a string only.