<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Website Monitoring Blog &#187; http</title>
	<atom:link href="http://www.fastmonitoring.com/tag/http/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fastmonitoring.com</link>
	<description>web site monitoring :: web server performance :: website uptime</description>
	<lastBuildDate>Tue, 15 Feb 2011 10:25:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Creating a Simple HTTP Ping Utility to Monitor Your Site Latency</title>
		<link>http://www.fastmonitoring.com/2010-06-30/creating-a-simple-http-ping-utility-to-monitor-your-site-latency/</link>
		<comments>http://www.fastmonitoring.com/2010-06-30/creating-a-simple-http-ping-utility-to-monitor-your-site-latency/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 13:28:00 +0000</pubDate>
		<dc:creator>Alex Ivanoff</dc:creator>
				<category><![CDATA[website monitoring]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[ping]]></category>
		<category><![CDATA[utility]]></category>

		<guid isPermaLink="false">http://www.fastmonitoring.com/?p=154</guid>
		<description><![CDATA[While surfing the web, I encountered a ready solution (written in Perl) that can be used to check websites&#8217; latency. How to install: Install Net::HTTP, and copy the shell script to a suitable location. #!/usr/bin/perl  -w # # Program: HTTP Ping &#60;http-ping.pl&#62; # # Author: Matty &#60; matty91 at gmail dot com &#62; # # [...]]]></description>
			<content:encoded><![CDATA[<p>While surfing the web, I encountered a ready solution (written in Perl) that can be used to check websites&#8217; latency.</p>
<p>How to install:</p>
<p>Install Net::HTTP, and copy the shell script to a suitable location.</p>
<blockquote><p><span id="more-154"></span>#!/usr/bin/perl  -w<br />
#<br />
# Program: HTTP Ping &lt;http-ping.pl&gt;<br />
#<br />
# Author: Matty &lt; matty91 at gmail dot com &gt;<br />
#<br />
# Current Version: 1.1<br />
#<br />
# Revision History:<br />
#<br />
# Version 1.1<br />
#     Added checks for arguments<br />
#<br />
# Purpose:<br />
#  Reports latency between a web server and a given host<br />
#<br />
# License:<br />
#   This program is free software; you can redistribute it and/or modify it<br />
#   under the terms of the GNU General Public License as published by the<br />
#   Free Software Foundation; either version 2, or (at your option) any<br />
#   later version.<br />
#<br />
#   This program is distributed in the hope that it will be useful,<br />
#   but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br />
#   GNU General Public License for more details.<br />
#<br />
#   You should have received a copy of the GNU General Public License<br />
#   along with this program; if not, write to the Free Software<br />
#   Foundation, 59 Temple Place &#8211; Suite 330, Boston, MA 02111-1307, USA.<br />
#<br />
# Usage<br />
#  Usage: http-ping.pl [ -s server ] [ -p port ] [ -d delay ] [ -u uri ] [ -h ]<br />
#<br />
# Example:<br />
#  ./http-ping.pl -s www.fastmonitoring.com -p 80 -d 5 -u /index.html<br />
#   Querying HTTP server www.fastmonitoring.com:80 every 5 seconds (Ctrl-C to stop):<br />
#      Mon Nov 29 18:09:59 2004: TCP Connection Time=0.052s HTTP GET Time=0.051s [Normal Delay]<br />
#      Mon Nov 29 18:10:04 2004: TCP Connection Time=0.036s HTTP GET Time=0.052s [Normal Delay]<br />
#      Mon Nov 29 18:10:09 2004: TCP Connection Time=0.034s HTTP GET Time=0.052s [Normal Delay]</p>
<p>use Net::HTTP;<br />
use Time::HiRes qw (time);<br />
use Getopt::Std;</p>
<p>############################<br />
# Globals                  #<br />
############################<br />
my $httpConnection = 0;<br />
my $content = 0;<br />
my $buffer = 0;<br />
my $buffer_size = 8192;<br />
my $excessive_delay = 1;</p>
<p>####################################<br />
# Get the parameters from the user #<br />
####################################<br />
%options=();<br />
getopts(&#8220;d:hp:s:u:&#8221;,\%options);</p>
<p>my $delay = defined($options{d}) ? $options{d} : 10;<br />
my $port = defined($options{p}) ? $options{p} : 80;<br />
my $server = defined($options{s}) ? $options{s} : &#8220;localhost&#8221;;<br />
my $uri = defined($options{u}) ? $options{u} : &#8220;/&#8221;;</p>
<p>if (defined $options{h} ) {<br />
printf(&#8220;Usage: http-ping.pl [ -s server ] [ -p port ] [ -d delay ] [ -u uri ] [ -h ]\n&#8221;);<br />
exit(1);<br />
}</p>
<p>#######################################<br />
# Let the user know what we are doing #<br />
#######################################</p>
<p>printf(&#8220;Issuing GET request for $uri on HTTP server $server:$port every $delay seconds (Ctrl-C to stop):\n&#8221;);</p>
<p>#############################<br />
# Connect to server         #<br />
#############################<br />
while (1) {<br />
# Calculate the time it takes to establish a TCP connection ( SYN, SYN/ACK, ACK )<br />
my $start = time();<br />
my $httpConnection = Net::HTTP-&gt;new( Host =&gt; $server )<br />
|| die $@;<br />
my $tcpConnectionTime = time() &#8211; $start;</p>
<p># Calculate the time it takes to GET / and process it<br />
$start = time();</p>
<p>$httpConnection-&gt;write_request(GET =&gt; &#8220;$uri&#8221;, &#8220;User-Agent&#8221; =&gt; &#8220;MTY/1.0.5f&#8221;);</p>
<p>while (  $content =  $httpConnection-&gt;read_entity_body($buffer, $buffer_size) ) {<br />
}<br />
my $httpConnectionTime = time() &#8211; $start;</p>
<p>if ( ($tcpConnectionTime &gt; $excessive_delay) || ( $httpConnectionTime &gt; $excessive_delay))  {<br />
my $dt = scalar localtime time;<br />
printf(&#8220;  %s: TCP Connection Time=%.3fs HTTP GET Time=%.3fs [Excessive Delay]\n&#8221;,$dt, $tcpConnectionTime, $httpConnectionTime);<br />
} else {<br />
my $dt = scalar localtime time;<br />
printf(&#8220;  %s: TCP Connection Time=%.3fs HTTP GET Time=%.3fs [Normal Delay]\n&#8221;,$dt, $tcpConnectionTime, $httpConnectionTime);<br />
}</p>
<p>sleep($delay);<br />
}</p>
<p>That&#8217;s it. Enjoy!</p></blockquote>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">Install Net::HTTP, and copy the shell script to a suitable location</div>
<img src="http://www.fastmonitoring.com/?ak_action=api_record_view&id=154&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.fastmonitoring.com/2010-06-30/creating-a-simple-http-ping-utility-to-monitor-your-site-latency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

