Syntax error when I add content to process check

Issue #599 closed
Aditya created an issue

I have the same issue as https://bitbucket.org/tildeslash/monit/issues/500/monit-network-check-should-allow-other where i need to make a GET call instead of HEAD. I have tried with the below line in monitrc file

if failed host localhost port 8000 protocol http request "/configs" with content "configs" then restart

The full config is below

check process config-service with pidfile /var/run/config-service.pid
   group vcbm
   start program = "/bin/systemctl start config-service.service"
   stop  program = "/bin/systemctl stop config-service.service"
   if failed host localhost port 8000 protocol http request "/configs" with content "configs" then restart
   if 10 restarts within 10 cycles then unmonitor

But I get an error ' /etc/monitrc:41: syntax error '"configs"' '

What am I doing wrong? I am using monit 5.21 version

As a follow up question, I only care for a 200 status to ensure that the service is started. Is there a way to change the content value to a regex like .* ?

Comments (4)

  1. Tildeslash repo owner

    The content check requires an operator, which is missing in your config, it should look like this:

    if failed host localhost port 8000 protocol http request "/configs" with content = "configs" then restart
    

    The Monit 5.22.0 added support for method specification, so you can simplify the configuration like this if you don't need to check the content:

    if failed port 8000 protocol http method get then restart
    
  2. Log in to comment