<?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>dev.enekoalonso.com &#187; status</title>
	<atom:link href="http://dev.enekoalonso.com/tag/status/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.enekoalonso.com</link>
	<description>having fun with code</description>
	<lastBuildDate>Wed, 12 Oct 2011 21:40:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Check your server status with email notification</title>
		<link>http://dev.enekoalonso.com/2009/01/03/check-your-server-status-with-email-notification/</link>
		<comments>http://dev.enekoalonso.com/2009/01/03/check-your-server-status-with-email-notification/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 19:34:11 +0000</pubDate>
		<dc:creator>Eneko Alonso</dc:creator>
				<category><![CDATA[uncategorized]]></category>
		<category><![CDATA[automatically]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[status]]></category>

		<guid isPermaLink="false">http://dev.enekoalonso.com/?p=238</guid>
		<description><![CDATA[I wanted to do this for a while and never really sit down and code it. Yesterday I came across this pretty nice script by Ben from Coderholic which does exactly that: check your server status and send you an email if it is other than 200 (OK). #!/bin/bash &#160; &#160; # Query a supplied [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to do this for a while and never really sit down and code it. Yesterday I came across this pretty nice <a href="http://www.coderholic.com/server-status-checker-shell-script-2/">script by Ben from Coderholic</a> which does exactly that: check your server status and send you an email if it is other than 200 (OK).</p>
<div class="geshi no bash">
<ol>
<li class="li1">
<div class="de1"><span class="co0">#!/bin/bash &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Query a supplied URL and output an error message if &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># the status code was not 200. Can be used as a cron &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># task to check if a server is up or not. &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># Ben Dowling &#8211; http://www.coderholic.com &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="co0"># The URL to query &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re4">$#</span> -ne <span class="nu0">1</span> <span class="br0">&#93;</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">then</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;Usage: $0 &lt;URL&gt;&quot;</span>; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">exit</span>; &nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">fi</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="re2">url=</span>$<span class="nu0">1</span>; &nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re2">response=</span>$<span class="br0">&#40;</span>curl -s -I -L <span class="re1">$url</span> <span class="sy0">|</span> <span class="kw2">grep</span> HTTP<span class="br0">&#41;</span>; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="re2">status=</span>$<span class="br0">&#123;</span>response<span class="co0">#* }; # Strip off characters up to the first space &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re2">status=</span>$<span class="br0">&#123;</span>status:<span class="nu0">0</span>:<span class="nu0">3</span><span class="br0">&#125;</span>; <span class="co0"># Just use the 3 digit status code &nbsp;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; </div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;$status&quot;</span> <span class="sy0">!</span>= <span class="st0">&quot;200&quot;</span> <span class="br0">&#93;</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">then</span> &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;Error fetching $url. Status code &#39;$status&#39;&quot;</span>; &nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">fi</span></div>
</li>
</ol>
</div>
<p>Nice.</p>
<h3  class="related_post_title">Related Posts:</h3><ul class="related_post"><li>July 13, 2011 -- <a href="http://dev.enekoalonso.com/2011/07/13/clone-your-osxterminal-window/" title="Clone your OSX terminal window">Clone your OSX terminal window</a> (1)</li><li>October 12, 2011 -- <a href="http://dev.enekoalonso.com/2011/10/12/command-line-scripting-with-node-js/" title="Command line scripting with Node.js">Command line scripting with Node.js</a> (0)</li><li>August 6, 2011 -- <a href="http://dev.enekoalonso.com/2011/08/06/python-script-remove-empty-folders/" title="Python script: remove empty folders">Python script: remove empty folders</a> (1)</li><li>October 1, 2010 -- <a href="http://dev.enekoalonso.com/2010/10/01/having-fun-with-node-js-redis/" title="Having fun with node.js &#038; Redis">Having fun with node.js &#038; Redis</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://dev.enekoalonso.com/2009/01/03/check-your-server-status-with-email-notification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

