Search code examples
linuxmonit

What am I doing wrong in monit syntax with regex?


In my monitrc i wrote next:

check file mysite.com-access.log with path /var/log/apache2/mysite.com-access.log
        if content = "\/1.[01]\" 4(\d){2}" then alert

But the systemctl status monit.service says I have an error in syntax:

extsites monit[19043]:  * Starting daemon monitor monit
extsites monit[19043]: /etc/monit/monitrc:305: syntax error '\d'
extsites monit[19043]:    ...fail!

Earlier I put "\/1.[01]\" [45](\d){2}", but error in syntax was in '[45]'.

What am I doing wrong? All my regex was right in https://regex101.com/.

Update: I corrected my string as if content = "^\/1\.[01]\" [45](\d){2}" then alert but syntax error there is still.


Solution

  • It seems we should use single quotes instead double.