monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Not using method "HEAD" for connection testing


From: Martin Pala
Subject: Re: Not using method "HEAD" for connection testing
Date: Thu, 28 Jul 2016 14:49:59 +0200

Hello Marcus,

the send/expect statement is not allowed in the http protocol context (it is 
part of "generic" protocol test only), but monit didn't throw a syntax error in 
such case (fixed: https://bitbucket.org/tildeslash/monit/commits/27210ed610ba/).

Regarding the HEAD vs. GET method ... the http protocol test uses the HEAD 
method unless the content test or content checksum is set as part the http 
protocol - the the GET is used automatically, as the content is required for 
these tests.

We can implement a new option for the http protocol, which will allow to 
override the http method (such as GET/POST), even if no content is required 
automatically.

As a workaround you can use the send/expect test to implement simple HTTP 
protocol check, for example:

       if failed
          port 80
          send "GET / HTTP/1.1\r\nHost: www.mydomain.com\r\n\r\n"
          expect "HTTP/[0-9\.]{3} 200.*"
       then alert

Best regards,
Martin




> On 28 Jul 2016, at 13:07, Marcus Mülbüsch <address@hidden> wrote:
> 
> Hello list,
> 
>   when monit does connection testing it uses the method "HEAD", which is fine 
> for it causes less traffic.
> 
>   However, some services don't send http-headers, so this method will fail.
> 
>   For example, when checking http-replicator 
> (https://sourceforge.net/projects/http-replicator/) with
> 
>> if failed
>>        port 8080
>>        protocol http
>> then alert
> 
>  http-relicator responds with a 503 and monit raises an alarm. Here is its 
> logfile:
> 
>>  HEAD / HTTP/1.1
>>  connection: close
>>  host: localhost:8080
>>  accept: */*
>>  user-agent: Monit/5.17.1
>> 
>> 27 Jul 2016 16:54:51 DEBUG: HttpClient 1 received header:
>> 
>>  HTTP/1.1 503 Service Unavailable
>>  date: Wed, 27 Jul 2016 14:54:51 GMT
>>  connection: close
> 
>   I changed the method by sending a "GET", so http-replicator responds with 
> something (if running) and monit alerts only on true failures:
> 
>> # !!! use 'send "GET"...' else monit uses method "HEAD" which 
>> http-replicator does not respond well to!
>> if failed
>>        port 8080
>>        protocol http
>>        send "GET / HTTP/1.1"
>> then alert
> 
>   Is there a better way to achieve this?
> 
>   I now have the problem that I want to monitor the alarm-log of my 
> innovaphone telephone system which is readable via authenticated https and 
> responds with an xml file. So to access the alarm-log I use a monit 
> configuration of:
> 
>> check host pbx with address 11.22.33.44
>> if failed
>>        port 443
>>        protocol https
>>        request "/LOG0/FAULT/mod_cmd.xml?cmd=xml-alarms"
>>        use http headers [Authorization: Basic blabla==]
>>        send "GET / HTTP/1.1"
>>        with content != 'type="alarm"'
>> then alert
> 
>   However, that doesn't work as expected.
> 
>   If I drop the "send" line, the telephony system responds with a 404 
> (there's no header in the xml).
> 
>   If I use the send line it seems as monit does not evaluate the content?
> 
>   I artificially created an alarm and the system now responds with
> 
> https://11.22.33.44/LOG0/FAULT/mod_cmd.xml?cmd=xml-alarms
> 
>> <alarms>
>>      <fault type="alarm" severity="1" active="true" code="0x00010002" 
>> date="1469703580" time="28.07.2016-12:59:40" xsl="fault_phone.xsl" 
>> handle="744">
>>              <text>Registration down (timeout)</text>
>>              <source>PHONE/SIG/REG2</source>
>>              <remote addr="1.2.3.4" name="IP241-ab-cd-ef"/>
>>      </fault>
>> </alarms>
> 
>   However, monit (given the above configuration) does not raise an alarm? Am 
> I doing something wrong, or is monit at fault here?
> 
> Marcus
> 
> 
> 
> --
> To unsubscribe:
> https://lists.nongnu.org/mailman/listinfo/monit-general




reply via email to

[Prev in Thread] Current Thread [Next in Thread]