squidclient HTTP request produces syntax error

Issue #586 resolved
Iain Elder
created an issue

I am trying to restart the squid service when it becomes unresponsive by simulating squidclient in a protocol check.

In verbose mode squidclient prints the HTTP request before the response.

$ /usr/local/squid/bin/squidclient -v mgr:info
Request:
GET cache_object://localhost/info HTTP/1.0
Host: localhost
User-Agent: squidclient/3.5.20
Accept: */*
Connection: close


.
HTTP/1.1 200 OK
[response truncated]

The control file squid.monitrc looks like this:

check process squid
  pidfile /usr/local/squid/var/run/squid.pid
  start program = "/etc/init.d/squid start"
    timeout 240 seconds
  stop program = "/etc/init.d/squid stop"
    timeout 240 seconds
  if failed
    port 3128
    protocol http
      http headers [
        Host: localhost,
        User-Agent: squidclient/squidclient/3.5.20,
        Accept: */*,
        Connection: close ]
    request "cache_object://localhost/info"
    then restart

The if failed clause of the check process statement should produce the same request and restart squid if it doesn't respond normally.

Instead it produces a syntax error:

$ sudo monit validate
/etc/monit/conf.d/squid.monitrc:15: syntax error '"cache_object://localhost/info"'

I am testing with monit 5.16 on Ubuntu 16.04. I know monit 5.16 is not in the version list, but it is the latest version packaged by Ubuntu. I don't see anything that would address this in the change log.

Comments (4)

  1. Tildeslash repo owner

    Fixed: Issue #586: HTTP protocol test: Support URL string as custom request to allow monitoring HTTP proxy. Example for testing Squid: if failed port 3128 protocol http request "cache_object://localhost/utilization" then alert

    → <<cset a53f7634d02d>>

  2. Tildeslash repo owner

    Fixed the problem in next Monit release (5.22.0), you can test the development snapshot if you want:

    wget https://bitbucket.org/tildeslash/monit/get/master.tar.gz
    tar -xzf master.tar.gz
    cd tildeslash*
    ./bootstrap
    ./configure
    make
    

    Best regards, The Monit team

  3. Iain Elder reporter

    Appears to work now. Thanks for the quick response.

    On a fresh Ubuntu VM I had to install these packages to test the snapshot:

    sudo apt install libtool \
                     m4 \
                     automake \
                     bison \
                     flex \
                     libpam0g-dev
    
  4. Log in to comment