Posts Tagged ‘code’
* Fall through code to a success…
Posted on December 10th, 2009 by doug. Filed under shell.
I found a piece of code in a nagios alerting script that returns “success” 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]; then
# return failure to nagios nrpe daemon
else
# return success to nrpe
fi
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.
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.
Something like:
if [success code here]; then
# return success to nagios nrpe daemon
else
# return failure nrpe
fi
Obvious. But an epiphany anyway.
–doug
recent posts
- compacting logs
- I miss my brother…
- home to Boston, daughter in remission
- visually healthy bone marrow…
- matter of the lungs
- Fall through code to a success…
- another tool for SVN – list_repositories.pl
- svnadmin.pl – perl cgi script to manage svn over apache
What I'm Doing...
- waiting for Dell to inform FedEx they've shipped my netbook... 2010-06-07
- sorting out stuff (moving...) 2010-05-25
- downloaded netbook remix (for my Asus) and amd64 (for my 64 bit Intel PC) - desktop for everything else has slowed to 120 kbs... 37 minutes 2010-04-29
- More updates...
Posting tweet...
