monit-general
[Top][All Lists]
Advanced

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

Re: advanced HTTP query (cookies)


From: Martin Pala
Subject: Re: advanced HTTP query (cookies)
Date: Fri, 26 Aug 2005 21:29:30 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050802 Debian/1.7.10-1



Ben Hartshorne wrote:
On Fri, Aug 26, 2005 at 06:25:23PM +0200, Martin Pala wrote:

Hi,

i think you can use monit's SEND/EXPECT statements - example usage:

--8<--
if failed host cave.persia.ir port 4040
   send "Open, Sesame!\r\n"
   expect "Please enter the cave\r\n"
   send "Shut, Sesame!\r\n"
   expect "See you later [A-Za-z ]+\r\n"
then restart
--8<--

It should be possible to write the send/expect sequence as http requests with the cookie in the http header where needed ...


Martin,

I was looking at that syntax, but the string I need to test for
'success' is buried further than 256 Bytes into the page.  I saw that
the SEND/EXPECT statements are good for protocol negotiation, but
getting the cookie to the web page is only the first part.  I actually
do use the SEND/EXPECT syntax for the back-end testing, because I need
to verify an XML schema.
Also, if I understand the SEND/EXPECT schema, even though it uses regexp
to match the incoming strings, I would still havet to code in pretty
much the entire page up to the string I'm looking for, wouldn't I?

So my understanding is that the SEND/EXPECT syntax won't be able to
solve my problem.
Thoughts?

I think it is possible to use it - the monit SEND statement will be very similar to your wget line.

Wget:
--8<--
wget --cookies=off --header "Cookie: sh3=id%3D1970583178430e5e1b0a3b72.85050652%3Bcv%3D2%3Brv%3D3d3b01f6%3B; sh2=db%3De8744%3Bcso%3D430e5fcd%3Bslu%3D430e5e1b%3Bref%3Dsh%3B" http://www.simplyhired.com/index.php?ds=sr\&mj=1
--8<--

Monit alternative (the EXPECT uses regular expression - for example string "SUCCESS" is expected somewhere in the response):
--8<--
if failed host www.simplyhired.com port 80
send "GET /index.php?ds=sr&mj=1 HTTP/1.0\r\nHost: www.simplyhired.com:80\r\nCookie: sh3=id%3D1970583178430e5e1b0a3b72.85050652%3Bcv%3D2%3Brv%3D3d3b01f6%3B; sh2=db%3De8744%3Bcso%3D430e5fcd%3Bslu%3D430e5e1b%3Bref%3Dsh%3B\r\n\r\n"
   expect "*SUCCESS*"
--8<--

(note that the SEND string should be on one line)


Another option could be to let the wget fetch the page regulary (as cronjob) and use monit file check's content test (new feature of upcomming monit-4.6).


Martin





reply via email to

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