Operating System - Microsoft
1753804 Members
7177 Online
108805 Solutions
New Discussion юеВ

Re: monitoring HTTP GET and HTTPS - 200

 
SOLVED
Go to solution
James R. Ferguson
Acclaimed Contributor

Re: monitoring HTTP GET and HTTPS - 200

Hi (again) Alvi:

> The following, a local site with no security restrictions, came back successfully.

So it appears that you may need to consider firewall settings. My Perl script has no problems in UNIX or Windows (as one might expect).

You might need to set your 'http_proxy' environment variable to enable the Perl script to offer its service.

Regards!

...JRF...
Omar Alvi_1
Super Advisor

Re: monitoring HTTP GET and HTTPS - 200

Hi,

Found LWP quite interesting.

Following the script modified to include the proxy setting, as adding the http_proxy environent variable had no impact on this script.

---------------

# cat ./probeurl
use strict;
use warnings;
use LWP::UserAgent;

my $wsr = LWP::UserAgent -> new;
$wsr -> timeout( 20 );

$wsr->proxy(['http', 'ftp','https'], 'http://192.168.5.39:8080/');

my $url = shift or die "URL expected\n";
my $useragent = LWP::UserAgent->new;

my $request = HTTP::Request->new( HEAD => $url );
my $response = $useragent->request($request);

print $response->status_line, "\n";
print $response->is_success, "\n";

-------------

Had some limited success but still getting the timeout errors for most websites. There was success as before for the internal websites.

The thing is that the external websites (behind proxy) are givign time outs and not authenitcation or forbidden messages.

C:\SCRIPTING>urltestv4.pl http://www.google.com
500 Can't connect to www.google.com:80 (connect: timeout)

Lookin forward to your support

Thanks and regards,

-Alvi

Omar Alvi_1
Super Advisor

Re: monitoring HTTP GET and HTTPS - 200

Additonally, after setting the http_prox variable, wget worked fine for a while. But now it returns proxy authentication errors.

Using Options without quotes

C:\Program Files\GnuWin32\bin>wget http://www.google.com --proxy-user=oalvi --pr
oxy-passwd=xxxxxx
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
--2009-07-08 16:14:00-- http://www.google.com/
Connecting to 192.168.5.39:8080... connected.
Proxy request sent, awaiting response... 407 Proxy Authentication Required
2009-07-08 16:14:00 ERROR 407: Proxy Authentication Required.

Using Options with quotes

C:\Program Files\GnuWin32\bin>wget http://www.google.com --proxy-user="domain\oalvi
" --proxy-passwd="xxxxxx"
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
--2009-07-08 16:15:22-- http://www.google.com/
Connecting to 192.168.5.39:8080... connected.
Proxy request sent, awaiting response... 403 Forbidden
2009-07-08 16:15:22 ERROR 403: Forbidden.



Some suiccess with LWP in that the followingg was successful. Here, I have success whether proxy is set or not.

C:\SCRIPTING>urltestv4.pl ftp://www.hp.com
200 OK
1

James R. Ferguson
Acclaimed Contributor

Re: monitoring HTTP GET and HTTPS - 200

Hi (again) Alvi:

> Had some limited success but still getting the timeout errors for most websites. There was success as before for the internal websites.

The default timeout is 180 (seconds). You might try increasing your value of 20 and see if you have better success.

Regards!

...JRF...



Omar Alvi_1
Super Advisor

Re: monitoring HTTP GET and HTTPS - 200

Hi JRF ...

Appreciate your persistence in assistance.

I ran it mostly with the 180 default timeout - it was still timing out. I put it to 20 only to reduce my troubleshooting time when I was trying out different stuff.

I've tried the proxy, by hardcoding as well as by passing from the environment - but no success.

Regards,

-Alvi
Omar Alvi_1
Super Advisor

Re: monitoring HTTP GET and HTTPS - 200

Well, it turned out to be some issues with the code.

The proxy was needed, but I had a variable too many and wasn't using the variable I had defined with the proxy.

Below the correct code with proxy

---------
# !C:\Perl\bin

use strict;
use warnings;
use LWP::UserAgent;

my $url = shift or die "URL expected\n";
my $useragent = LWP::UserAgent->new;

$useragent->proxy(['http', 'ftp','https'], 'http://192.168.5.39:8080/');
$useragent -> timeout( 20 );

my $request = HTTP::Request->new( HEAD => $url );
my $response = $useragent->request($request);

print $response->status_line, "\n";
print $response->is_success, "\n";
print $useragent->proxy('http'),"\n";
---------

Regards,

-Alvi