<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en" xml:base="http://blog.browsermob.com/wp-atom.php">
	<title type="text">The BrowserMob Blog</title>
	<subtitle type="text">All about browsers, performance testing, and load testing</subtitle>

	<updated>2010-07-13T15:31:14Z</updated>
	<generator uri="http://wordpress.org/" version="2.8.5">WordPress</generator>

	<link rel="alternate" type="text/html" href="http://blog.browsermob.com" />
	<id>http://blog.browsermob.com/feed/atom/</id>
	

			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/BrowserMob" /><feedburner:info uri="browsermob" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
		<author>
			<name>Patrick Lightbody</name>
						<uri>http://browsermob.com</uri>
					</author>
		<title type="html"><![CDATA[BrowserMob Joins Neustar Webmetrics Family of Services]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BrowserMob/~3/mkcxXOxHjiE/" />
		<id>http://blog.browsermob.com/2010/07/browsermob-joins-neustar-webmetrics-family-of-services/</id>
		<updated>2010-07-08T23:21:51Z</updated>
		<published>2010-07-08T23:20:39Z</published>
		<category scheme="http://blog.browsermob.com" term="Announcements" /><category scheme="http://blog.browsermob.com" term="BrowserMob" /><category scheme="http://blog.browsermob.com" term="Neustar" /><category scheme="http://blog.browsermob.com" term="Webmetrics" />		<summary type="html"><![CDATA[
I’ve got great news to share with you – BrowserMob has been acquired and is joining the Neustar family of services, which includes UltraDNS and Webmetrics!


I started BrowserMob in 2008 with the belief that a combination of cloud computing and real browsers wrapped up in a self-service model could dramatically change how people used load [...]]]></summary>
		<content type="html" xml:base="http://blog.browsermob.com/2010/07/browsermob-joins-neustar-webmetrics-family-of-services/"><![CDATA[<p>
I’ve got great news to share with you – BrowserMob has been acquired and is joining the Neustar family of services, which includes UltraDNS and Webmetrics!
</p>
<p>
I started BrowserMob in 2008 with the belief that a combination of cloud computing and real browsers wrapped up in a self-service model could dramatically change how people used load testing. Neustar shares that same philosophy and has built a world-class portfolio of cloud-based performance services that currently has over 3,000 customers.  I&#8217;m most excited by this partnership because it means that we can now offer our unique services to an even greater audience.
</p>
<p>
A few months ago Neustar approached us and it was immediately obvious that our visions for website testing, development, and operations were very similar. For example, just like BrowserMob, the team at Webmetrics utilizes real browsers and supports open source and cloud computing initiatives. Even better, upon closer look I found that Webmetrics Load Testing and Monitoring solutions actually complement our own services much more than they compete. Joining forces made perfect sense!
</p>
<p>
While in the short term nothing will be changing, the long term benefits of this partnership will be an even better experience for all our users. For example, Webmetrics Load Testing provides high quality, hands-on professional services that BrowserMob customers will be able to utilize if they need extra assistance. And for monitoring, BrowserMob customers will be able to benefit from the massive infrastructure and capabilities that Webmetrics already has in place including a global infrastructure with agents in over 100 major cities. Similarly, we expect to bring to the table many innovations of our own over the coming months and years.
</p>
<p>
Of course our highest priority is you – our customer. I want to assure you that the quality of service you&#8217;ve been receiving from us will not change, and that 100% of our team will remain intact and dedicated to making you successful. In fact, effective today both Ian White and I are officially Neustar employees and we are committed to enhancing our solutions and your satisfaction!
</p>
<p>
Thank you for showing your continued support to BrowserMob. I&#8217;m excited to continue working with you and updating you on our plans for a fully integrated BrowserMob + Neustar offering. If you have any questions, you&#8217;re of course always welcome to contact me directly.
</p>
<p>
Patrick<br />
+1 (503) 828-9003 x 101<br />
patrick.lightbody@neustar.biz</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=BrowserMob:+BrowserMob+Joins+Neustar+Webmetrics+Family+of+Services+http://7s2qs.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.browsermob.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="[Post to Twitter]" border="0" /></a> <a class="tt" href="http://twitter.com/home/?status=BrowserMob:+BrowserMob+Joins+Neustar+Webmetrics+Family+of+Services+http://7s2qs.th8.us" title="Post to Twitter">Tweet This Post</a>&nbsp; </p>]]></content>
		<link rel="replies" type="text/html" href="http://blog.browsermob.com/2010/07/browsermob-joins-neustar-webmetrics-family-of-services/#comments" thr:count="8" />
		<link rel="replies" type="application/atom+xml" href="http://blog.browsermob.com/2010/07/browsermob-joins-neustar-webmetrics-family-of-services/feed/atom/" thr:count="8" />
		<thr:total>8</thr:total>
	<feedburner:origLink>http://blog.browsermob.com/2010/07/browsermob-joins-neustar-webmetrics-family-of-services/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Patrick Lightbody</name>
						<uri>http://browsermob.com</uri>
					</author>
		<title type="html"><![CDATA[Estimating concurrent users based on past traffic]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BrowserMob/~3/RlXsc5VKZac/" />
		<id>http://blog.browsermob.com/2010/06/estimating-concurrent-users-based-on-past-traffic/</id>
		<updated>2010-06-16T05:10:57Z</updated>
		<published>2010-06-15T17:08:38Z</published>
		<category scheme="http://blog.browsermob.com" term="FAQ" />		<summary type="html"><![CDATA[
Today we received an excellent question from a customer of ours:


We were wondering if you all have any information that says &#8220;X Unique visitors per day translates into Y simultaneous users at any given time.&#8221;
Essentially, we&#8217;re looking for a way to determine how many simultaneous users we should load test with if we know the [...]]]></summary>
		<content type="html" xml:base="http://blog.browsermob.com/2010/06/estimating-concurrent-users-based-on-past-traffic/"><![CDATA[<p>
Today we received an excellent question from a customer of ours:
</p>
<blockquote style="padding: 10px; border: 1px solid #ddd; background-color: #eee"><p>
We were wondering if you all have any information that says &#8220;X Unique visitors per day translates into Y simultaneous users at any given time.&#8221;</p>
<p>Essentially, we&#8217;re looking for a way to determine how many simultaneous users we should load test with if we know the sites normal daily traffic.</p></blockquote>
<p>
While every site is different, we recommend following this line of reasoning to help you find the answer. Suppose your site gets <strong>100K unique visitors per day</strong>, with peak traffic in the mornings and afternoons. Assume that 40% of the traffic comes between 7AM and 11AM, 40% at 4PM to 9PM, and 20% at other times. This means during your peak hours (7AM to 11AM and 4PM to 9PM) you&#8217;ll get ~10% of your unique visitors <em>per hour</em>, or <strong>10K uniques</strong> in our example.
</p>
<p>
Now that you know how many unique visitors you&#8217;ll get in an hour, you can start turning that in to concurrent users. To do that, it&#8217;s important to understand that a unique visitor is roughly equivalent of a <strong>transaction</strong>. So really you want to figure out how many users you need to reach 10K transactions in an hour.
</p>
<p>
Suppose your script (or scripts) take an average of 2 minutes to complete. That means a single user will execute 30 transactions in an hour. So to reach 10K transactions, you&#8217;d need 334 users (10K divided by 30). If you decide you want to create realistic scripts that include human think time, then the scripts will take that much longer and you&#8217;ll need that many more concurrent users. For example, if the script gets 5X think time added and now takes 10 minutes to run, then you&#8217;ll need 1,667 users (10K divided by 6).
</p>
<p>
Of course, this calculation will only get you the load on a typical day (assuming a single hour sees 10% of traffic). Your traffic patterns may vary, or you may want to prepare for a larger surge. For example, if you want to test what happens when 60% of the daily traffic visits in an hour, then you&#8217;d need 2,000 users (60K divided by 30).</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Estimating+concurrent+users+based+on+past+traffic+http://h7tbd.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.browsermob.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="[Post to Twitter]" border="0" /></a> <a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Estimating+concurrent+users+based+on+past+traffic+http://h7tbd.th8.us" title="Post to Twitter">Tweet This Post</a>&nbsp; </p>]]></content>
		<link rel="replies" type="text/html" href="http://blog.browsermob.com/2010/06/estimating-concurrent-users-based-on-past-traffic/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://blog.browsermob.com/2010/06/estimating-concurrent-users-based-on-past-traffic/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://blog.browsermob.com/2010/06/estimating-concurrent-users-based-on-past-traffic/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Patrick Lightbody</name>
						<uri>http://browsermob.com</uri>
					</author>
		<title type="html"><![CDATA[Eliminating concurrent access to sensitive data]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BrowserMob/~3/zbHcIbxRYys/" />
		<id>http://blog.browsermob.com/2010/06/eliminating-concurrent-access-to-sensitive-data/</id>
		<updated>2010-06-14T18:36:17Z</updated>
		<published>2010-06-14T18:36:17Z</published>
		<category scheme="http://blog.browsermob.com" term="Load Testing Tips" /><category scheme="http://blog.browsermob.com" term="API" /><category scheme="http://blog.browsermob.com" term="Scripting" />		<summary type="html"><![CDATA[
We recently had a customer from a large clothing retailer ask us if there was any way to ensure that data, such as a username/password combination, could be restricted such that it was &#8220;checked out&#8221; and available only for a specific concurrent user. This is very common with logins, where systems often will prevent concurrent [...]]]></summary>
		<content type="html" xml:base="http://blog.browsermob.com/2010/06/eliminating-concurrent-access-to-sensitive-data/"><![CDATA[<p>
We recently had a customer from a large clothing retailer ask us if there was any way to ensure that data, such as a username/password combination, could be restricted such that it was &#8220;checked out&#8221; and available only for a specific concurrent user. This is very common with logins, where systems often will prevent concurrent logins from multiple IP addresses.
</p>
<p>
While BrowserMob does not have a concept in which data rows can be &#8220;checked out&#8221;, some simple scripting can achieve the same results. The key is in creative use of the <strong>browserMob.getUserNum()</strong> and <strong>browserMob.getTxCount()</strong> APIs. You can learn more about them by reading up on the <a href="http://browsermob.com/tools">BrowserMob APIs</a>.
</p>
<p>
The getUserNum function returns 0, 1, 2, etc based on the concurrent user in your load test. So if you have a 100 user test, getUserNum will return between 0 and 99. It&#8217;s important to understand that it will return the same value for the same user throughout the test.
</p>
<p>
The getTxCount function returns 1, 2, 3, etc based on the number of cycles for that specific user. This number will effectively be a counter of the unique number of transactions that that particular user has executed. So user 1 and user 100 will both have a getTxCount of 1 returned, but by the time user 100 sees it, user 1 might already be on transaction 50.
</p>
<p>
Now suppose you want to run a 1000 user test in which you never concurrently log in with the same user. All you need to do is pre-create 1000 user accounts and then write your script like so:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> userId <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">getUserNum</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> username <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;test-&quot;</span> <span style="color: #339933;">+</span> userId<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> password <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;password&quot;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">type</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;username&quot;</span><span style="color: #339933;">,</span> username<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">type</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;password&quot;</span><span style="color: #339933;">,</span> password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>
This works great, but what if you want to use more than 1000 logins? Suppose you want to use up to 10,000 logins among the 1000 user test? This is where the getTxCount function comes in to:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> loginsPerUser <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> userNum <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">getUserNum</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> txCount <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">getTxCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> userId <span style="color: #339933;">=</span> userNum <span style="color: #339933;">*</span> loginsPerUser <span style="color: #339933;">+</span> txCount <span style="color: #339933;">%</span> loginsPerUser<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> username <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;test-&quot;</span> <span style="color: #339933;">+</span> userId<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> password <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;password&quot;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">type</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;username&quot;</span><span style="color: #339933;">,</span> username<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">type</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;password&quot;</span><span style="color: #339933;">,</span> password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>
What this does is allocate 10 logins per concurrent user. So user 1 will get usernames test-0, test-1, &#8230;, test-9 while user 8 will get usernames test-80, test-81, &#8230;, test-89, etc. Because of the mod call (%) the ten usernames will simply wrap around once they&#8217;ve been used.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Eliminating+concurrent+access+to+sensitive+data+http://eag2c.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.browsermob.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="[Post to Twitter]" border="0" /></a> <a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Eliminating+concurrent+access+to+sensitive+data+http://eag2c.th8.us" title="Post to Twitter">Tweet This Post</a>&nbsp; </p>]]></content>
		<link rel="replies" type="text/html" href="http://blog.browsermob.com/2010/06/eliminating-concurrent-access-to-sensitive-data/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://blog.browsermob.com/2010/06/eliminating-concurrent-access-to-sensitive-data/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://blog.browsermob.com/2010/06/eliminating-concurrent-access-to-sensitive-data/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Patrick Lightbody</name>
						<uri>http://browsermob.com</uri>
					</author>
		<title type="html"><![CDATA[Advanced handling of page timeouts in Selenium]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BrowserMob/~3/pJwfesM1GPg/" />
		<id>http://blog.browsermob.com/2010/06/advanced-handling-of-page-timeouts-in-selenium/</id>
		<updated>2010-06-13T21:45:11Z</updated>
		<published>2010-06-13T21:44:08Z</published>
		<category scheme="http://blog.browsermob.com" term="Uncategorized" /><category scheme="http://blog.browsermob.com" term="Scripting" /><category scheme="http://blog.browsermob.com" term="Selenium" /><category scheme="http://blog.browsermob.com" term="Timeouts" />		<summary type="html"><![CDATA[
Because both our load testing and website monitoring services are based on Selenium, we have a unique ability to measure the performance of things like page load times, AJAX timings, and other in-browser interactions.


Selenium has both a setTimeout command and a waitForPageToLoad command. Both can be given a timeout value, which will control how long [...]]]></summary>
		<content type="html" xml:base="http://blog.browsermob.com/2010/06/advanced-handling-of-page-timeouts-in-selenium/"><![CDATA[<p>
Because both our <a href="http://browsermob.com/website-load-testing">load testing</a> and <a href="http://browsermob.com/website-monitoring">website monitoring</a> services are based on Selenium, we have a unique ability to measure the performance of things like page load times, AJAX timings, and other in-browser interactions.
</p>
<p>
Selenium has both a setTimeout command and a waitForPageToLoad command. Both can be given a timeout value, which will control how long Selenium waits for a given page to load or element to appear. When it comes to using our services, most people stick with the default time of 30 seconds. If the timeout is reached, an error is thrown, the script aborts, and the transaction is recorded.
</p>
<p>
However, sometimes people want to know when pages take more than X seconds to load, but don&#8217;t want to necessarily interrupt the flow of the script. In fact, just last week we got this request from a customer:
</p>
<blockquote style="padding: 10px; border: 1px solid #ddd; background-color: #eee"><p>
Ability to trigger an alert based on a set threshold (by the user) – not using the timeout.  This basically came from the performance issues we are experiencing.  Here’s the scenario:</p>
<ul>
<li>We have a specific page that takes 2+ minutes to load.</li>
<li>The page load timeout in the Selenium script was set to 60s.</li>
<li>BMob properly reported the &#8220;timeout&#8221; error but when this error happens, BMob quits the script.</li>
<li>This is not ideal for me since I want to still be able to see how long the page takes to load.</li>
<li>Increasing the page load timeout for the page in question works, but now I don’t have a way (that I know of) to still trigger an alert after 60s.</li>
</ul>
<p>I should be able to set a threshold for any page I choose that would then send a notification alert.
</p></blockquote>
<p>
In other words, this customer wanted for a way to still report a transaction as a failure and receive an alert, but also still allow the script to continue. Fortunately, our support for JavaScript as a scripting language provides the answer:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> timeout <span style="color: #339933;">=</span> <span style="color: #CC0000;">90000</span><span style="color: #339933;">;</span>
...
<span style="color: #006600; font-style: italic;">// start of script</span>
...
<span style="color: #003366; font-weight: bold;">var</span> start <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> end <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...
<span style="color: #006600; font-style: italic;">// rest of script</span>
...
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>end <span style="color: #339933;">-</span> start<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">45000</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #3366CC;">&quot;An important page took longer than 45 seconds to load&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>
What this script does is sets the timeout to a very long amount (1.5 minutes) but will still report an error if a specific page takes longer than 45 seconds. This allows the remainder of the script to execute even when the page takes more than a specified 45-second threshold.
</p>
<p>
The only problem with this script is that if the page takes longer than 90 seconds, then the rest of the script will still not run because waitForPageToLoad will throw an exception. You can solve that too with a little code:
</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> start <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
    selenium.<span style="color: #660066;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// this will happen after 90 seconds</span>
    <span style="color: #006600; font-style: italic;">// todo: recover and send the browser to the the next URL</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> end <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>
The only thing that is important to remember with this use of try/catch is that you&#8217;ll need to properly recover from the error. Simply catching the error and trying to continue may not work. For example, if the next Selenium command requires clicking on a button that should have loaded from the last page, there may be no way to recover. However, if the next step is simply visiting a new URL, you could possibly get away with a simple open() command in the catch block.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Advanced+handling+of+page+timeouts+in+Selenium+http://yp2im.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.browsermob.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="[Post to Twitter]" border="0" /></a> <a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Advanced+handling+of+page+timeouts+in+Selenium+http://yp2im.th8.us" title="Post to Twitter">Tweet This Post</a>&nbsp; </p>]]></content>
		<link rel="replies" type="text/html" href="http://blog.browsermob.com/2010/06/advanced-handling-of-page-timeouts-in-selenium/#comments" thr:count="1" />
		<link rel="replies" type="application/atom+xml" href="http://blog.browsermob.com/2010/06/advanced-handling-of-page-timeouts-in-selenium/feed/atom/" thr:count="1" />
		<thr:total>1</thr:total>
	<feedburner:origLink>http://blog.browsermob.com/2010/06/advanced-handling-of-page-timeouts-in-selenium/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Patrick Lightbody</name>
						<uri>http://browsermob.com</uri>
					</author>
		<title type="html"><![CDATA[dynaTrace shows how to track AJAX performance with Selenium]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BrowserMob/~3/7La3UcdXKTg/" />
		<id>http://blog.browsermob.com/2010/05/dynatrace-shows-how-to-track-ajax-performance-with-selenium/</id>
		<updated>2010-05-25T18:26:24Z</updated>
		<published>2010-05-25T18:26:24Z</published>
		<category scheme="http://blog.browsermob.com" term="Uncategorized" /><category scheme="http://blog.browsermob.com" term="dynaTrace" /><category scheme="http://blog.browsermob.com" term="Selenium" />		<summary type="html"><![CDATA[
dynaTrace just posted a really nice tutorial showing how to track client-side performance (JavaScript, DOM, render times, etc) automatically using Selenium. They do this by using their super-cool free AJAX edition of their product.
 Tweet This Post&#160; ]]></summary>
		<content type="html" xml:base="http://blog.browsermob.com/2010/05/dynatrace-shows-how-to-track-ajax-performance-with-selenium/"><![CDATA[<p>
dynaTrace just posted a <a href="http://blog.dynatrace.com/2010/05/21/how-to-use-your-selenium-tests-for-automated-javascriptajax-performance-analysis/">really nice tutorial</a> showing how to track client-side performance (JavaScript, DOM, render times, etc) automatically using Selenium. They do this by using their super-cool <a href="http://ajax.dynatrace.com/">free AJAX edition</a> of their product.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=BrowserMob:+dynaTrace+shows+how+to+track+AJAX+performance+with+Selenium+http://xc64g.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.browsermob.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="[Post to Twitter]" border="0" /></a> <a class="tt" href="http://twitter.com/home/?status=BrowserMob:+dynaTrace+shows+how+to+track+AJAX+performance+with+Selenium+http://xc64g.th8.us" title="Post to Twitter">Tweet This Post</a>&nbsp; </p>]]></content>
		<link rel="replies" type="text/html" href="http://blog.browsermob.com/2010/05/dynatrace-shows-how-to-track-ajax-performance-with-selenium/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://blog.browsermob.com/2010/05/dynatrace-shows-how-to-track-ajax-performance-with-selenium/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://blog.browsermob.com/2010/05/dynatrace-shows-how-to-track-ajax-performance-with-selenium/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>ian</name>
					</author>
		<title type="html"><![CDATA[Monitoring Maintenance Windows]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BrowserMob/~3/hwGpN5U52PU/" />
		<id>http://blog.browsermob.com/?p=608</id>
		<updated>2010-05-19T19:07:05Z</updated>
		<published>2010-05-17T19:17:16Z</published>
		<category scheme="http://blog.browsermob.com" term="FAQ" /><category scheme="http://blog.browsermob.com" term="How To" /><category scheme="http://blog.browsermob.com" term="Monitoring" /><category scheme="http://blog.browsermob.com" term="downtime" /><category scheme="http://blog.browsermob.com" term="javascript" /><category scheme="http://blog.browsermob.com" term="maintenance" /><category scheme="http://blog.browsermob.com" term="maintenance windows" /><category scheme="http://blog.browsermob.com" term="RBU" /><category scheme="http://blog.browsermob.com" term="Scripting" /><category scheme="http://blog.browsermob.com" term="scripts" />		<summary type="html"><![CDATA[When setting up monitoring jobs, there are often predictable time periods in which you want to change the behavior of a script or prevent it from running at all, without having to manually stop/start the monitoring job each time. For instance, you might want to prevent errors and alert emails during routine maintenance windows, or [...]]]></summary>
		<content type="html" xml:base="http://blog.browsermob.com/2010/05/monitoring-maintenance-windows/"><![CDATA[<p>When setting up monitoring jobs, there are often predictable time periods in which you want to change the behavior of a script or prevent it from running at all, without having to manually stop/start the monitoring job each time. For instance, you might want to prevent errors and alert emails during routine maintenance windows, or perhaps you&#8217;re only interested in site performance on weekdays during regular business hours. We&#8217;ve come up with solutions to a few common situations that will help jump start your scripts.</p>
<p><strong>Overview</strong><br />
At the core of all these examples is a small configuration object that sits at the top of the script for quick changes, and a single function that returns true or false depending on whether or not the current time is within a blackout period. The following is some pseudo-code outlining one way in which you might choose to implement these examples in your own scripts. Don&#8217;t forget to add in the appropriate maintenance object and isInMaintenance() function from the examples below to make this work.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// The configuration object for the maintenance window</span>
<span style="color: #003366; font-weight: bold;">var</span> maintenance <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>...<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// The maintenance function (plug in the appropriate function)</span>
<span style="color: #003366; font-weight: bold;">var</span> isInMaintenance <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    ...
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> selenium <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">openBrowser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>browserMob.<span style="color: #660066;">isValidation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> isInMaintenance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Active maintenance window</span>
    browserMob.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Is in maintenance!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Run normal script</span>
    browserMob.<span style="color: #660066;">beginTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Step 1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://google.com/search?q=website+monitoring&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ...
    <span style="color: #660066;">browserMob</span>.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    browserMob.<span style="color: #660066;">endTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Web Page Check</strong><br />
The most straight forward way to check for a maintenance window is to have Selenium load a web page and look for an element that&#8217;s only present during scheduled down time. You&#8217;ll want to be careful not to choose something that is also present when the site is really in trouble or you will never get your alerts!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> maintenance <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    check<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        url<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://example.com/home&quot;</span><span style="color: #339933;">,</span>
        element<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;//img[@title=<span style="color: #000099; font-weight: bold;">\&quot;</span>maintenance<span style="color: #000099; font-weight: bold;">\&quot;</span>]&quot;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> isInMaintenance <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>maintenance.<span style="color: #660066;">check</span> <span style="color: #339933;">&amp;&amp;</span> maintenance.<span style="color: #660066;">check</span>.<span style="color: #660066;">url</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> maintenance.<span style="color: #660066;">check</span>.<span style="color: #660066;">element</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>maintenance.<span style="color: #660066;">url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> selenium.<span style="color: #660066;">isElementPresent</span><span style="color: #009900;">&#40;</span>maintenance.<span style="color: #660066;">element</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Multipe Date Ranges</strong><br />
One of the most common requests we get is for a way to handle scheduled maintenance windows. These windows tend to be one-off date ranges decided well in advance of the actual event. Given a set of start/end dates, you could prevent monitoring errors and email alerts during the blackout periods. When setting the dates, don&#8217;t forget to include the time zone abbreviation in the argument string or the script will use the local time of the machine it&#8217;s running on.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> maintenance <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    dates<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #009900;">&#123;</span>start<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;05/12/2010 23:00 PDT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> end<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;05/13/2010 02:30 PDT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#123;</span>start<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;05/24/2010 23:00 PDT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> end<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;05/25/2010 02:30 PDT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> isInMaintenance <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> now <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    nowTime <span style="color: #339933;">=</span> now.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	    maintenanceWindows <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// Check for maintenance date ranges</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>maintenance.<span style="color: #660066;">dates</span> <span style="color: #339933;">&amp;&amp;</span> maintenance.<span style="color: #660066;">dates</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        maintenanceWindows <span style="color: #339933;">=</span> maintenance.<span style="color: #660066;">dates</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> maintenanceWindows<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> m <span style="color: #339933;">=</span> maintenanceWindows<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>nowTime <span style="color: #339933;">&gt;=</span> m.<span style="color: #660066;">start</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> nowTime <span style="color: #339933;">&lt;</span> m.<span style="color: #660066;">end</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Days of the Week</strong><br />
Here&#8217;s an example for blacking out specific days of the week. This will allow you to create a script that, for example, monitors on Mondays, Wednesdays, and Fridays, or only on business days. Simply provide a time zone offset, which is the number of minutes your time zone deviates from coordinated universal time (a.k.a. UTC, GMT, Zulu time), and the days of the week you <em>don&#8217;t</em> want to run the script (from 0-6, where 0 is Sunday, 1 is Monday, etc.).</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> maintenance <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    timezoneOffset<span style="color: #339933;">:</span> <span style="color: #CC0000;">240</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// UTC offset in minutes (eg: NYC (GMT-4) is 4 * 60</span>
    days<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6</span><span style="color: #009900;">&#93;</span>    <span style="color: #006600; font-style: italic;">// Sunday = 0, Saturday = 6</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> isInMaintenance <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> now <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        nowTime <span style="color: #339933;">=</span> now.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        timezoneOffset <span style="color: #339933;">=</span> maintenance.<span style="color: #660066;">timezoneOffset</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
        localTimezoneOffset <span style="color: #339933;">=</span> now.<span style="color: #660066;">getTimezoneOffset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        timezoneDiff <span style="color: #339933;">=</span> localTimezoneOffset <span style="color: #339933;">-</span> timezoneOffset<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// Check for full blackout days (such as weekends)</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>maintenance.<span style="color: #660066;">days</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> maintenance.<span style="color: #660066;">days</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> targetDate <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>nowTime <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>timezoneDiff <span style="color: #339933;">*</span> <span style="color: #CC0000;">60</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            targetDay <span style="color: #339933;">=</span> targetDate.<span style="color: #660066;">getDay</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> maintenance.<span style="color: #660066;">days</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>maintenance.<span style="color: #660066;">days</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> targetDay<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Time of Day</strong><br />
This example shows how you can have a daily blackout range. This code will parse the start/end strings into a daily time range adjusted to the target time zone. Use this if you only want to monitor during banker&#8217;s hours, or if you want to prevent a script from running while your database is backing up.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> maintenance <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    timezoneOffset<span style="color: #339933;">:</span> <span style="color: #CC0000;">240</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// UTC offset in minutes (eg: NYC (GMT-4) is 4 * 60</span>
    hours<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>start<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;23:30&quot;</span><span style="color: #339933;">,</span> end<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;07:30&quot;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> isInMaintenance <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> now <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        nowTime <span style="color: #339933;">=</span> now.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        timezoneOffset <span style="color: #339933;">=</span> maintenance.<span style="color: #660066;">timezoneOffset</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
        localTimezoneOffset <span style="color: #339933;">=</span> now.<span style="color: #660066;">getTimezoneOffset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        timezoneDiff <span style="color: #339933;">=</span> localTimezoneOffset <span style="color: #339933;">-</span> timezoneOffset<span style="color: #339933;">,</span>
        maintenanceWindows <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>maintenance.<span style="color: #660066;">hours</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> maintenance.<span style="color: #660066;">hours</span>.<span style="color: #660066;">start</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> maintenance.<span style="color: #660066;">hours</span>.<span style="color: #660066;">end</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> sH<span style="color: #339933;">,</span> eH<span style="color: #339933;">,</span> sM<span style="color: #339933;">,</span> eM<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">var</span> chunks <span style="color: #339933;">=</span> maintenance.<span style="color: #660066;">hours</span>.<span style="color: #660066;">start</span>.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        sH <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>chunks<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        sM <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>chunks<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
&nbsp;
        chunks <span style="color: #339933;">=</span> maintenance.<span style="color: #660066;">hours</span>.<span style="color: #660066;">end</span>.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        eH <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>chunks<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        eM <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>chunks<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">var</span> startDate <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>now.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> now.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> now.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> sH<span style="color: #339933;">,</span> sM<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            endDate <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>now.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> now.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> now.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> eH<span style="color: #339933;">,</span> eM<span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// Convert to target timezone</span>
        startDate <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>startDate.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>timezoneDiff <span style="color: #339933;">*</span> <span style="color: #CC0000;">60</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        endDate <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>endDate.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span>timezoneDiff <span style="color: #339933;">*</span> <span style="color: #CC0000;">60</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>startDate.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;=</span> endDate.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// Single range mid-day</span>
            maintenanceWindows.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>start<span style="color: #339933;">:</span> startDate<span style="color: #339933;">,</span> end<span style="color: #339933;">:</span> endDate<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// Date wraps, which means two blackout ranges in a single day</span>
            <span style="color: #003366; font-weight: bold;">var</span> morning <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>now.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> now.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> now.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                midnight <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>morning.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #CC0000;">24</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">60</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">60</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            maintenanceWindows.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
                start<span style="color: #339933;">:</span> morning<span style="color: #339933;">,</span>
                end<span style="color: #339933;">:</span> endDate
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            maintenanceWindows.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
                start<span style="color: #339933;">:</span> startDate<span style="color: #339933;">,</span>
                end<span style="color: #339933;">:</span> midnight
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> maintenanceWindows<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> m <span style="color: #339933;">=</span> maintenanceWindows<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>nowTime <span style="color: #339933;">&gt;=</span> m.<span style="color: #660066;">start</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> nowTime <span style="color: #339933;">&lt;</span> m.<span style="color: #660066;">end</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now, a few of you might have noticed that the above examples are compatible with one another; you can mix-and-match them as you see fit. Just combine the various maintenance object fields into one config object, combine the contents of all the maintenance methods you want to use (just watch not to overwrite the variable declarations), and you can create something that fits just about any situation.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Monitoring+Maintenance+Windows+http://6n4xf.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.browsermob.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="[Post to Twitter]" border="0" /></a> <a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Monitoring+Maintenance+Windows+http://6n4xf.th8.us" title="Post to Twitter">Tweet This Post</a>&nbsp; </p>]]></content>
		<link rel="replies" type="text/html" href="http://blog.browsermob.com/2010/05/monitoring-maintenance-windows/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://blog.browsermob.com/2010/05/monitoring-maintenance-windows/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://blog.browsermob.com/2010/05/monitoring-maintenance-windows/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>raf</name>
					</author>
		<title type="html"><![CDATA[Integrating BrowserMob with Nagios]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BrowserMob/~3/opZqUVwo0lM/" />
		<id>http://blog.browsermob.com/?p=574</id>
		<updated>2010-05-06T20:50:54Z</updated>
		<published>2010-05-06T20:50:54Z</published>
		<category scheme="http://blog.browsermob.com" term="How To" /><category scheme="http://blog.browsermob.com" term="Monitoring" /><category scheme="http://blog.browsermob.com" term="API" /><category scheme="http://blog.browsermob.com" term="Example" /><category scheme="http://blog.browsermob.com" term="Nagios" /><category scheme="http://blog.browsermob.com" term="tools" />		<summary type="html"><![CDATA[To demonstrate how you can use our new API to leverage deeper integration with your internal monitoring tools, we’re going to guide you through an example that connects Nagios (a ubiquitous open source monitoring tool) with BrowserMob’s web site monitoring service.]]></summary>
		<content type="html" xml:base="http://blog.browsermob.com/2010/05/integrating-browsermob-with-nagios/"><![CDATA[<p>To demonstrate how you can use our new API to leverage deeper integration with your internal monitoring tools, we’re going to guide you through an example that connects Nagios (a ubiquitous open source monitoring tool) with BrowserMob’s web site monitoring service.</p>
<p><strong>Getting it all setup:</strong></p>
<p>Since this is intended to be a quick how-to, we’re going to assume that you already have a working Nagios installation behind your firewall and an active monitoring job with BrowserMob. Here at the BMob we eat our own dog food, utilizing our own monitoring service to monitor BrowserMob.com. For this example, we’ll use a monitoring job called “BMOB” for our Nagios integration.  </p>
<p><strong> What you will need:</strong></p>
<ol>
<li>API Key &#038; API Secret. Log on to browsermob.com with your account and under Home > My Profile you will find your API key and secret.</li>
<li>CLI BrowserMob API tool. Download our nifty API command line tool from <a href="http://github.com/rferreira/bmob-python">http://github.com/rferreira/bmob-python</a></li>
<li>Nagios 3.06. We have it installed on Ubuntu Jaunty for this example.</li>
<li>jsonpretty. This just makes JSON strings human-readable in the CLI. Get it here: <a href="http://github.com/nicksieger/jsonpretty">http://github.com/nicksieger/jsonpretty</a></li>
</ol>
<p><strong>Getting to know your monitoring job:</strong></p>
<p>Before we can actually wire anything into Nagios we need to find out the internal id of a monitoring job. In the BrowserMob web interface monitoring jobs have friendly names like “BMOB”, but internally they are referenced by a unique id such as &#8220;fe33b13dc0764588b5eabf747a96a48b&#8221;. </p>
<p>You will need the monitoring job’s unique id. You can get it by running the following query (replacing the credentials with your own):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>bmob.py <span style="color: #660033;">-c</span> XXX:XXX http:<span style="color: #000000; font-weight: bold;">//</span>browsermob.com<span style="color: #000000; font-weight: bold;">/</span>a<span style="color: #000000; font-weight: bold;">/</span>m<span style="color: #000000; font-weight: bold;">/</span>all <span style="color: #000000; font-weight: bold;">|</span> jsonpretty
<span style="color: #7a0874; font-weight: bold;">&#91;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #ff0000;">&quot;browsers&quot;</span>: <span style="color: #7a0874; font-weight: bold;">&#91;</span>
<span style="color: #ff0000;">&quot;FF3&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#93;</span>,
<span style="color: #ff0000;">&quot;name&quot;</span>: <span style="color: #ff0000;">&quot;BMOB&quot;</span>,
<span style="color: #ff0000;">&quot;lastBilled&quot;</span>: null,
<span style="color: #ff0000;">&quot;alertEmail&quot;</span>: <span style="color: #ff0000;">&quot;support@browsermob.com&quot;</span>,
<span style="color: #ff0000;">&quot;preferenceId&quot;</span>: <span style="color: #ff0000;">&quot;7ea6d3b47c8c4a1c8d30db7fef9d5fd1&quot;</span>,
<span style="color: #ff0000;">&quot;lastRun&quot;</span>: <span style="color: #000000;">1273007522255</span>,
<span style="color: #ff0000;">&quot;deleted&quot;</span>: <span style="color: #c20cb9; font-weight: bold;">false</span>,
<span style="color: #ff0000;">&quot;enabled&quot;</span>: <span style="color: #c20cb9; font-weight: bold;">true</span>,
<span style="color: #ff0000;">&quot;id&quot;</span>: <span style="color: #ff0000;">&quot;fe33b13dc0764588b5eabf747a96a48b&quot;</span>,
<span style="color: #ff0000;">&quot;lastUpdated&quot;</span>: <span style="color: #000000;">1273005121243</span>,
<span style="color: #ff0000;">&quot;frequency&quot;</span>: <span style="color: #000000;">15</span>,
<span style="color: #ff0000;">&quot;locations&quot;</span>: <span style="color: #7a0874; font-weight: bold;">&#91;</span>
<span style="color: #ff0000;">&quot;DALLAS&quot;</span>,
<span style="color: #ff0000;">&quot;SING&quot;</span>,
<span style="color: #ff0000;">&quot;AMS&quot;</span>,
<span style="color: #ff0000;">&quot;NY&quot;</span>,
<span style="color: #ff0000;">&quot;DC&quot;</span>,
<span style="color: #ff0000;">&quot;DUBLIN&quot;</span>,
<span style="color: #ff0000;">&quot;SF&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#93;</span>,
<span style="color: #ff0000;">&quot;scriptId&quot;</span>: <span style="color: #ff0000;">&quot;21312a2da1834f2aa02db73f32037619&quot;</span>,
<span style="color: #ff0000;">&quot;accountId&quot;</span>: <span style="color: #000000;">2</span>,
<span style="color: #ff0000;">&quot;email&quot;</span>: <span style="color: #ff0000;">&quot;raf@browsermob.com&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Look for the “id” property in the JSON response.</p>
<p><strong>Wiring it all up:</strong></p>
<p>Now we need to write a wrapper script to query and parse the API results. Create a file called “check_bmob.sh” with the following contents:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># RETURN CODES:</span>
<span style="color: #007800;">OK</span>=<span style="color: #000000;">0</span>
<span style="color: #007800;">WARNING</span>=<span style="color: #000000;">1</span>
<span style="color: #007800;">CRITICAL</span>=<span style="color: #000000;">2</span>
<span style="color: #007800;">UNKNOWN</span>=<span style="color: #000000;">3</span>
&nbsp;
<span style="color: #007800;">WARNING_T</span>=<span style="color: #000000;">2000</span>
<span style="color: #007800;">CRITICAL_T</span>=<span style="color: #000000;">5000</span>
&nbsp;
<span style="color: #007800;">ID</span>=<span style="color: #ff0000;">&quot;fe33b13dc0764588b5eabf747a96a48b&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># dates</span>
<span style="color: #007800;">START</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> -u  <span style="color: #660033;">--date</span>=<span style="color: #ff0000;">&quot;5 mins ago&quot;</span> +<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span>000
<span style="color: #007800;">END</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> -u  +<span style="color: #000000; font-weight: bold;">%</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span>000
<span style="color: #007800;">RESP</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>bmob-python<span style="color: #000000; font-weight: bold;">/</span>bmob.py <span style="color: #660033;">-d</span> <span style="color: #007800;">metric</span>=responseTime,<span style="color: #007800;">start</span>=<span style="color: #007800;">$START</span>,<span style="color: #007800;">end</span>=<span style="color: #007800;">$END</span>,<span style="color: #007800;">resolution</span>=hour –c XXX:XXX http:<span style="color: #000000; font-weight: bold;">//</span>browsermob.com<span style="color: #000000; font-weight: bold;">/</span>a<span style="color: #000000; font-weight: bold;">/</span>m<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$ID</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tr</span> <span style="color: #ff0000;">&quot;,&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> responseTime <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;:&quot;</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> t <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$RESP</span>
<span style="color: #000000; font-weight: bold;">do</span>
   <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$t</span> <span style="color: #660033;">-gt</span> <span style="color: #007800;">$CRITICAL_T</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
      <span style="color: #000000; font-weight: bold;">then</span>
         <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$t</span>
         <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$CRITICAL</span>
   <span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$t</span> <span style="color: #660033;">-gt</span> <span style="color: #007800;">$WARNING_T</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
      <span style="color: #000000; font-weight: bold;">then</span>
         <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$t</span>
         <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #007800;">$WARNING</span>
   <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

<p>What this script will do is look up the response time for the last 5 minutes and trigger an alert if the response time is greater than the threshold for WARNING_T or CRITICAL_T.</p>
<p>Now, we just need to tell Nagios to use it; the sample config below should do the trick:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># defining the command</span>
define <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    command_name    check_bmob
    command_line    <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>nagios<span style="color: #000000; font-weight: bold;">/</span>plugins<span style="color: #000000; font-weight: bold;">/</span>check_bmob.sh
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
define hostgroup <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    hostgroup_name website
    <span style="color: #7a0874; font-weight: bold;">alias</span> web site
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
define host <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    host_name browsermob.com
    check_command check_http
    <span style="color: #7a0874; font-weight: bold;">alias</span> login-check
    use generic-host
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
define service <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    hostgroup_name                  website
    service_description             response_time
    check_command                   check_bmob
    host_name                       browsermob.com
    use generic-service
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Please keep in mind that Nagios’ configuration files can be–and usually are–fairly complex. The example above is purposely simple and may need to be modified to work in your environment. </p>
<p>If everything works as planned you should be able to log in to the Nagios web interface and see:</p>
<div id="attachment_579" class="wp-caption aligncenter" style="width: 703px"><img class="size-full wp-image-579" title="Nagios using Bmob's API" src="http://blog.browsermob.com/wp-content/uploads/2010/05/Screen-shot-2010-05-04-at-4.23.01-PM-11.png" alt="Pudding" width="693" height="851" /><p class="wp-caption-text">Pudding</p></div>
<p>Official BrowserMob API documentation:</p>
<p><a title="http://cdn.browsermob.com/api.html" href="http://cdn.browsermob.com/api.html">http://cdn.browsermob.com/api.html</a></p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Integrating+BrowserMob+with+Nagios+http://kp79i.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.browsermob.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="[Post to Twitter]" border="0" /></a> <a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Integrating+BrowserMob+with+Nagios+http://kp79i.th8.us" title="Post to Twitter">Tweet This Post</a>&nbsp; </p>]]></content>
		<link rel="replies" type="text/html" href="http://blog.browsermob.com/2010/05/integrating-browsermob-with-nagios/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://blog.browsermob.com/2010/05/integrating-browsermob-with-nagios/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://blog.browsermob.com/2010/05/integrating-browsermob-with-nagios/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>ian</name>
					</author>
		<title type="html"><![CDATA[Introducing the BrowserMob API]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BrowserMob/~3/eqvQvdKf6dg/" />
		<id>http://blog.browsermob.com/?p=596</id>
		<updated>2010-05-06T15:54:43Z</updated>
		<published>2010-05-06T15:54:43Z</published>
		<category scheme="http://blog.browsermob.com" term="Announcements" /><category scheme="http://blog.browsermob.com" term="API" /><category scheme="http://blog.browsermob.com" term="New Feature" />		<summary type="html"><![CDATA[The BrowserMob team is excited to launch our new API, giving customers access to all their data (including load test results and monitoring reports) through a simple programmatic interface.]]></summary>
		<content type="html" xml:base="http://blog.browsermob.com/2010/05/introducing-the-browsermob-api/"><![CDATA[<p>The BrowserMob team is excited to launch our new API, giving customers access to all their data (including load test results and monitoring reports) through a simple programmatic interface. The API is still in beta and will likely change over the next few weeks, but we welcome everyone to take a look, kick the tires, and send us any <a href="mailto:support@browsermob.com">feedback</a>.</p>
<p>Currently the API is &#8220;read only&#8221;, allowing access to load test and monitoring data. We will be adding new services in the coming weeks, including endpoints for creating load tests, monitoring jobs, and working toward complete programmatic access to anything you can do on the BrowserMob website today.</p>
<p>To get started, check out the <a href="http://cdn.browsermob.com/api.html">API documentation</a>. We will be updating the docs as things progress and more endpoints are added. Included in the documentation are links to some simple tools to help you get started quickly, and as always you can <a href="mailto:support@browsermob.com">email</a> the BrowserMob team if you have any questions.</p>
<p>- The BrowserMob Team</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Introducing+the+BrowserMob+API+http://hf2ct.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.browsermob.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="[Post to Twitter]" border="0" /></a> <a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Introducing+the+BrowserMob+API+http://hf2ct.th8.us" title="Post to Twitter">Tweet This Post</a>&nbsp; </p>]]></content>
		<link rel="replies" type="text/html" href="http://blog.browsermob.com/2010/05/introducing-the-browsermob-api/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://blog.browsermob.com/2010/05/introducing-the-browsermob-api/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://blog.browsermob.com/2010/05/introducing-the-browsermob-api/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Patrick Lightbody</name>
						<uri>http://browsermob.com</uri>
					</author>
		<title type="html"><![CDATA[Identifying bottlenecks with New Relic&#8217;s Java profiling tool]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BrowserMob/~3/eOr5VzFb-Y8/" />
		<id>http://blog.browsermob.com/2010/04/identifying-bottlenecks-with-new-relics-java-profiling-tool/</id>
		<updated>2010-04-29T20:19:51Z</updated>
		<published>2010-04-29T20:16:37Z</published>
		<category scheme="http://blog.browsermob.com" term="Load Testing Tips" /><category scheme="http://blog.browsermob.com" term=".NET" /><category scheme="http://blog.browsermob.com" term="dynaTrace" /><category scheme="http://blog.browsermob.com" term="Java" /><category scheme="http://blog.browsermob.com" term="Load Testing" /><category scheme="http://blog.browsermob.com" term="Monitoring" /><category scheme="http://blog.browsermob.com" term="New Relic" /><category scheme="http://blog.browsermob.com" term="Profiler" /><category scheme="http://blog.browsermob.com" term="Untitled" />		<summary type="html"><![CDATA[
A couple weeks ago, New Relic launched a new hosted, on-demand Java profiling tool. We&#8217;re big fans of New Relic (great for Ruby or Java), dynaTrace (great for .NET or Java), and other application performance monitoring tools because they complement our website load testing and website monitoring services so well.



At BrowserMob, we&#8217;re a Java shop, [...]]]></summary>
		<content type="html" xml:base="http://blog.browsermob.com/2010/04/identifying-bottlenecks-with-new-relics-java-profiling-tool/"><![CDATA[<p>
A couple weeks ago, <a href="http://www.newrelic.com/index.html">New Relic</a> launched a new hosted, on-demand <a href="http://www.newrelic.com/profiler.html">Java profiling tool</a>. We&#8217;re big fans of New Relic (great for Ruby or Java), <a href="http://www.dynatrace.com/en/">dynaTrace</a> (great for .NET or Java), and other application performance monitoring tools because they complement our <a href="http://browsermob.com/website-load-testing">website load testing</a> and <a href="http://browsermob.com/website-monitoring">website monitoring</a> services so well.
</p>
<p><img src="http://blog.browsermob.com/wp-content/uploads/2010/04/B89947C6-B587-4107-BE38-889C01D47C09.jpg" width="274" height="172" alt="B89947C6-B587-4107-BE38-889C01D47C09.jpeg" style="float:right;" /></p>
<p>
At BrowserMob, we&#8217;re a Java shop, and so it didn&#8217;t take long for us to have an opportunity to try out New Relic&#8217;s Java profiler. We were getting reports from some customers that viewing the response time charts of their monitoring data was occasionally slow (don&#8217;t worry, we didn&#8217;t miss the irony.)
</p>
<p>
To investigate the problem, we turned on New Relic&#8217;s profiler and selected <strong>5 minutes</strong> of profiler time. You can choose between 1 and 10 minutes as the length of time you want to gather data. During that time, there is a small but potentially noticeable hit in performance on your site, but the upside is that the profiler is able to inspect deep in to our codebase and expose bottlenecks.
</p>
<p>
Five minutes later, we instantly saw the problem:
</p>
<p><img src="http://blog.browsermob.com/wp-content/uploads/2010/04/201004291309.jpg" width="480" height="362" alt="201004291309.jpg" /></p>
<p>
As you can see, during that 5 minute period, 55% of the time was spent on <strong>java.net.SocketInputStream.socketRead</strong>. Tracing back a bit, we were able to see that was from a call by <strong>MonitoringController.selectRangeForObject</strong>. It turned out we were calling a cloud-based data server that was having performance issues due to the way we constructed our API call. It didn&#8217;t take more than a few minutes to optimize the call and roll out the fix.
</p>
<p>
Such is the power of application performance monitoring tools. If you&#8217;re doing any sort of load testing, website monitoring, or page optimizations, you&#8217;re going to be very blind unless you have access to information like this. That&#8217;s why we jumped at the opportunity to partner with New Relic and dynaTrace and encourage all our customers to look at their products.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Identifying+bottlenecks+with+New+Relic%27s+Java+profiling+tool+http://az7qg.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.browsermob.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="[Post to Twitter]" border="0" /></a> <a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Identifying+bottlenecks+with+New+Relic%27s+Java+profiling+tool+http://az7qg.th8.us" title="Post to Twitter">Tweet This Post</a>&nbsp; </p>]]></content>
		<link rel="replies" type="text/html" href="http://blog.browsermob.com/2010/04/identifying-bottlenecks-with-new-relics-java-profiling-tool/#comments" thr:count="7" />
		<link rel="replies" type="application/atom+xml" href="http://blog.browsermob.com/2010/04/identifying-bottlenecks-with-new-relics-java-profiling-tool/feed/atom/" thr:count="7" />
		<thr:total>7</thr:total>
	<feedburner:origLink>http://blog.browsermob.com/2010/04/identifying-bottlenecks-with-new-relics-java-profiling-tool/</feedburner:origLink></entry>
		<entry>
		<author>
			<name>Patrick Lightbody</name>
						<uri>http://browsermob.com</uri>
					</author>
		<title type="html"><![CDATA[Watir and Selenium joining forces for the benefit of all testers and developers]]></title>
		<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/BrowserMob/~3/f9j9vskEkns/" />
		<id>http://blog.browsermob.com/2010/04/watir-and-selenium-joining-forces-for-the-benefit-of-all-testers-and-developers/</id>
		<updated>2010-04-27T14:39:53Z</updated>
		<published>2010-04-27T14:24:48Z</published>
		<category scheme="http://blog.browsermob.com" term="Industry News" /><category scheme="http://blog.browsermob.com" term="Selenium" /><category scheme="http://blog.browsermob.com" term="Watir" /><category scheme="http://blog.browsermob.com" term="WebDriver" />		<summary type="html"><![CDATA[
We&#8217;re a few weeks late to the story, but we think it&#8217;s still important to call attention to: Watir and Selenium are joining forces. For those unfamiliar with Watir or Selenium, both of them are open source browser automation frameworks. For years they have been &#8220;competing&#8221; in the open source community, with Watir winning favor [...]]]></summary>
		<content type="html" xml:base="http://blog.browsermob.com/2010/04/watir-and-selenium-joining-forces-for-the-benefit-of-all-testers-and-developers/"><![CDATA[<p>
We&#8217;re a few weeks late to the story, but we think it&#8217;s still important to call attention to: <a href="http://watirmelon.com/2010/04/10/watir-selenium-webdriver/">Watir and Selenium are joining forces</a>. For those unfamiliar with Watir or Selenium, both of them are open source browser automation frameworks. For years they have been &#8220;competing&#8221; in the open source community, with <a href="http://watir.com/">Watir</a> winning favor among the Ruby community and those who needed strong IE support, while <a href="http://seleniumhq.org/">Selenium</a> won favor among the Java and C# crowds and those who really valued cross-browser support.
</p>
<p>
While both projects had their pluses and minuses, it&#8217;s great to see them finally working together. On behalf of BrowserMob (which builds on top of Selenium) and as a Selenium contributor, it pleases me to know end to know that the Selenium community will now gain two huge contributions: a first-class Ruby API and all the benefits of Watir&#8217;s fantastic IE support.
</p>
<p>
Note: this is not a merger. Watir will continue to run as an independent project and it will even still work with it&#8217;s own browser backend. The important thing here is that Watir will now offer an option to wrap around Selenium WebDriver, the core cross-browser automation library that all the other Selenium projects also wrap around. This means that while the projects will remain independent there will likely be a lot more cooperation moving forward.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Watir+and+Selenium+joining+forces+for+the+benefit+of+all+testers+and+developers+http://otxby.th8.us" title="Post to Twitter"><img class="nothumb" src="http://blog.browsermob.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="[Post to Twitter]" border="0" /></a> <a class="tt" href="http://twitter.com/home/?status=BrowserMob:+Watir+and+Selenium+joining+forces+for+the+benefit+of+all+testers+and+developers+http://otxby.th8.us" title="Post to Twitter">Tweet This Post</a>&nbsp; </p>]]></content>
		<link rel="replies" type="text/html" href="http://blog.browsermob.com/2010/04/watir-and-selenium-joining-forces-for-the-benefit-of-all-testers-and-developers/#comments" thr:count="0" />
		<link rel="replies" type="application/atom+xml" href="http://blog.browsermob.com/2010/04/watir-and-selenium-joining-forces-for-the-benefit-of-all-testers-and-developers/feed/atom/" thr:count="0" />
		<thr:total>0</thr:total>
	<feedburner:origLink>http://blog.browsermob.com/2010/04/watir-and-selenium-joining-forces-for-the-benefit-of-all-testers-and-developers/</feedburner:origLink></entry>
	</feed><!-- Dynamic Page Served (once) in 1.071 seconds --><!-- Cached page generated by WP-Super-Cache on 2010-07-29 06:01:13 -->
