Tuesday, February 21, 2012

Stop nagios downtime alert spam

If you're like me and find the nagios alerts declaring when scheduled downtime starts and ends annoying, try wrapping your notify command in an if block:

command_line if [ "$NOTIFICATIONTYPE$" = "PROBLEM" -o "$NOTIFICATIONTYPE$" = "RECOVERY" -o "$NOTIFICATIONTYPE$" = "ACKNOWLEDGEMENT" ]; then /usr/bin/printf "%b" "***** Nagios  *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $DATETIME$\n\nAdditional Info:\n\n$OUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$; fi

Thursday, February 2, 2012

rails gotcha

Rails has improved my web development experience, no doubt but not without a few gotcha's. Somehow I missed this one, so hope this helps if anyone else did too:

One of the useful features of rails is the asset pipeline. Very flexible and designed to improve performance of rails apps overall - good stuff!

My preference is to pre-compile assets in my dev environment and simply copy these static resources to the proper destination (presumably to a cached store in your environment, CDN, mod_cache, etc). What wasn't apparent (obvious) from the docs is that you need to clean after compilation

rake assets:precompile
rake assets:clean

in your dev environment, otherwise bad things will happen. In my case, a javascript event handler was installed twice for the same event and caused some very odd behavior but difficult to troubleshoot. I wasted an entire afternoon fishing this one out, hopefully will save you some trouble - clean after precompile!