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

<channel>
	<title>Opsview Labs &#187; Development</title>
	<atom:link href="http://labs.opsview.com/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.opsview.com</link>
	<description>Opsview&#039;s Engineering Blog</description>
	<lastBuildDate>Fri, 20 Jan 2012 09:32:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Monitoring Apache Solr with Opsview</title>
		<link>http://labs.opsview.com/2011/12/monitoring-apache-solr-with-opsview/</link>
		<comments>http://labs.opsview.com/2011/12/monitoring-apache-solr-with-opsview/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 14:58:29 +0000</pubDate>
		<dc:creator>rbramley</dc:creator>
				<category><![CDATA[Configuration]]></category>
		<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[JMX]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[System Management]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[agentless checks]]></category>
		<category><![CDATA[apache solr]]></category>
		<category><![CDATA[Lucene]]></category>
		<category><![CDATA[nrpe]]></category>
		<category><![CDATA[Opsview]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/?p=2012</guid>
		<description><![CDATA[
			
				
			
		Apache Solr is an open source enterprise search service from the Lucene project. Solr is written in Java and runs as a standalone full-text search server within a servlet container such as Tomcat.
Like any service or component in your architecture, you’ll want to monitor it to ensure that it’s available and gather performance data to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2011%2F12%2Fmonitoring-apache-solr-with-opsview%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2011%2F12%2Fmonitoring-apache-solr-with-opsview%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p><a href="http://labs.opsview.com/wp-content/uploads/2011/12/solr.jpg"><img class="alignleft size-full wp-image-2027" title="solr" src="http://labs.opsview.com/wp-content/uploads/2011/12/solr.jpg" alt="monitoring Apache Solr" width="150" height="83" /></a><a title="Apache Solr" href="http://lucene.apache.org/solr/">Apache Solr</a> is an open source enterprise search service from the Lucene project. Solr is written in Java and runs as a standalone full-text search server within a servlet container such as Tomcat.</p>
<p>Like any service or component in your architecture, you’ll want to monitor it to ensure that it’s available and gather performance data to help with tuning.</p>
<p>In this post, we’ll look at how we can monitor Solr, what performance metrics we might want to gather and how we can easily achieve this with Opsview.</p>
<p><span id="more-2012"></span></p>
<div style="border: 1px solid #ccc; background-color: #f5f5f5; padding: 8px;">
<h2>Requirements</h2>
<ul>
<li>Installed version of Opsview <a title="Download Opsview" href="http://www.opsview.com/downloads">[download]</a></li>
<li>Apache Solr Custom Plugin <a title="Download Apache Solr Custom Plugin" href="https://github.com/rbramley/Opsview-solr-checks">[download]</a></li>
</ul>
</div>
<p><br /></p>
<h2>A check list for service checks</h2>
<p>Solr is built on Lucene so follows the same layout, an index contains documents that are comprised of fields. As part of the search service value add over Lucene, Solr provides a number of useful ways of obtaining health status / monitoring metrics:</p>
<ol>
<li>Health-check status using the <em>/admin/ping</em> handler</li>
<li>The admin statistics page <em>/admin/stats.jsp</em> (XML styled with XSL)</li>
<li><a href="http://wiki.apache.org/solr/SolrJmx">JMX MBeans</a></li>
</ol>
<p>The list of applicable checks could be defined by whether it is a health check or a data gathering check – but this would lead to a lot of overlap. Instead the list is divided into the checks that can be performed remotely (without an installed agent on the server) and those that are best performed locally to the Solr server.</p>
<h2>Remote (agent-less) checks</h2>
<p>What should we look for over the network?</p>
<p>Firstly we can have a host-level check which may perform a network level ping. Next we can check TCP connectivity to the servlet container port and then make an HTTP GET request to the Solr ‘front page’ and check for a known string (e.g. Welcome to Solr).</p>
<p>Now we’ve made it up to the application layer so can start to perform Solr specific checks.</p>
<p>Items to monitor may include (delete as applicable):</p>
<ol>
<li>Ping status</li>
<li>Number of docs</li>
<li>Number of queries / queries per second</li>
<li>Average response time</li>
<li>Number of updates</li>
<li>Cache hit ratios</li>
<li>Replication status</li>
<li>Synthetic queries</li>
</ol>
<h2>Agent-based checks</h2>
<p>Installing an <a title="Opsview Agents" href="http://www.opsview.com/downloads/opsview-agents">Opsview agent</a> on the Solr server means we can run additional checks over NRPE (Nagios Remote Plugin Executor). This could be operating system level checks such as memory/disk utilisation or CPU load, or the following:</p>
<ol>
<li>Java servlet container process is running</li>
<li>JMX checks e.g. heap memory or custom MBeans</li>
<li>File age</li>
<li>Log parsing for exceptions</li>
</ol>
<p>The Solr wiki describes how to configure JMX support: <a title="Configure JMX support" href="http://wiki.apache.org/solr/SolrJmx">http://wiki.apache.org/solr/SolrJmx.</a></p>
<h2>Opsview configuration</h2>
<p>For the rest of this article you&#8217;ll need to have <a title="Download Opsview" href="http://www.opsview.com/downloads">Opsview</a> installed (or the <a title="Opsview VMWare Appliance" href="http://www.opsview.com/downloads/opsview-3-vmware-virtual-appliance">Opsview VMWare appliance</a>) and have completed the <a title="Opsview Quick Start Guide" href="http://docs.opsview.com/doku.php?id=opsview3.14:quickstart">Quick Start.</a></p>
<h2>Solr-specific Plugin</h2>
<p>Install the Solr plugin at <a title="Opsview Solr Plugin" href="https://github.com/rbramley/Opsview-solr-checks">https://github.com/rbramley/Opsview-solr-checks</a> into /usr/local/nagios/libexec/</p>
<p>The check_solr plugin was developed using Perl, so that it could be contributed back to Opsview. It requires the CPAN XML::XPath module (sudo cpan -i XML::XPath).</p>
<p>The plugin includes usage instructions, check_solr -h which can also be viewed in Opsview by selecting the ‘Show Plugin Help‘ link beneath the Plugin drop down (see Figure 1). The -u option can be used to specify the URL path for multi-core set-ups.</p>
<h2>Service check setup</h2>
<p>Figure 1 gives an example of a service check configuration.</p>
<p><a href="http://labs.opsview.com/wp-content/uploads/2011/12/figure_1_with_help.png"><img class="aligncenter size-full wp-image-2013" title="figure_1_with_help" src="http://labs.opsview.com/wp-content/uploads/2011/12/figure_1_with_help.png" alt="Opsview service check configuration." width="542" height="699" /></a></p>
<p>Figure 2 shows the <em>agentless</em> service check group with plugins and their arguments.</p>
<p><a href="http://labs.opsview.com/wp-content/uploads/2011/12/solr-agentless-monitoring1.png"><img class="aligncenter size-full wp-image-2015" title="solr-agentless-monitoring" src="http://labs.opsview.com/wp-content/uploads/2011/12/solr-agentless-monitoring1.png" alt="solr agentless monitoring" width="500" height="252" /></a></p>
<h2>Host configuration</h2>
<p>Figure 3 shows a simplistic host setup with a ping check.</p>
<p><a href="http://labs.opsview.com/wp-content/uploads/2011/12/set_up_host1.png"><img class="aligncenter size-full wp-image-2017" title="set_up_host" src="http://labs.opsview.com/wp-content/uploads/2011/12/set_up_host1.png" alt="set up host" width="500" height="596" /></a></p>
<p>Figure 4 is an extract from the <strong>Monitors</strong> tab, where we select the checks we want performed for the current host.</p>
<p><a href="http://labs.opsview.com/wp-content/uploads/2011/12/monitors.png"><img class="aligncenter size-full wp-image-2018" title="monitors" src="http://labs.opsview.com/wp-content/uploads/2011/12/monitors.png" alt="monitors" width="288" height="226" /></a></p>
<h2>Viewing output</h2>
<p>The check results shown in Figure 5 are visible by navigating through the host group hierarchy.</p>
<p><a href="http://labs.opsview.com/wp-content/uploads/2011/12/viewing-output.png"><img class="aligncenter size-full wp-image-2019" title="viewing-output" src="http://labs.opsview.com/wp-content/uploads/2011/12/viewing-output.png" alt="" width="500" height="192" /></a></p>
<p><a href="http://labs.opsview.com/wp-content/uploads/2011/12/viewing-output.png"></a>If you click on the graph icon of <em>Solr Cache Hit Ratios</em> this will drill down onto the graph shown in Figure 6.</p>
<p>Clicking on the graph icon for <em>Solr Avg Response Time – standard</em> will take you to the graphs in Figure 7.</p>
<p><a href="http://labs.opsview.com/wp-content/uploads/2011/12/cache_hit_ratios.png"><img class="aligncenter size-full wp-image-2021" title="cache_hit_ratios" src="http://labs.opsview.com/wp-content/uploads/2011/12/cache_hit_ratios.png" alt="cache hit ratios" width="500" height="209" /></a><a href="http://labs.opsview.com/wp-content/uploads/2011/12/avg_req_time.png"><img class="aligncenter size-full wp-image-2022" title="avg_req_time" src="http://labs.opsview.com/wp-content/uploads/2011/12/avg_req_time.png" alt="average request time" width="500" height="449" /></a></p>
<p>If you shutdown Solr, then the check results will start to turn critical and show in red as per Figure 8.</p>
<p><a href="http://labs.opsview.com/wp-content/uploads/2011/12/post-shutdown-alert.png"><img class="aligncenter size-full wp-image-2023" title="post-shutdown-alert" src="http://labs.opsview.com/wp-content/uploads/2011/12/post-shutdown-alert.png" alt="post shoutdown alert" width="500" height="197" /></a></p>
<h2>Alternatives</h2>
<p>There are a few other plugins available for monitoring Solr from Opsview, depending on your needs:</p>
<ul>
<li><a href="http://code.google.com/p/nagios-plugins-shamil/">http://code.google.com/p/nagios-plugins-shamil</a> – provides ping, replication status and num docs</li>
<li><a href="http://code.google.com/p/solr-nagios-check">http://code.google.com/p/solr-nagios-check</a> – provides QPS, response time and num docs</li>
</ul>
<p>Also, chapter 8 of the recently published <a href="http://www.amazon.co.uk/gp/product/1849516065/ref=as_li_ss_tl?ie=UTF8&amp;tag=leanjavaengi-21&amp;linkCode=as2&amp;camp=1634&amp;creative=19450&amp;creativeASIN=1849516065">Apache Solr 3 Enterprise Search Server</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=leanjavaengi-21&amp;l=as2&amp;o=2&amp;a=1849516065" border="0" alt="" width="1" height="1" /> book includes a section on Monitoring Solr Performance.</p>
<h2>Summary</h2>
<p>Using <em>check_solr</em> in conjunction with <a title="Opsview Open Source Monitoring" href="http://www.opsview.com">Opsview</a> allows you to  ensure that your Solr server is available and provides you with metrics  that can help you tune your Solr configuration.</p>
<p>This can be complemented  with additional agent-based operating system and JMX checks to give you  a full picture view.</p>
<div>
<div style="border: 1px solid #ccc; background-color: #f5f5f5; padding: 8px;">
<h3>About the Author</h3>
<p>Robin Bramley is a hands-on Technical Manager / Lead Architect at an Open Source software &amp; services company who has spent the majority of the last decade working with Java, mobile &amp; Open Source across sectors including Financial Services &amp; High Growth / start-ups. You can view Robin&#8217;s personal blog at <a href="http://leanjavaengineering.wordpress.com/">www.leanjavaengineering.com</a></p>
<h4>Legal Disclaimer</h4>
<p>This blog post is contributed by a member of the Opsview community.  The Opsview project and Opsera Ltd accept no responsibility for the  accuracy of its content and are not liable for any direct or indirect  damages caused by its use.</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2011/12/monitoring-apache-solr-with-opsview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Managing security permissions for large teams in Opsview</title>
		<link>http://labs.opsview.com/2011/04/managing-security-permissions-for-large-teams-in-opsview/</link>
		<comments>http://labs.opsview.com/2011/04/managing-security-permissions-for-large-teams-in-opsview/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 10:34:10 +0000</pubDate>
		<dc:creator>tonvoon</dc:creator>
				<category><![CDATA[Catalyst]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[MSPs]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Opsview]]></category>
		<category><![CDATA[System Management]]></category>
		<category><![CDATA[Unix / Linux]]></category>
		<category><![CDATA[business systems]]></category>
		<category><![CDATA[multi-tenancy]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/?p=819</guid>
		<description><![CDATA[
			
				
			
		Hindsight is a wonderful thing.
In hindsight, Opsview would have always had access controls for objects at the role level &#8211; since roles also define which parts of the Opsview application you can get to, it would make sense to also put all the host and service objects into this definition.
(In our defence, we wanted to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2011%2F04%2Fmanaging-security-permissions-for-large-teams-in-opsview%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2011%2F04%2Fmanaging-security-permissions-for-large-teams-in-opsview%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p><a class="lightbox" title="img-secure" href="http://labs.opsview.com/wp-content/uploads/2011/04/img-secure.png"><img class="alignleft size-full wp-image-832" title="img-secure" src="http://labs.opsview.com/wp-content/uploads/2011/04/img-secure.png" alt="" width="168" height="168" /></a>Hindsight is a wonderful thing.</p>
<p>In hindsight, Opsview would have always had <a href="http://docs.opsview.com/doku.php?id=opsview3.12:access">access controls</a> for objects at the <a href="http://docs.opsview.com/doku.php?id=opsview3.12:role">role level</a> &#8211; since roles also define which parts of the Opsview application you can get to, it would make sense to also put all the host and service objects into this definition.</p>
<p>(In our defence, we wanted to make it as obvious as possible for a contact when you were changing access information.)</p>
<p>The downside of our design decision many years ago is that Opsview administrators who have lots of their users – or <a href="http://docs.opsview.com/doku.php?id=opsview3.12:contact">contacts</a> in Opsview terms – with the same sort of access and were having to change each user individually. This was painful and error prone if you had 40 &#8220;similar&#8221; users.<span id="more-819"></span></p>
<p>So <a href="http://www.opsview.com/products/opsview-enterprise">Opsview Enterprise 3.12.0</a> now has access information in the role definition. You change access at the role level and it automatically affects all users of that role. Even better, we ensure that a user&#8217;s notification profile only has references to the objects they are allowed &#8211; change the role definitions and object references will be <a href="http://docs.opsview.com/doku.php?id=opsview3.12:role#authorised_for_host_groups">automatically removed</a> from all aspects of that contact.</p>
<p>Now you can administer users in a much simpler way.</p>
<p>Hindsight &#8211; we wish we had more of it.</p>
<p>But the next best thing to hindsight &#8211; migratability.</p>
<h2>Migratability?</h2>
<p>The Opsview configuration database is <a href="http://www.ibm.com/developerworks/web/library/wa-dbdsgn2.html">normalised</a> and models the data as it is. Some application designers like to use key-value pairs to describe their data, which is nice from an expandable point of view, but rubbish when it comes to actually accessing that data in a meaningful way. When it comes to modelling our data, we model it &#8211; we don&#8217;t &#8220;meta-model&#8221; it.</p>
<p>We care a lot about people&#8217;s data because we build up a trust with our users that they can upgrade and bring their platform right up to date with the latest versions of Opsview. So we spend a lot of time getting the upgrade scripts just right.</p>
<p>If you are upgrading to Opsview 3.12, here&#8217;s what the upgrade scripts do:</p>
<ul>
<li>for each contact, it will see if this contact&#8217;s role has access information applied</li>
<li>if it hasn&#8217;t, it will use this contact&#8217;s access information to populate the role</li>
<li>if the role already has access information (from another contact), then it will compare all the current roles with their access information and if there is a match, this role is used</li>
<li>if it isn&#8217;t exactly the same, then a new role is created called &#8220;old role name &#8211; contact&#8221;</li>
</ul>
<p>So for example, let&#8217;s say you have 4 contacts &#8211; John, Paul, George and Ringo &#8211; all using the &#8220;Liverpool administrators&#8221; role.</p>
<p style="text-align: center;"><a class="lightbox" title="contact_list_preupgrade" href="http://labs.opsview.com/wp-content/uploads/2011/03/contact_list_preupgrade1.png"><img class="size-medium wp-image-821 aligncenter" title="contact_list_preupgrade" src="http://labs.opsview.com/wp-content/uploads/2011/03/contact_list_preupgrade1-300x129.png" alt="" width="300" height="129" /></a></p>
<p>The first three have their access information the same, but Ringo has missed out the <em>Production &#8211; Slicehost Servers</em> host group he should have had access to.</p>
<p style="text-align: center;"><a class="lightbox" title="ringo_config" href="http://labs.opsview.com/wp-content/uploads/2011/03/ringo_config.png"><img class="size-medium wp-image-818 aligncenter" title="ringo_config" src="http://labs.opsview.com/wp-content/uploads/2011/03/ringo_config-300x221.png" alt="" width="300" height="221" /></a></p>
<p>After the upgrade, the first three would still have the role of <em>Liverpool administrators</em>, but Ringo would have the role of a newly created <em>Liverpool administrators &#8211; ringo</em>. You could easily tell from this that Ringo should belong to the Liverpool administrators, so you can set him to this. Otherwise, maybe he is different after all, so you can rename the role to <em>Liverpool drummers</em>.</p>
<p style="text-align: center;"><a class="lightbox" title="contact_list_postupgrade" href="http://labs.opsview.com/wp-content/uploads/2011/03/contact_list_postupgrade.png"><img class="size-medium wp-image-822 aligncenter" title="contact_list_postupgrade" src="http://labs.opsview.com/wp-content/uploads/2011/03/contact_list_postupgrade-300x129.png" alt="" width="300" height="129" /></a></p>
<p>This means that most of the configuration for this new functionality is done for you automatically and you can think of your users in their role groups, rather than individually. Another step to making Opsview easier to use.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2011/04/managing-security-permissions-for-large-teams-in-opsview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Next generation distributed monitoring, the Opsview way</title>
		<link>http://labs.opsview.com/2011/01/next-generation-distributed-monitoring-the-opsview-way/</link>
		<comments>http://labs.opsview.com/2011/01/next-generation-distributed-monitoring-the-opsview-way/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 10:50:01 +0000</pubDate>
		<dc:creator>tonvoon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Opsview]]></category>
		<category><![CDATA[distributed monitoring]]></category>
		<category><![CDATA[Nagios]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/?p=751</guid>
		<description><![CDATA[
			
				
			
		One of Opsview&#8217;s great features is distributed monitoring, which we&#8217;ve had for over 5 years now. From the web user interface, you can assign hosts to a slave system and Opsview will take care of all the configuration work for you: from the slave configuration files, to the slave results sent to the master, to [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2011%2F01%2Fnext-generation-distributed-monitoring-the-opsview-way%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2011%2F01%2Fnext-generation-distributed-monitoring-the-opsview-way%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><div id="attachment_765" class="wp-caption alignleft" style="width: 126px"><a class="lightbox" title="communityIcon" href="http://www.opsview.com/downloads/opsview-3-vmware-virtual-appliance"><img class="size-full wp-image-765   " style="margin: 0pt 10px 5px 0pt;" title="communityIcon" src="http://labs.opsview.com/wp-content/uploads/2011/01/communityIcon.png" alt="Opsview Community 3.11 - the next generation of distributed monitoring for free" width="116" height="116" /></a><p class="wp-caption-text">Opsview Community 3.11 - Free distributed monitoring</p></div>
<p>One of Opsview&#8217;s great features is distributed monitoring, which we&#8217;ve had for over 5 years now. From the web user interface, you can assign hosts to a slave system and Opsview will take care of all the configuration work for you: from the slave configuration files, to the slave results sent to the master, to the master configuration with freshness checking.</p>
<p>We do all the system integration work, so you don&#8217;t have to.</p>
<p><span id="more-751"></span>However, there are some limitations in our chosen technologies. We use <a href="http://nagios.sourceforge.net/docs/3_0/addons.html#nsca">NSCA</a>, which is the most <a href="http://nagios.sourceforge.net/docs/3_0/distributed.html">common method</a> in the Nagios&amp;reg; world, and while we&#8217;ve <a href="http://labs.opsview.com/tag/nsca/">made improvements</a> to it that have gone back upstream, there are some baked-in limitations:</p>
<ul>
<li>Only the first 511 bytes of plugin output was returned to the master, limiting the usefulness of the information you could display</li>
<li>Only the 1st line of data was returned, meaning you had to cram output together</li>
<li>NSCA communication used fixed size packets which were inefficient</li>
<li>While results were sent, Nagios would wait for completion, introducing a bottleneck</li>
<li>If there was a communication problem with the master, results were dropped</li>
</ul>
<p>Sometimes to move forward, you have to leave the past behind.</p>
<p>So we did that &#8211; we ripped out NSCA from Opsview&#8217;s slave communications and we&#8217;ve addressed every one of these limitations &#8211; and added a few nice extras too!</p>
<p>We&#8217;ve chosen <a href="http://code.google.com/p/nrd/">NRD</a> (Nagios Result Distributor) as our core technology. This is a library, written by one of our partners, <a href="http://capside.com/">CAPSiDE</a>. There are many reasons we chose this, but the top four are:</p>
<ul>
<li>It is based on perl, which is our language of choice</li>
<li>It has taken the test suite we developed for <a href="http://labs.opsview.com/2007/01/the-importance-of-being-earnestly-tested/">NSCA</a> and enhanced it, demonstrating a mature approach to code development</li>
<li>The client and server code is a thin shim over the libraries, which means you can easily create your own clients</li>
<li>We have a good relationship with CAPSiDE and they have given us access to their code repository</li>
</ul>
<p>We&#8217;ve spent some time understanding the core NRD code, enhancing it, fixing some issues and adding in some great new features. CAPSiDE have also released it on <a href="http://search.cpan.org/dist/NRD-Daemon/lib/NRD/Daemon.pm">CPAN</a> for wider consumption.</p>
<p>So Opsview&#8217;s new process for sending results from a slave is:</p>
<p style="text-align: center;"><a class="lightbox" title="NRD architecture" href="http://labs.opsview.com/wp-content/uploads/2011/01/NRD-architecture.png"><img class="size-medium wp-image-754 aligncenter" title="NRD architecture" src="http://labs.opsview.com/wp-content/uploads/2011/01/NRD-architecture-300x279.png" alt="" width="300" height="279" /></a></p>
<p>A couple of other amazing features we&#8217;ve squeezed in:</p>
<ul>
<li>A known Nagios limitation is the named pipe to submit results. We&#8217;ve overcome this by writing directly to the checkresults spool directory &#8211; this reduces a Nagios processing cycle on the Opsview master</li>
<li>We&#8217;ve implemented transactions in the results, so if the client has a failure communicating to the server, the client will back off and retry again in 5 seconds. This guarantees you do not have duplicated results</li>
<li>The nrd daemon on the master will dynamically add more servers as workload increases, thanks to the features of <a href="http://search.cpan.org/dist/Net-Server/lib/Net/Server.pod">Net::Server</a></li>
<li>As all communication between master and slaves is over a tunnelled SSH session, we&#8217;ve updated our Opsview check scripts to restart these tunnels if the slave is exhibiting communication errors</li>
</ul>
<p>With all this extra capabilities, you would think there is a cost in performance. But in fact, our testing shows that performance has got better!</p>
<p style="text-align: center;"><a class="lightbox" title="nrd performance table" href="http://labs.opsview.com/wp-content/uploads/2011/01/nrd-performance-table.png"><img class="size-medium wp-image-755 aligncenter" title="nrd performance table" src="http://labs.opsview.com/wp-content/uploads/2011/01/nrd-performance-table-300x62.png" alt="" width="300" height="62" /></a></p>
<p>(Based on sending 2016 results in a single transaction over an SSH tunnel from a slave to a master. Times measured on the client.)</p>
<p>This shows that we are getting an average 62% improvement in all aspects of slave communication back to the master!</p>
<p>We are thrilled we&#8217;ve added this major new functionality into Opsview and have taken distributed monitoring another huge step further over any of our competitors.</p>
<p>But the best thing is: this is available immediately with our Opsview Community 3.11 release. Install the VM, add a slave and you will get this new architecture setup as part of the process. And if you are an existing Opsview user, you get a silky smooth switch-over. We&#8217;ve done a lot of testing to ensure that as part of the upgrade, Opsview will automatically switch any slaves to this architecture and start sending results in the new NRD way.</p>
<p style="text-align: center;"><a title="Download Opsview VM Appliance" href="http://www.opsview.com/downloads/opsview-3-vmware-virtual-appliance"><img class="size-full wp-image-762 aligncenter" title="downloadNow_gb" src="http://labs.opsview.com/wp-content/uploads/2011/01/downloadNow_gb.png" alt="" width="197" height="42" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2011/01/next-generation-distributed-monitoring-the-opsview-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nagios bugs and how to fix them permanently</title>
		<link>http://labs.opsview.com/2011/01/nagios-bugs-and-how-to-fix-them-permanently/</link>
		<comments>http://labs.opsview.com/2011/01/nagios-bugs-and-how-to-fix-them-permanently/#comments</comments>
		<pubDate>Tue, 11 Jan 2011 16:53:25 +0000</pubDate>
		<dc:creator>tonvoon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[Hudson]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/?p=707</guid>
		<description><![CDATA[
			
				
			
		We&#8217;ve just fixed a bug in Nagios® which an Opsview user had raised to us. A change made to Nagios in version 3.2.2 caused an issue where service alerts were being raised in the nagios.log file for every result that came back from a host that was down. This had the impact of adding lots [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2011%2F01%2Fnagios-bugs-and-how-to-fix-them-permanently%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2011%2F01%2Fnagios-bugs-and-how-to-fix-them-permanently%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p>We&#8217;ve just fixed a bug in Nagios® which an <a href="http://opsview.com">Opsview</a> user had raised to us. A <a href="http://tracker.nagios.org/view.php?id=128">change made to Nagios</a> in version 3.2.2 caused an issue where service alerts were being raised in the <em>nagios.log</em> file for every result that came back from a host that was down. This had the impact of adding lots of extra alerts that were overwhelming <a href="http://www.opsview.com/learn/screenshots">Opsview&#8217;s event views</a>.</p>
<p><span id="more-707"></span>To reproduce the problem in Nagios 3.2.3:</p>
<ol>
<li>Create a host with 2 service checks</li>
<li>Let this run normally</li>
<li>Shutdown the host</li>
<li>The first service check will notice the state change and set the host to be checked. It will go into a SOFT state and the service will go into a check attempt of 2 and continue into a hard state correctly</li>
<li>The 2nd service check will see that the host is DOWN and force a hard state failure with check attempt 1 of a maximum 4. However, this hard state change did not set the last_hard_state flag correctly, which meant every subsequent check was considered to be a new hard state failure and hence a SERVICE ALERT was raised every time in <em>nagios.log</em></li>
</ol>
<p>This took a long time to track down, but we&#8217;ve found the problem and fixed it. Our fix is pushed to Nagios <a href="http://article.gmane.org/gmane.network.nagios.cvs/3045">already</a>.</p>
<p>While this bug is annoying, we&#8217;re upset that this had an impact on a customer system. We make it our principle to keep as up to date with Nagios as possible because Opsview is a <em>shallow fork</em> of Nagios &#8211; we make only the changes that are necessary to support our customers and we push our changes back upstream where we can.</p>
<p>We&#8217;ve developed a lot of trust with our users &#8211; we make the upgrade process for Opsview as easy as possible because we want all our users to get to the latest version (in fact, we&#8217;ve just had one user update their Opsview from 4 years ago, right up to the latest version, going through over a hundred database changes!).</p>
<p>One thing we do to make sure our systems work as expected, is to continuously test our latest versions of Opsview. We use <a href="http://hudson-ci.org/">Hudson</a> to test Opsview on every change &#8211; currently this runs 5269 individual tests, taking 1 hour 46 minutes.</p>
<p>We want to bring this level of quality assurance to Nagios &#8211; included in our fix is a <a href="http://article.gmane.org/gmane.network.nagios.cvs/3046">test case</a> that checks exactly this issue. Running tests on Nagios will now show that this problem is fixed forever and our nightly builds of Opsview includes these too.</p>
<p>So now everyone can sleep easier knowing that this problem is never going to happen again.</p>
<p><small>Please note: Nagios, the Nagios logo, and Nagios graphics are the servicemarks,  trademarks, or registered trademarks owned by Nagios Enterprises</small></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2011/01/nagios-bugs-and-how-to-fix-them-permanently/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internationalising Catalyst, Part 2</title>
		<link>http://labs.opsview.com/2010/12/internationalising-catalyst-part-2/</link>
		<comments>http://labs.opsview.com/2010/12/internationalising-catalyst-part-2/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 09:17:41 +0000</pubDate>
		<dc:creator>tonvoon</dc:creator>
				<category><![CDATA[Catalyst]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Frameworks]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/?p=699</guid>
		<description><![CDATA[
			
				
			
		We present the 2nd part to our Catalyst advent calendar entry about internationalising your Catalyst application, complete with some really neat scripts such as automatically translating your string using Google! See it here. Enjoy!
]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F12%2Finternationalising-catalyst-part-2%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F12%2Finternationalising-catalyst-part-2%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p><a class="lightbox" title="catalyst_logo" href="http://labs.opsview.com/wp-content/uploads/2010/12/catalyst_logo.png"><img class="alignleft size-full wp-image-696" style="margin: 0pt 10px 5px 0pt;" title="catalyst_logo" src="http://labs.opsview.com/wp-content/uploads/2010/12/catalyst_logo.png" alt="" width="103" height="146" /></a>We present the <a href="http://bit.ly/eECIOH">2nd part</a> to our <a href="http://catalystframework.org">Catalyst</a> advent calendar entry about <a href="http://bit.ly/g2SzQb">internationalising your Catalyst application</a>, complete with some really neat scripts such as automatically translating your string using Google! See it <a href="http://bit.ly/eECIOH">here</a>. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2010/12/internationalising-catalyst-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turning ideas into features: Part 1</title>
		<link>http://labs.opsview.com/2010/12/turning-ideas-into-features-part-1/</link>
		<comments>http://labs.opsview.com/2010/12/turning-ideas-into-features-part-1/#comments</comments>
		<pubDate>Thu, 02 Dec 2010 09:20:41 +0000</pubDate>
		<dc:creator>James Peel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Opsview]]></category>
		<category><![CDATA[customer survey]]></category>
		<category><![CDATA[feedback]]></category>
		<category><![CDATA[james peel]]></category>
		<category><![CDATA[roadmap]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/?p=647</guid>
		<description><![CDATA[
			
				
			
		I thought it might be interesting if I provided some insight into how we decide which features are included in each Opsview release cycle.

The long and winding roadmap
We are very lucky to have a committed user community and this is a great source of feedback and ideas. Part of my role is to work with [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F12%2Fturning-ideas-into-features-part-1%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F12%2Fturning-ideas-into-features-part-1%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p><a class="lightbox" title="roadmap" href="http://labs.opsview.com/wp-content/uploads/2010/12/roadmap.jpg"><img class="size-full wp-image-650 alignleft" style="margin: 0pt 10px 7px 0pt;" title="roadmap" src="http://labs.opsview.com/wp-content/uploads/2010/12/roadmap.jpg" alt="" width="180" height="135" /></a>I thought it might be interesting if I provided some insight into how we decide which features are included in each <a href="http://www.opsview.com">Opsview</a> release cycle.</p>
<p><span id="more-647"></span></p>
<h3>The long and winding roadmap</h3>
<p>We are very lucky to have a committed user community and this is a great source of feedback and ideas. Part of my role is to work with customers and prospective customers to figure out how to get the most out of Opsview in their IT environments. This is another extremely valuable source of feedback about how existing features could be developed and which new features we should be considering. One of our biggest challenges is taking all of these great ideas and figuring out which ones the product development team should work on.</p>
<p>Ideas are captured in our Atlassian JIRA system and this forms the feature backlog. For a feature to move from the backlog to the product roadmap it goes through a scoring and review process. This allows us to work out what the relative priorities are and how much effort will be involved in developing the feature. The scoring system takes into account the following factors:</p>
<ul>
<li>Opsview Enterprise customer feedback</li>
<li>Opsview Community feedback</li>
<li>Feedback from pre-sales discussions with potential customers</li>
<li>Input from the Opsview team</li>
<li>Where the feature sits in terms of our long term product strategy</li>
<li>The level of complexity involved in developing the feature</li>
</ul>
<p>The resulting score helps us to narrow down the feature backlog to a roadmap covering the next year of releases. Usually this comprises three Community release cycles with corresponding Enterprise releases. The roadmap is under constant refinement and there is always scope to insert features or change priorities. This allows us to remain flexible and responsive.</p>
<p>If a feature is sponsored it will usually take priority. Features requested by our customers receive a higher weighting however the features appearing top on the roadmap are usually those where there is a high level combined of interest from customers, pre-sales and community users.</p>
<h3>From concept to code</h3>
<p>Customer / Community (User) feedback is our primary source of feature ideas since this means we&#8217;re always addressing &#8216;real&#8217; issues.  Our challenge is to translate ideas into more concrete feature specifications and then into code. This is where the Opsview team&#8217;s creativity is involved, spotting related threads, designing solutions that will work for everyone and figuring out the tricky details.</p>
<p><strong>In Part 2: <a href="http://labs.opsview.com/2010/12/turning-ideas-into-features-part-2/">How our recent Customer Survey has influenced the Product Roadmap</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2010/12/turning-ideas-into-features-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparing APIs: Opsview and Icinga</title>
		<link>http://labs.opsview.com/2010/09/comparing-apis-opsview-and-icinga/</link>
		<comments>http://labs.opsview.com/2010/09/comparing-apis-opsview-and-icinga/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 08:32:56 +0000</pubDate>
		<dc:creator>tonvoon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Opsview]]></category>
		<category><![CDATA[Unix / Linux]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[icinga]]></category>
		<category><![CDATA[hostgroup hierarchy]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/?p=533</guid>
		<description><![CDATA[
			
				
			
		So, what&#8217;s up in the Opsview&#8217;s world?
We&#8217;re comparing APIs. A user was asking how Opsview&#8217;s API compares to Icinga&#8217;s API. We spent a bit of time investigating what the competition are up to.
What&#8217;s an API?
According to Wikipedia, an Application Programming Interface is a way of having two programs talk to each other, in a known [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F09%2Fcomparing-apis-opsview-and-icinga%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F09%2Fcomparing-apis-opsview-and-icinga%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p><strong><a class="lightbox" title="api" href="http://labs.opsview.com/wp-content/uploads/2010/09/api1.jpg"><img class="size-full wp-image-582 alignleft" title="api" src="http://labs.opsview.com/wp-content/uploads/2010/09/api1.jpg" alt="" width="129" height="110" /></a>So, what&#8217;s up in the Opsview&#8217;s world?</strong></p>
<p>We&#8217;re comparing APIs. A user was asking how Opsview&#8217;s API compares to Icinga&#8217;s API. We spent a bit of time investigating what the competition are up to.</p>
<p><strong><span id="more-533"></span>What&#8217;s an API?</strong></p>
<p>According to Wikipedia, an <a href="http://en.wikipedia.org/wiki/API">Application Programming Interface</a> is a way of having two programs talk to each other, in a known and consistent way.</p>
<p><strong>So what does Icinga&#8217;s API do?</strong></p>
<p>Looking at their documentation, they have two APIs: a plugins API and a status API (which they call the Icinga API). The contents of the plugins <a href="http://docs.icinga.org/latest/en/pluginapi.html">API document</a> looks almost exactly the same as the <a href="http://nagios.sourceforge.net/docs/3_0/pluginapi.html">Nagios document</a> &#8211; it looks like some liberties were taken there.</p>
<p>But the main point is that anything that calls itself &#8220;Nagios-compatible&#8221; will use the same Nagios Plugins API, in order to reach into the large number of plugins that are available. Opsview also uses the Nagios Plugins API &#8211; we just don&#8217;t make much noise about it.</p>
<p><strong>So it&#8217;s nothing special?</strong></p>
<p>Correct.</p>
<p><strong>You said there were two APIs?</strong></p>
<p>Their 2nd API is a status API, a way of getting <a href="http://docs.icinga.org/latest/en/icinga-api.html">host and service state information</a>. It looks like it is just a thin layer to getting information from their recommended data store using IDOUtils. <a href="http://docs.icinga.org/latest/en/quickstart-idoutils.html">IDOUtils</a> is based on <a href="http://nagios.sourceforge.net/docs/ndoutils/NDOUtils.pdf">NDOUtils</a>, which Opsview has been using for the last 4 years (where we&#8217;ve also sent back lots of fixes and enhancements back upstream). The type of status information available in the database is very rudimentary: is this host up or down? Is this service critical or not?</p>
<p><strong>So how does it stack up next to Opsview?</strong></p>
<p>Here&#8217;s why I think the <a href="http://docs.opsview.com/doku.php?id=opsview-community:api">Opsview API</a> is superior:</p>
<ul>
<li>Our API is a <a href="http://en.wikipedia.org/wiki/Webservice">webservice</a>, so anything that can talk HTTP can communicate with it. Our community have written dynamic web pages which present the data in a <a href="http://github.com/allan/nocview">different way</a> and we have a <a href="http://search.cpan.org/dist/Opsview-StatusAPI/">perl module on cpan</a> to easily get data back. We&#8217;ve even prototyped a <a href="http://labs.opsview.com/2010/05/gwtgxt-dashboard-primer/">dashboard app</a> to prove its functionality</li>
<li>Our API requires authentication, so users only see what they are allowed to see. Icinga&#8217;s API is wide open, which means the responsibility for security falls onto programmers rather that the system itself</li>
<li>Our status APIs aggregate data, so you can get information like in the <a href="http://docs.opsview.com/lib/exe/detail.php?id=opsview-community%3Amonitoringui&amp;media=opsview-community:hh_example.png">host group hierarchy pages</a> which gives summarised totals for host and service states based on hierarchical information. The Icinga API will not scale to thousands of hosts because a program would need to count each state itself</li>
</ul>
<div id="attachment_542" class="wp-caption aligncenter" style="width: 570px"><a class="lightbox" title="opsviewCommunityHostgroupHierarchyAPI" href="http://labs.opsview.com/wp-content/uploads/2010/09/opsviewCommunityHostgroupHierarchyAPI.png"><img class="alignnone size-full wp-image-557" title="opsviewCommunityHostgroupHierarchyAPI" src="http://labs.opsview.com/wp-content/uploads/2010/09/opsviewCommunityHostgroupHierarchyAPI.png" alt="" width="560" height="377" /></a><p class="wp-caption-text">Opsview Community: Host Group Hierarchy</p></div>
<p>Here&#8217;s the XML that describes the data on that page:</p>
<p><pre class="brush: xml; title: ; notranslate">
&lt;opsview&gt;
  &lt;data name=&quot;hostgroup&quot;&gt;
    &lt;list name=&quot;Development Systems&quot; downtime=&quot;2&quot; hostgroup_id=&quot;19&quot;&gt;
      &lt;hosts handled=&quot;38&quot; total=&quot;38&quot; unhandled=&quot;0&quot;&gt;
        &lt;unreachable handled=&quot;1&quot; /&gt;
        &lt;up handled=&quot;37&quot; /&gt;
      &lt;/hosts&gt;
      &lt;services handled=&quot;279&quot; highest=&quot;critical&quot; total=&quot;283&quot; unhandled=&quot;4&quot;&gt;
        &lt;critical handled=&quot;7&quot; unhandled=&quot;4&quot; /&gt;
        &lt;ok handled=&quot;263&quot; /&gt;
        &lt;warning handled=&quot;9&quot; /&gt;
      &lt;/services&gt;
    &lt;/list&gt;
    &lt;list name=&quot;Production Systems&quot; downtime=&quot;2&quot; hostgroup_id=&quot;18&quot;&gt;
      &lt;hosts handled=&quot;15&quot; total=&quot;16&quot; unhandled=&quot;1&quot;&gt;
        &lt;unreachable unhandled=&quot;1&quot; /&gt;
        &lt;up handled=&quot;15&quot; /&gt;
      &lt;/hosts&gt;
      &lt;services handled=&quot;82&quot; highest=&quot;critical&quot; total=&quot;82&quot; unhandled=&quot;0&quot;&gt;
        &lt;critical handled=&quot;4&quot; /&gt;
        &lt;ok handled=&quot;77&quot; /&gt;
        &lt;warning handled=&quot;1&quot; /&gt;
      &lt;/services&gt;
    &lt;/list&gt;
    &lt;summary handled=&quot;414&quot; total=&quot;419&quot; unhandled=&quot;5&quot;&gt;
      &lt;host handled=&quot;53&quot; total=&quot;54&quot; unhandled=&quot;1&quot; unreachable=&quot;2&quot; up=&quot;52&quot; /&gt;
      &lt;service critical=&quot;15&quot; handled=&quot;361&quot; ok=&quot;340&quot; total=&quot;365&quot; unhandled=&quot;4&quot; warning=&quot;10&quot; /&gt;
    &lt;/summary&gt;
  &lt;/data&gt;
&lt;/opsview&gt;
</pre></p>
<p><strong>Wow, that&#8217;s neat!</strong></p>
<p>Yes, because it decouples the data from the presentation. But the biggest advantage with our API is that it includes the ability to make configuration changes.</p>
<p><strong>Why is changing your configuration via an API useful?</strong></p>
<p>It&#8217;s for automating changes. We have users that write scripts to talk to the API to add and delete hosts as part of their build process. Some users hook Opsview to their central configuration databases. As nice as our web UI is, you don&#8217;t want to be doing regular changes all the time in the browser.</p>
<p><strong>So Opsview comes out on top?</strong></p>
<p>Yes, but I think this is because API is a bit of a loose term. Icinga&#8217;s use of API is &#8220;how to write programs to get status information&#8221;. Opsview considers &#8220;API&#8221; to mean &#8220;getting status data and making changes via a webservice&#8221;. On those grounds, I think its a bit unfair to compare the APIs at the moment because the Opsview API is doing much more, at a much higher level.</p>
<p><strong>Got any plans for the future?</strong></p>
<p>Definitely! But I&#8217;ll tell you about them later <img src='http://labs.opsview.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Update: 24th September 2010</strong></p>
<p><strong>What&#8217;s <a href="http://www.icinga.org/2010/09/24/making-things-accessible-the-icinga-web-rest-api/">this</a>? Someone trying to defend themselves?</strong></p>
<p>Yes, I think the Icinga chaps have got a little bit twitchy! I especially like the link to the documentation for the <a href="https://dev.icinga.org/projects/icinga-web/wiki/The_Icinga-web_REST_API_-_The_hidden_documentation">REST Adapter API</a> which is titled <em>The Hidden Documentation</em> &#8211; clearly they don&#8217;t think it is worth making it official.</p>
<p><strong>But it&#8217;s good, right?</strong></p>
<p>It&#8217;s a start <img src='http://labs.opsview.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2010/09/comparing-apis-opsview-and-icinga/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Grails &amp; Hudson Part 3: Testing</title>
		<link>http://labs.opsview.com/2010/09/grails-hudson-part-3-testing/</link>
		<comments>http://labs.opsview.com/2010/09/grails-hudson-part-3-testing/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 16:04:02 +0000</pubDate>
		<dc:creator>tcallway</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[Unix / Linux]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/?p=528</guid>
		<description><![CDATA[
			
				
			
		Since Grails incorporated the testing plugin into core it provides good unit &#38; integration testing support (via the test-app script). There are also additional plugins to support BDD tools (e.g. EasyB) and functional testing (e.g. Canoo WebTest).
One of the useful roles that Hudson fulfils is helping to manage quality. Consequently it has plugins available for [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F09%2Fgrails-hudson-part-3-testing%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F09%2Fgrails-hudson-part-3-testing%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p><a title="grails" href="http://labs.opsview.com/wp-content/uploads/2010/08/grails.png"><img class="alignleft" title="grails" src="http://labs.opsview.com/wp-content/uploads/2010/08/grails.png" alt="" width="176" height="53" /></a>Since Grails incorporated the testing plugin into core it provides good unit &amp; integration testing support (via the test-app script). There are also additional plugins to support BDD tools (e.g. EasyB) and functional testing (e.g. Canoo WebTest).</p>
<p><span id="more-528"></span>One of the useful roles that Hudson fulfils is helping to manage quality. Consequently it has plugins available for most of the popular testing tools (we saw an example of the Violations plugin in <a href="http://labs.opsview.com/2010/08/grails-hudson-part-1-codenarc/">part 1</a> of this series).</p>
<p>We’ll start with the standard unit &amp; integration tests, then add in test coverage and functional tests.</p>
<p><strong>Unit tests</strong>
Assuming you already have unit/integration tests in your Grails project – we need to add the targets into the Grails builder options.
<code>clean compile "test-app -unit -integration"</code></p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/09/grails-builder-test-app.png?w=453&amp;h=152" alt="" width="453" height="152" /></p>
<p style="text-align: left;">Notice how the server port has been set to prevent port collision with the servlet container running Hudson.
<em> </em></p>
<p style="text-align: left;"><em>Tip:</em> you’ll need to set this differently on each job too.</p>
<p style="text-align: left;">Then set the post-build action:</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/09/post-build_junit_small.png?w=418&amp;h=86" alt="" width="418" height="86" /></p>
<p style="text-align: left;">After a couple of builds (so that there is a trend), Hudson will show:</p>
<p style="text-align: center;"><a href="http://leanjavaengineering.files.wordpress.com/2010/08/test_trend.png"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/test_trend.png?w=150&amp;h=136" alt="" width="150" height="136" /></a></p>
<p>With blue for tests that passed and red for failed tests.
You can also drill into the test results just as with the standard HTML junit reports.</p>
<p><strong>Test coverage</strong>
As we’re looking to use Hudson to help ensure the quality of the software project, we’ll also inspect the level of test coverage as one of our quality metrics.</p>
<p><em>Warning</em>: determining test coverage isn’t foolproof and high levels of coverage don’t guarantee good code or good tests. It is possible to achieve a high percentage with poor tests (I’m writing a separate post on this topic).</p>
<p>For this post, we’ll be using Cobertura to check the code coverage. There are other options, but we’ll be using Cobertura because:</p>
<ol>
<li>There is a <a href="http://www.grails.org/plugin/code-coverage">Grails plugin</a></li>
<li>There is a <a href="http://wiki.hudson-ci.org/display/HUDSON/Cobertura+Plugin">Hudson plugin</a> too.</li>
</ol>
<p><strong>Install the Grails code-coverage plugin</strong>
<code>grails install-plugin code-coverage</code></p>
<p>You may want to configure additional exclusions in BuildConfig.groovy, e.g. to avoid testing 3rd party code such as a plugin taglib that isn’t used. (the plugin scripts/_Events.groovy includes a default list)</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/09/buildconfig_cobertura_exclusions.png?w=247&amp;h=160" alt="" width="247" height="160" /></p>
<p><strong>Install the Hudson Cobertura plugin</strong>
This follows the same process that we covered in <a href="http://leanjavaengineering.wordpress.com/2010/08/31/grails-hudson-basics/">part 2</a> of this series (we’ll omit the screenshots this time):</p>
<ol>
<li>From the main Hudson dashboard, click on the “Manage Hudson” menu item</li>
<li>Click on “Manage plugins”</li>
<li>Go to the available tab, find &amp; select Cobertura, click on the install button.</li>
<li>When the plugin has downloaded and installed, you will need to restart Hudson (you can use the button provided).</li>
</ol>
<p><strong>Configure your Hudson job</strong>
There are 2 things that need to be done here:</p>
<ol>
<li>Set up the Grails build action</li>
<li>Enable the post-build action for Cobertura</li>
</ol>
<p>1. This is a case of adding “-coverage -xml” into the build targets within the test-app double quoted section.
2. Enable the Cobertura post-build processing, tell it where the XML report is and set thresholds:</p>
<p style="text-align: center;"><a href="http://leanjavaengineering.files.wordpress.com/2010/09/post-build_cobertura_config.png"><img class="aligncenter" src="http://leanjavaengineering.files.wordpress.com/2010/09/post-build_cobertura_config.png?w=300&amp;h=93" alt="" width="300" height="93" /></a></p>
<p style="text-align: left;"><strong>Leverage the information</strong></p>
<p style="text-align: left;">Watch the trends:</p>
<p style="text-align: center;"><a href="http://leanjavaengineering.files.wordpress.com/2010/09/cobertura_summary_report.png"><img class="aligncenter" src="http://leanjavaengineering.files.wordpress.com/2010/09/cobertura_summary_report.png?w=300&amp;h=266" alt="" width="300" height="266" /></a></p>
<p style="text-align: left;">and drill down to see the in-context coverage:</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/09/cobertura_in_context.png?w=443&amp;h=76" alt="" width="443" height="76" /></p>
<p>When you have the insight as to where you are missing coverage, then you can take the appropriate action to remedy the situation…</p>
<p><strong>Functional tests</strong>
There are a number of options for functional testing your application. We’ll cover <a href="http://webtest.canoo.com/">Canoo WebTest</a> in this post for the following reasons:</p>
<ol>
<li>WebTest is <a href="http://htmlunit.sourceforge.net/">htmlunit</a> based – portable across different environments</li>
<li>Canoo have written a <a href="http://webtestrecorder.canoo.com/">Firefox WebTest Recorder add-on</a> – allowing less technical users to create the basis of the tests</li>
<li>There is also a <a href="http://wiki.hudson-ci.org/display/HUDSON/WebTest+Presenter+Plugin">WebTest Presenter plugin</a> for Hudson.</li>
</ol>
<p>Note that as WebTest isn’t browser-based, you may encounter some issues with JavaScript on particular test scenarios.</p>
<p><strong>Install the Grails webtest plugin</strong>
<code>grails install-plugin webtest</code>
If you are using older versions of Grails, you may need to do an interactive plugin install on the Hudson server (the plugin used to download a WebTest bundle, rather than having it as a managed dependency).</p>
<p><strong>Install the Firefox WebTest Recorder add-on</strong>
You can install the WebTest Recorder in Firefox from:
<a href="https://www.canoo.com/webtestrecorder-dist/webtestrecorder.xpi">https://www.canoo.com/webtestrecorder-dist/webtestrecorder.xpi</a></p>
<p><strong>Create some web tests</strong>
<em>You can come back to this bit later</em></p>
<p>The process we’ll follow here uses the WebTest Recorder to create the initial test steps.</p>
<p>1. Run “grails create-webtest <em>name</em>” e.g.
<code>grails create-webtest HomepageLogin</code></p>
<p>This plugin script will create us the placeholder test file under test/webtest.</p>
<p>2. <code>grails run-app</code></p>
<p>3. Bring up Firefox
4. Navigate to the starting page for your test scenario.
5. Enable the WebTest Recorder Sidebar (Tools &gt; Webtest Recorder Sidebar)
6. Click on the Groovy tab.</p>
<p>This should already contain “invoke http://localhost:8080/YourGrailsApp/” (you’ll probably want to trim this down to just a relative path e.g. /YourGrailsApp/)</p>
<p>Using the Webtest Recorder Sidebar, you can click around the site and also easily add verification of content on pages (as a test isn’t a test if you don’t verify that the output is correct for the given input). This can then be placed into a method in the groovy file we created earlier (note: you may need to trim some instructions e.g. where the recorder has created different versions for the same input field).
For more information using Webtest, see the <a href="http://webtest.canoo.com/webtest/manual/manualOverview.html">manual</a>.</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/09/webtest_recorder.png?w=300&amp;h=241" alt="" width="300" height="241" /></p>
<p>I’d strongly advise you to run your tests locally first before checking them in – in the interests of time/space we’ll assume you’ve done that using:
<code>grails test-app -functional</code></p>
<p><strong>Install the Hudson WebTest presenter plugin</strong>
This follows the same process as the Cobertura plugin above (see <a href="http://leanjavaengineering.wordpress.com/2010/08/31/grails-hudson-basics/">part 2</a> of this series for screenshots):</p>
<ol>
<li>From the main Hudson dashboard, click on the “Manage Hudson” menu item</li>
<li>Click on “Manage plugins”</li>
<li>Go to the available tab, find &amp; select WebTest Presenter, click on the install button.</li>
<li>When the plugin has downloaded and installed, you will need to restart Hudson (you can use the button provided).</li>
</ol>
<p><strong>Configure your Hudson job</strong>
There are 2 things that need to be done here:</p>
<ol>
<li>Set up the Grails build action</li>
<li>Enable the post-build action for the WebTest Presenter</li>
</ol>
<p>1. This is a case of adding “-functional -headless” into the build targets within the test-app double quoted section (The headless option tells Webtest to not run the test monitor nor to load the test results into the browser).</p>
<p>2. The Webtest Presenter post-build action needs enabling and telling where to find the results</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/09/webtest_presenter_config.png?w=473&amp;h=58" alt="" width="473" height="58" /></p>
<p>After the Hudson job has executed your webtests, you’ll see that these have been included in your overall test count (and may even have improved your test coverage if you’ve followed the Cobertura section above).</p>
<p>If you click onto an individual build, the left hand menu will now have “Webtest Results”</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/09/job_webtest_results_menu_item.png?w=161&amp;h=305" alt="" width="161" height="305" /></p>
<p style="text-align: left;">This will give you an overview report:</p>
<p style="text-align: center;"><a href="http://leanjavaengineering.files.wordpress.com/2010/09/webtest_report.png"><img class="aligncenter" src="http://leanjavaengineering.files.wordpress.com/2010/09/webtest_report.png?w=300&amp;h=112" alt="" width="300" height="112" /></a></p>
<p style="text-align: left;">and a detailed step-by-step report for each test (including resulting pages and any errors):</p>
<p style="text-align: center;"><a href="http://leanjavaengineering.files.wordpress.com/2010/09/webtest_test_step_report.png"><img class="aligncenter" src="http://leanjavaengineering.files.wordpress.com/2010/09/webtest_test_step_report.png?w=300&amp;h=228" alt="" width="300" height="228" /></a></p>
<p style="text-align: left;">So there you go, a whistle stop tour of setting up test execution, coverage analysis and result reporting with trends.</p>
<p style="text-align: left;">Next in the series, we move into using Hudson for continuous deployment of Grails projects.</p>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2010/09/grails-hudson-part-3-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails &amp; Hudson Part 2: Back to basics</title>
		<link>http://labs.opsview.com/2010/09/grails-hudson-part-2-back-to-basics/</link>
		<comments>http://labs.opsview.com/2010/09/grails-hudson-part-2-back-to-basics/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 15:50:07 +0000</pubDate>
		<dc:creator>rbramley</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[Unix / Linux]]></category>
		<category><![CDATA[development frameworks]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/?p=521</guid>
		<description><![CDATA[
			
				
			
		Ok, so you’ve decided that you want to use Hudson to build your Grails projects (or have read part 1 and want to use CodeNarc too). If you don’t know where to start, you’ve come to the right place.

The basic steps (and we’ll go into more detail on each one) are:

Download Hudson
Run Hudson
Download Hudson plugins
Configure Hudson
Create [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F09%2Fgrails-hudson-part-2-back-to-basics%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F09%2Fgrails-hudson-part-2-back-to-basics%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p><a title="grails" href="http://labs.opsview.com/wp-content/uploads/2010/08/grails.png"><img class="alignleft" title="grails" src="http://labs.opsview.com/wp-content/uploads/2010/08/grails.png" alt="" width="176" height="53" /></a>Ok, so you’ve decided that you want to use Hudson to build your Grails projects (or have read part 1 and want to use CodeNarc too). If you don’t know where to start, you’ve come to the right place.</p>
<p><span id="more-521"></span></p>
<p>The basic steps (and we’ll go into more detail on each one) are:</p>
<ol>
<li>Download Hudson</li>
<li>Run Hudson</li>
<li>Download Hudson plugins</li>
<li>Configure Hudson</li>
<li>Create a Hudson job</li>
<li>Watch the trends</li>
</ol>
<p>This post will get you started and subsequent posts in the series will add even more power to your CI process.</p>
<p><strong>Step 1 – Download Hudson</strong></p>
<p>Hudson is packaged as a Java web application archive (war file) and can be downloaded from <a href="http://hudson-ci.org/">hudson-ci.org</a>.
The 1.373 war is available from <a href="https://hudson.dev.java.net/files/documents/2402/152405/hudson.war">here</a>.</p>
<p>Debian/Ubuntu users can install Hudson using ‘<em>apt-get install hudson</em>‘ (but if you’re on stable, it isn’t the latest version).</p>
<p><strong>Step 2 – Install/run Hudson</strong></p>
<p>Before we dive into the installation, you’ll need some pre-requisites installed:</p>
<ul>
<li>Java JDK (6 is best)</li>
<li>Grails (whichever version you’re using)</li>
</ul>
<p>As previously mentioned, Hudson comes as a war file and so it can be deployed to a servlet container such as Tomcat. The Hudson war file also includes the lightweight Winstone servlet container so can be run using:
<code>java -jar hudson.war</code></p>
<p>Note that Hudson uses ~/.hudson as a working directory by default.</p>
<p>Key folders are:
<em>jobs </em>- job configuration, the workspace and builds are stored here
<em>plugins </em>- plugin .hpi files are unpacked to directories beneath this
<em>war </em>- the Hudson war file is unpacked here</p>
<p><strong>Step 3 – Download Hudson plugins</strong></p>
<p>Once you’ve got Hudson running – we’ll start by getting the Grails plugin.</p>
<p>Click on the “Manage Hudson” menu item</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/manage_hudson_link.png?w=141&amp;h=300" alt="" width="141" height="299" /></p>
<p>Click on “Manage plugins”</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/manage_hudson_manage_plugins_link.png?w=300&amp;h=112" alt="" width="300" height="112" /></p>
<p>Go to the available tab, find &amp; select Grails, click on the install button.</p>
<p>When the plugin has downloaded and installed, you will need to restart Hudson (you can use the button provided).</p>
<p>Note: you can also manually install downloaded/compiled Hudson plugin .hpi files into ~/.hudson/plugins</p>
<p><strong>Step 4 – Configure Hudson</strong></p>
<p>Now we need to set-up the JDK and Grails – so have their paths handy.</p>
<p>Click on the “Manage Hudson” menu item</p>
<p>Click on “Configure System”</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/manage_hudson_configure_system_link.png?w=300&amp;h=112" alt="" width="300" height="112" /></p>
<p>Step 4.1 Set-up the JDK</p>
<ol>
<li>Give it a name</li>
<li>Set the JAVA_HOME</li>
</ol>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/configure_jdk.png?w=300&amp;h=86" alt="" width="300" height="86" /></p>
<p>Step 4.2 Set-up Grails</p>
<ol>
<li>Give it a name</li>
<li>Set the GRAILS_HOME</li>
</ol>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/configure_grails_builder.png?w=300&amp;h=70" alt="" width="300" height="70" /></p>
<p>Congratulations, you’re now ready to set-up your first Hudson job.</p>
<p><strong>Step 5 – Create a Hudson job</strong></p>
<p>If you have lots of Grails projects, you’ll only need to do this from scratch the first time as Hudson allows you to copy existing jobs.</p>
<p>Click on the “New Job” link</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/new_job_link.png?w=189&amp;h=266" alt="" width="189" height="266" /></p>
<ol>
<li>Enter a job name (Tip: Hudson will use this for a directory name – so be careful what characters you use)</li>
<li>Select “Build a free-style software project”</li>
<li>Click “Ok”</li>
</ol>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/new_job_2_highlighted.png?w=500&amp;h=424" alt="" width="500" height="424" /></p>
<p>For the first pass at the configuration, let’s assume that you have a working copy of the code locally (you can always come back to set-up the Source Code Management settings).</p>
<p>We need to add the Grails build step, so click on “Add Build Step”</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/job_config_1_highlighted.png?w=300&amp;h=255" alt="" width="300" height="255" /></p>
<p>This will give you an option list – select “Build With Grails”</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/job_config_build_step_options_highlighted.png?w=244&amp;h=128" alt="" width="244" height="128" /></p>
<p>You can now perform the basic configuration of the Grails step. Let’s set it to do a clean, followed by execution of the unit tests:
<code>clean "test-app -unit"</code></p>
<p>Unless you’ve set up the SCM configuration, you’ll want to specify the root of the Grails application in the “Project Base Directory” too.</p>
<p>Finally, we want Hudson to publish the unit test results (this is relative to the workspace under ~/.hudson/job/<em>Example</em>/workspace).</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/job_config_grails_plus_test_highlighted.png?w=500&amp;h=398" alt="" width="500" height="398" /></p>
<p>If the working copy is clean, Hudson may complain that the XML results or the target directory do not exist – this can be safely ignored for now.</p>
<p>Now ‘Save’ the job using the Save button at the bottom of the form and test it using the “Build Now” link.</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/job_menu_highlighted.png?w=300&amp;h=288" alt="" width="300" height="288" /></p>
<p>If the build passes, it will be marked as blue (this can be changed to green balls with a plugin).</p>
<p>If the build fails, then click on the failed job</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/job_build_history_highlighted.png?w=152&amp;h=300" alt="" width="152" height="298" /></p>
<p>and look at the error message under “Console Output”.</p>
<p>E.g. If you select Subversion as an SCM option, but leave the form blank:</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/error_output_console_highlighted.png?w=300&amp;h=165" alt="" width="300" height="165" /></p>
<p><strong>Step 6 – Watch the trends</strong></p>
<p>Assuming you’ve got it all working – after you’ve performed a few builds, Hudson will start to show build trends on the job page…</p>
<p style="text-align: center;"><img class="alignnone" src="http://leanjavaengineering.files.wordpress.com/2010/08/test_trend.png?w=234&amp;h=213" alt="" width="234" height="213" /></p>
<p>We’ll add more statistics to this view in later posts in the series.</p>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2010/09/grails-hudson-part-2-back-to-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails &amp; Hudson Part 1: CodeNarc</title>
		<link>http://labs.opsview.com/2010/08/grails-hudson-part-1-codenarc/</link>
		<comments>http://labs.opsview.com/2010/08/grails-hudson-part-1-codenarc/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 13:25:43 +0000</pubDate>
		<dc:creator>rbramley</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Grails]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[Opsview]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[CodeNarc]]></category>

		<guid isPermaLink="false">http://labs.opsview.com/?p=483</guid>
		<description><![CDATA[
			
				
			
		The first part of a series of posts on Grails and Hudson leading up to a presentation at the London Groovy &#38; Grails User Group. Subsequent instalments will include testing (unit, integration, functional), test coverage, automatic war deployment and monitoring Hudson with Opsview Enterprise.

Grails has a rich plugin eco-system with over 400 hundred plugins – so it’s [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F08%2Fgrails-hudson-part-1-codenarc%2F">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Flabs.opsview.com%2F2010%2F08%2Fgrails-hudson-part-1-codenarc%2F&amp;style=normal&amp;b=2" height="61" width="50" />
			</a>
		</div><p><a class="lightbox" title="grails" href="http://labs.opsview.com/wp-content/uploads/2010/08/grails.png"><img class="alignleft size-full wp-image-501" style="margin-bottom: 8px; margin-right: 10px;" title="grails" src="http://labs.opsview.com/wp-content/uploads/2010/08/grails.png" alt="" width="176" height="53" /></a>The first part of a series of posts on <a href="http://en.wikipedia.org/wiki/Grails_(framework)">Grails</a> and <a href="http://en.wikipedia.org/wiki/Hudson_(software)">Hudson</a> leading up to a presentation at the London Groovy &amp; Grails User Group. Subsequent instalments will include testing (unit, integration, functional), test coverage, automatic war deployment and monitoring Hudson with <a href="https://www.opsview.com/products/opsview-enterprise">Opsview Enterprise</a>.</p>
<div><span id="more-483"></span></div>
<p>Grails has a rich plugin eco-system with over 400 hundred plugins – so it’s easy to miss something useful. If you’re serious about software craftsmanship, then using static code analysis tools should be part of your quality regime as it gives further insight into the code base (and if you insist, yes it’ll help with your Technical Debt management).</p>
<p><a title="CodeNarc" href="http://codenarc.sourceforge.net/">CodeNarc</a> provides static code analysis for Groovy and the <a title="CodeNarc plugin" href="http://www.grails.org/plugin/codenarc/">CodeNarc plugin for Grails</a> allows you to perform this analysis with the “grails codenarc” script. Behind the scenes this uses the CodeNarc ant task and settings from grails-app/conf/Config.groovy and produces an HTML report by default.</p>
<p>Until recently, if you used the codenarc target within a continuous integration server such as <a title="Hudson CI" href="http://hudson-ci.org/">Hudson</a> – then the HTML report would be generated and sit in the workspace waiting for a diligent developer to check it. You can imagine how often that happens in practice with all the other demands of a project!</p>
<p>However, I’ve now integrated the CodeNarc XML output with the <a title="Violations plugin" href="http://wiki.hudson-ci.org/display/HUDSON/Violations">Hudson Violations plugin </a>so that an overview trend line is shown against the Hudson job. Then the team quickly fixed the violations…</p>
<p><a class="lightbox" title="1" href="http://labs.opsview.com/wp-content/uploads/2010/08/1.png"><img class="aligncenter size-full wp-image-484" title="1" src="http://labs.opsview.com/wp-content/uploads/2010/08/1.png" alt="" width="300" height="169" /></a>You can also get a breakdown by priority:</p>
<p><a class="lightbox" title="2" href="http://labs.opsview.com/wp-content/uploads/2010/08/2.png"><img class="aligncenter size-full wp-image-485" title="2" src="http://labs.opsview.com/wp-content/uploads/2010/08/2.png" alt="" width="300" height="259" /></a>And in-context views of the violations so you know what to fix:</p>
<p><a class="lightbox" title="3" href="http://labs.opsview.com/wp-content/uploads/2010/08/3.png"><img class="aligncenter size-full wp-image-486" title="3" src="http://labs.opsview.com/wp-content/uploads/2010/08/3.png" alt="" width="300" height="143" /></a></p>
<p>This is how you do it…</p>
<p>Grails <strong>config.groovy</strong>
<code>codenarc {
reportName = 'target/test-reports/CodeNarcReport.xml'
reportType = 'xml'
// any further settings like maxPriority1Violations=0
}</code></p>
<h3>Hudson</h3>
<p>Set up your Grails build step – normally you’d add the ‘codenarc’ target:</p>
<p><a class="lightbox" title="4" href="http://labs.opsview.com/wp-content/uploads/2010/08/4.png"><img class="aligncenter size-full wp-image-487" title="4" src="http://labs.opsview.com/wp-content/uploads/2010/08/4.png" alt="" width="519" height="459" /></a></p>
<p><em>The <a title="CodeNarc rule configuration" href="http://codenarc.sourceforge.net/codenarc-configuring-rules.html#Configuring_Rules_Using_a_Properties_File">codenarc.properties</a> file can be used to configure specific exclusions, the location of this file can be passed in as a system property (shown above).</em></p>
<p>You need to have installed the violations plugin (Manage Hudson &gt; Manage Plugins &gt; Available and search for Violations). As this is a recent addition, I’m using a patched version of the Violations plugin, though the patch has been integrated into trunk (I’ll update when it is released). Configure violations:</p>
<p><a class="lightbox" title="5" href="http://labs.opsview.com/wp-content/uploads/2010/08/5.png"><img class="aligncenter size-full wp-image-488" title="5" src="http://labs.opsview.com/wp-content/uploads/2010/08/5.png" alt="" width="526" height="515" /></a></p>
<p><em>Note the ‘Faux project path’ – you may need to set this to get an in-context view working properly due to path (e.g. if your code is checked out to workspace/trunk)</em></p>
<p>I also had a contribution to CodeNarc accepted at the weekend to add an<em>inlineXml</em> report type – this will, with a minor tweak to the CodeNarc parser, allow the Hudson Violations plugin to give the rule description on the pop-up message.</p>
]]></content:encoded>
			<wfw:commentRss>http://labs.opsview.com/2010/08/grails-hudson-part-1-codenarc/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

