<?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>intuitive engineering &#187; code</title>
	<atom:link href="http://dougmunsinger.com/tag/code/feed" rel="self" type="application/rss+xml" />
	<link>http://dougmunsinger.com</link>
	<description>doug munsinger</description>
	<lastBuildDate>Mon, 07 Jun 2010 16:44:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Fall through code to a success&#8230;</title>
		<link>http://dougmunsinger.com/2009/12/fall-through-code-to-a-success.html</link>
		<comments>http://dougmunsinger.com/2009/12/fall-through-code-to-a-success.html#comments</comments>
		<pubDate>Thu, 10 Dec 2009 15:58:10 +0000</pubDate>
		<dc:creator>doug</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[bash shell]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://dougmunsinger.com/2009/12/fall-through-code-to-a-success.html</guid>
		<description><![CDATA[I found a piece of code in a nagios alerting script that returns &#8220;success&#8221; matter what is happening with the jboss application it is checking. This script had been perpetuated as a service alerting script for years in the environs I work in, edited and passed on as working. It reads: if [failure code here]; [...]]]></description>
			<content:encoded><![CDATA[<p>I found a piece of code in a nagios alerting script that returns &#8220;success&#8221; matter what is happening with the jboss application it is checking.  </p>
<p>This script had been perpetuated as a service alerting script for years in the environs I work in, edited and passed on as working.  It reads:</p>
<p>if [failure code here]; then<br />
    # return failure to nagios nrpe daemon<br />
else<br />
   # return success to nrpe<br />
fi</p>
<p>The test for a failure failed to match, even when the test was looking for a jboss instance not present on the server.  Because the code falls through to success, everything looks just fine, all of the time.  </p>
<p>The test for failure being incorrect struck me first when I looked through the script.  The more basic flaw in logic hit me after.  I think it would be true in an alerting script you would NEVER drop through a loop to a final success.   The test would be for success, the fall-through to failure.  This would have prevented a false sense of security, and the failure to detect success would have been dealt with immediately.</p>
<p>Something like: </p>
<p>if [success code here]; then<br />
    # return success to nagios nrpe daemon<br />
else<br />
   # return failure nrpe<br />
fi</p>
<p>Obvious.  But an epiphany anyway.</p>
<p>&#8211;doug</p>
]]></content:encoded>
			<wfw:commentRss>http://dougmunsinger.com/2009/12/fall-through-code-to-a-success.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.402 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-29 18:57:35 -->
