<?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>Infinitus Incognita</title>
	<atom:link href="http://jaredwatkins.com/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://jaredwatkins.com/wordpress</link>
	<description>The Infinite Unknown</description>
	<lastBuildDate>Tue, 14 Feb 2012 12:39:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Broken By Design &#8211; DirectTV and Overproduced Email</title>
		<link>http://jaredwatkins.com/wordpress/2012/02/broken-by-design-directtv-and-overproduced-email/</link>
		<comments>http://jaredwatkins.com/wordpress/2012/02/broken-by-design-directtv-and-overproduced-email/#comments</comments>
		<pubDate>Sat, 11 Feb 2012 20:04:05 +0000</pubDate>
		<dc:creator>JaredWatkins</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[directv]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[tivo]]></category>
		<category><![CDATA[user interface design]]></category>
		<category><![CDATA[wbt]]></category>

		<guid isPermaLink="false">http://jaredwatkins.com/wordpress/?p=690</guid>
		<description><![CDATA[I was invited to be in a focus group for the local talk radio station recently with a focus on how they use email to communicate with listeners.  As I&#8217;ve been a long time listener of this station and especially like some of the things they do online I thought it would be good to [...]]]></description>
			<content:encoded><![CDATA[<p>I was invited to be in a focus group for the local talk radio station recently with a focus on how they use email to communicate with listeners.  As I&#8217;ve been a long time listener of this station and especially like some of the things they do online I thought it would be good to participate.  They wanted feedback on what they are currently doing and opinions on new approaches and services they were thinking of offering.  One example that I like.. is that you can tell them what roads you travel for your commute and if there are accidents or whatever on those roads leading up to rush hour they will let you know via email. They also do breaking news alerts and similar things you can choose to receive.</p>
<p>So some of what they showed us were examples of emails from other companies that were covering news items or special deals from their advertisers etc.  All were overproduced email through&#8230; that is.. they looked like web pages instead of email. Lots of graphics.. large photos.. etc.  I and several others pointed out that this is not the sort of stuff we want to get or have to read on our smart phones and how often we are working with limited bandwidth.</p>
<p>Most of these example emails were 80% &#8216;advertising&#8217; or branding or whatever and 20% message content.  To me.. for an email that is supposed to be communicating the content.. that&#8217;s broken. It looks great.. and if you have the screen and bandwidth to see it properly I&#8217;m sure it would leave a good impression&#8230; but it&#8217;s not appropriate for email.  Also, you are emailing people you already have a relationship with. You don&#8217;t need half the screen taken up by some logo banner to remind them who you are or what your call letters are.  You also don&#8217;t need to repeat the same information 3 times in a message.  Keeping mobile devices in mind.. you should make use of the From address and Subject lines to let someone know without even opening it if it&#8217;s breaking news.. some advertising deal or an upcoming special guest on a show that day.</p>
<p>My similar gripe is with <a class="wikinvest-suggestion-link" articletype="company" articletitle="RGlyZWNUVg,,_0" target="_blank" href="http://www.wikinvest.com/stock/The_DirecTV_Group_(DTV)" ticker="NASDAQ%3ADTV">DirecTV</a>.  I switched back to them a few months ago after TimeWarner demonstrated that the combination of Tivo/CableCard/Tuning Adapter just wasn&#8217;t going to work reliably. One of things I like about DVRs is the 30 second skip.. I use it constantly.  One thing I&#8217;ve noticed though is that when you encounter an advertisement FOR DirectTV.. ON DirecTV it won&#8217;t let you skip past it.  You can still fast forward.. but not skip.  It&#8217;s hard to imagine what the reasoning is for this&#8230; seeing as I&#8217;m obviously already a customer. What marketing genius thought it was a good idea to FORCE me to watch an advert for a service I&#8217;m already paying for??  This is broken behavior and all it does is annoy me every single time it happens. It&#8217;s also a reminder that as good as their stuff is.. it&#8217;s a long way from Tivo.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaredwatkins.com/wordpress/2012/02/broken-by-design-directtv-and-overproduced-email/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I Do &#8211; Broadsoft CDR Files to Radius Accounting Records</title>
		<link>http://jaredwatkins.com/wordpress/2012/02/what-i-do-broadsoft-cdr-files-to-radius-accounting-records/</link>
		<comments>http://jaredwatkins.com/wordpress/2012/02/what-i-do-broadsoft-cdr-files-to-radius-accounting-records/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 03:40:17 +0000</pubDate>
		<dc:creator>JaredWatkins</dc:creator>
				<category><![CDATA[Computing and Tech]]></category>
		<category><![CDATA[My Code]]></category>
		<category><![CDATA[broadsoft]]></category>
		<category><![CDATA[cdr]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[radius]]></category>
		<category><![CDATA[resume]]></category>
		<category><![CDATA[soft switch.radiator]]></category>

		<guid isPermaLink="false">http://jaredwatkins.com/wordpress/?p=675</guid>
		<description><![CDATA[As part of a larger project I needed to generate real time radius records from the CDR accounting files of several cluster pairs of Broadsoft application servers. So I wrote a perl script to do just that. It maps the CDR fields to radius attribs and encodes the accounting packet using the Net::Radius::Packet CPAN module. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jaredwatkins.com/wordpress/wp-content/uploads/2012/02/perl.jpg"><img class="alignleft size-thumbnail wp-image-680" title="perl" src="http://jaredwatkins.com/wordpress/wp-content/uploads/2012/02/perl-150x150.jpg" alt="" width="150" height="150" /></a>As part of a larger project I needed to generate real time <a href="http://en.wikipedia.org/wiki/RADIUS">radius</a> records from the CDR accounting files of several cluster pairs of <a href="http://www.broadsoft.com/">Broadsoft</a> <a href="http://www.broadsoft.com/products/broadworks/platform/">application servers</a>. So I wrote a perl script to do just that. It maps the CDR fields to radius attribs and encodes the accounting packet using the <a href="http://search.cpan.org/~luismunoz/Net-Radius-2.103/Radius/Packet.pm">Net::Radius::Packet</a> CPAN module.  In my case I&#8217;m using the <a href="http://www.open.com.au/radiator/">Radiator radius server</a>  from <a href="http://www.open.com.au/">OSC Software</a> on the other end with lots of custom &#8216;hook code&#8217; to clean up and store the call data coming off our network into a <a href="http://www.postgresql.org/">Postgresql</a> database.  This is my first time doing any development with radius.. but I&#8217;ve been running this script on several servers for a few weeks now and it appears to be quite stable.</p>
<ul>
<li>Get it on the <a href="http://jaredwatkins.com/wordpress/my-projects/file2radius/">Project Page</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jaredwatkins.com/wordpress/2012/02/what-i-do-broadsoft-cdr-files-to-radius-accounting-records/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Site Facelift</title>
		<link>http://jaredwatkins.com/wordpress/2012/01/site-facelift/</link>
		<comments>http://jaredwatkins.com/wordpress/2012/01/site-facelift/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 17:52:35 +0000</pubDate>
		<dc:creator>JaredWatkins</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://jaredwatkins.com/wordpress/?p=653</guid>
		<description><![CDATA[I&#8217;ve been working on giving the site a facelift lately.. trying to make it a little more &#8216;light&#8217;&#8230; how am I doing?  I&#8217;ll also be rotating in various photos I&#8217;ve taken in the page header.  I&#8217;ll try to stick to photos I&#8217;ve actually taken myself&#8230; maybe as an incentive to do more traveling.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on giving the site a facelift lately.. trying to make it a little more &#8216;light&#8217;&#8230; how am I doing?  I&#8217;ll also be rotating in various photos I&#8217;ve taken in the page header.  I&#8217;ll try to stick to photos I&#8217;ve actually taken myself&#8230; maybe as an incentive to do more traveling.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaredwatkins.com/wordpress/2012/01/site-facelift/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unraveling the Duct Tape</title>
		<link>http://jaredwatkins.com/wordpress/2012/01/unraveling-the-duct-tape/</link>
		<comments>http://jaredwatkins.com/wordpress/2012/01/unraveling-the-duct-tape/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 03:44:03 +0000</pubDate>
		<dc:creator>JaredWatkins</dc:creator>
				<category><![CDATA[Computing and Tech]]></category>
		<category><![CDATA[Security/Insecurity Insanity]]></category>
		<category><![CDATA[Skepticism]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[duct tape]]></category>
		<category><![CDATA[ethical hacking]]></category>
		<category><![CDATA[Joshua Wright]]></category>
		<category><![CDATA[SANS]]></category>
		<category><![CDATA[SCADA]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[smart grid]]></category>

		<guid isPermaLink="false">http://jaredwatkins.com/wordpress/?p=621</guid>
		<description><![CDATA[I&#8217;ve written before about the world being held together by duct tape&#8230; and it seems there are more people lately who have decided to rip off the covers and go looking for some duct tape.  The latest headline comes from the world of SCADA systems.  Researchers Lay Bare Woeful SCADA Security.  SCADA systems are small [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="" title="Duct_Tape" href="http://farm8.static.flickr.com/7016/6486021333_9c6e3d86bd.jpg"><img class="alignleft" style="float: left;" src="http://farm8.staticflickr.com/7016/6486021333_9c6e3d86bd_s.jpg" alt="Duct_Tape" /></a>I&#8217;ve written before about <a title="The world is held together by duct tape" href="http://jaredwatkins.com/wordpress/2010/09/the-world-is-held-together-by-duct-tape/">the world being held together by duct tape</a>&#8230; and it seems there are more people lately who have decided to rip off the covers and go looking for some duct tape.  The latest headline comes from the world of SCADA systems.  <a href="https://threatpost.com/en_us/blogs/looking-firesheep-moment-researchers-lay-bare-woeful-scada-security-012012">Researchers Lay Bare Woeful SCADA Security</a>.  SCADA systems are small embedded computers that help guide various kinds of industrial processes..manufacturing, power plants and water systems. Basically anything where you have sensors, motors, pumps etc that have to be monitored and controlled.  <a href="http://en.wikipedia.org/wiki/Stuxnet">Iran learned all about lax SCADA security</a> over the last couple years and now everyone else is finding out about it too.  The dirty little secret is that most of these systems haven&#8217;t fundamentally changed in the last 20 years&#8230; despite huge improvements in the level of sophistication of what&#8217;s out there now even for hobbyists.  Things like the <a href="http://www.makershed.com/Arduinos_Accessories_s/43.htm">Arduino platform</a> costs an order of magnitude less than commercial systems and can perform many of the same jobs.  Actually that&#8217;s not true though.. SCADA systems have changed in one very important way.. people started plugging them into a network.  Once you do that.. you are opening yourself up for a world of hurt if those systems were not designed to operate in a hostile environment.  As the researches in the linked story found out.. some of them can&#8217;t even be probed without crashing.. never mind standing up to direct attacks.</p>
<p>I was fortunate enough to take the SANS security course on <a href="https://www.sans.org/security-training/wireless-ethical-hacking-penetration-testing-defenses-3-mid">Wireless Ethical Hacking, Penetration Testing, and Defenses</a> a few years ago. While I totally recommend the SANS courses.. they are really top notch in the world of tech training.. one of the things I learned as a result of that course is that very few people/organizations take security seriously.   Security should be thought of as existing on a continuum along with ease of use.  That is.. something could be totally secure and totally unusable or very easy to use and totally insecure.  SCADA systems have been operating at that end of the scale for decades now and I doubt very seriously that&#8217;s going to change anytime soon.  If the customers who buy these systems cared at all about security they would demand the systems actually be more secure.  That doesn&#8217;t happen though.. and I blame human nature.</p>
<p>Incidentally&#8230; you may think your world isn&#8217;t personally touched by these systems but you would be wrong.  In fact.. in some areas you may already have a <a href="http://gigaom.com/cleantech/smart-meter-worm-could-spread-like-a-virus/">vulnerable SCADA component </a>bolted right on your own home.  Heard of the SmartGrid?  The very same researcher who taught my wireless hacking class has <a href="http://www.msnbc.msn.com/id/36055667/ns/technology_and_science-security/t/smart-meters-have-security-holes/#.TxuBaSOZNCI">found some serious issues </a>with the power meters used in smart grid systems.  Imagine a worm that could infect a network of power company smart meters.. giving control over the power they regulate to some 3rd party.  At that point it would be trivial to crash the regional electrical grid on demand.. and we know from what happened accidentally in the north east a few years ago that can take days to recover from. Sleep tight!</p>
]]></content:encoded>
			<wfw:commentRss>http://jaredwatkins.com/wordpress/2012/01/unraveling-the-duct-tape/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I do &#8211; Dynamic Daily Table Partitions With Postgres</title>
		<link>http://jaredwatkins.com/wordpress/2012/01/what-i-do-dynamic-daily-table-partitions-with-postgres/</link>
		<comments>http://jaredwatkins.com/wordpress/2012/01/what-i-do-dynamic-daily-table-partitions-with-postgres/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 21:00:13 +0000</pubDate>
		<dc:creator>JaredWatkins</dc:creator>
				<category><![CDATA[Computing and Tech]]></category>
		<category><![CDATA[Geeky Stuff]]></category>
		<category><![CDATA[My Code]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[partitions]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[resume]]></category>
		<category><![CDATA[rolling]]></category>
		<category><![CDATA[sliding]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[window]]></category>

		<guid isPermaLink="false">http://jaredwatkins.com/wordpress/?p=549</guid>
		<description><![CDATA[As part of a new and fairly large project I have a need to partition a few postgres tables and have a rolling daily window.  That is.. I want to organize data by a timestamp storing each day in its own partition and maintain 90 days of historical data.  Doing this is possible in Postgresql [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft  wp-image-581" title="postgres_elephant" src="http://jaredwatkins.com/wordpress/wp-content/uploads/2011/12/postgres_elephant-150x150.png" alt="" width="90" height="90" />As part of a new and fairly large project I have a need to partition a few postgres tables and have a rolling daily window.  That is.. I want to organize data by a timestamp storing each day in its own partition and maintain 90 days of historical data.  Doing this is possible in Postgresql but it&#8217;s not pretty or very clean to set it up.  To simplify the process I wrote this perl script that (when run daily) will pre-create a certain number of empty partitions into the future and remove the oldest partitions from your window.</p>
<p>The script is generalized so as to be easy to modify and there isn&#8217;t much here that&#8217;s specific to postgres.. so it could easily be adapted for use with other systems like Oracle. You will need to put in the DDL for the child tables you will create but otherwise it&#8217;s pretty straight forward.  Please let me know if you find this useful as I couldn&#8217;t find anything else out there like it.</p>
<p>Visit the <strong><a title="pgDynamicPartitions" href="http://jaredwatkins.com/wordpress/my-projects/pgdynamicpartitions/">project page</a></strong> for details and the download.</p>
<p>Update: Several important updates to the code and my examples since I first published this.  Be sure to grab the latest version which is starting to behave reasonably now.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaredwatkins.com/wordpress/2012/01/what-i-do-dynamic-daily-table-partitions-with-postgres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSX Mail App Using Tons of Memory and CPU?</title>
		<link>http://jaredwatkins.com/wordpress/2012/01/osx-mail-app-using-tons-of-memory-and-cpu/</link>
		<comments>http://jaredwatkins.com/wordpress/2012/01/osx-mail-app-using-tons-of-memory-and-cpu/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 18:36:15 +0000</pubDate>
		<dc:creator>JaredWatkins</dc:creator>
				<category><![CDATA[Computing and Tech]]></category>
		<category><![CDATA[Geeky Stuff]]></category>
		<category><![CDATA[cpu]]></category>
		<category><![CDATA[Entourage]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[high cpu]]></category>
		<category><![CDATA[high memory]]></category>
		<category><![CDATA[isync]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[resources]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[troubleshoot]]></category>

		<guid isPermaLink="false">http://jaredwatkins.com/wordpress/?p=598</guid>
		<description><![CDATA[I&#8217;ve been using a mac for a while now and I recently decided to dump Entourage and go to using the native Mail.app.  I noticed a problem though.. within minutes of starting up it would consume several hundred megs of ram and have frequent CPU spikes of 80 to 100%.  If Mail was left open, [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="" title="My mail.app unread messages icon" href="http://farm1.static.flickr.com/30/44074632_687cc920b9.jpg"><img class="alignleft" src="http://farm1.staticflickr.com/30/44074632_687cc920b9_s.jpg" alt="My mail.app unread messages icon" /></a>I&#8217;ve been using a mac for a while now and I recently decided to dump Entourage and go to using the native Mail.app.  I noticed a problem though.. within minutes of starting up it would consume several hundred megs of ram and have frequent CPU spikes of 80 to 100%.  If Mail was left open, memory usage would climb above 2 gig with continued CPU spikes.  After much digging I finally found the problem and fixed it.</p>
<p>I&#8217;d been using iSync back before I got an <a class="wikinvest-suggestion-link" articletype="concept" articletitle="SVBob25l_0" target="_blank" href="http://www.wikinvest.com/concept/IPhone">iPhone</a>..  and had never thought to disable it.  It looks like what was happening is that mail and other apps (ical, address book) had been building a huge database of stuff that needed to be synced to my old phone.  Once I went in and reset the sync history and disabled iSync.. everything calmed down and now a running instance of Mail.app with 3 imap accounts and an Exchange account is using about 60 MB of ram.. and it&#8217;s not steadily climbing as it had been before.  This may have also been the source of the problems I&#8217;d been having with Entourage.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaredwatkins.com/wordpress/2012/01/osx-mail-app-using-tons-of-memory-and-cpu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I do &#8211; Interviewing for Linux Engineers</title>
		<link>http://jaredwatkins.com/wordpress/2011/12/what-i-do-interviewing-for-linux-engineers/</link>
		<comments>http://jaredwatkins.com/wordpress/2011/12/what-i-do-interviewing-for-linux-engineers/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 17:00:40 +0000</pubDate>
		<dc:creator>JaredWatkins</dc:creator>
				<category><![CDATA[Computing and Tech]]></category>
		<category><![CDATA[Geeky Stuff]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[interview questions]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[load average]]></category>
		<category><![CDATA[resume]]></category>

		<guid isPermaLink="false">http://jaredwatkins.com/wordpress/?p=535</guid>
		<description><![CDATA[Now and then I&#8217;m called on to help interview candidates for linux admin/engineer slots and as I&#8217;ve been doing some of that lately I thought I&#8217;d share the way I go about doing a technical interview. This approach seems to work equally well over the phone or in person. I&#8217;m big on understanding the fundamentals [...]]]></description>
			<content:encoded><![CDATA[<p>Now and then I&#8217;m called on to help interview candidates for linux admin/engineer slots and as I&#8217;ve been doing some of that lately I thought I&#8217;d share the way I go about doing a technical interview.  This approach seems to work equally well over the phone or in person.</p>
<p>I&#8217;m big on understanding the fundamentals of linux.  If someone comes to me with a resume showing 10+ years of experience building and managing production unix/linux systems there are certain things I&#8217;d expect them to know.. and to a certain depth. If they obviously don&#8217;t.. then I have to question the validity of what&#8217;s on the resume.  So what I&#8217;ll usually do is pick a few key areas and start off with some general (easy) questions and then drill down a bit to discover the level of understanding on that particular topic. As an example.. I&#8217;ll share one of my favorites and lay it out the way I might do it during an interview.</p>
<p>Q: If I wanted to know who was logged in, how busy a system was and how long it had been up what command would tell me all that?</p>
<p>(Assuming they get that I&#8217;m looking for the &#8216;w&#8217; command and mention the system load)</p>
<p>Q: Why are there three numbers for the system load?</p>
<p>(Assuming they know about the 3 time periods)</p>
<p>Q: What is the system load.. what do those averages actually represent?</p>
<p>(This usually starts to trip up the junior people but assuming they know it&#8217;s the run queue length)</p>
<p>Q: How does a multi-cpu system affect your interpretation of system load?</p>
<p>(Assuming they say something about dividing load by CPU count)</p>
<p>Q: Describe the relationship between the load average measurement and the percentage busy you might get from &#8216;top&#8217;.</p>
<p>This is usually about as far as I&#8217;ll take something like this.. but it can lead to a discussion about things like different kernel schedulers and how they can be tweaked etc. If a person can answer these and have that sort of discussion it tells me they have the right depth of understanding a senior person should have&#8230; at least on this area.  Someone who has been an admin (but not what I&#8217;d classify as an engineer) should be able to answer at least the first 2 questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaredwatkins.com/wordpress/2011/12/what-i-do-interviewing-for-linux-engineers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I do &#8211; Voice Integration With Nagios and Asterisk</title>
		<link>http://jaredwatkins.com/wordpress/2011/12/what-i-do-voice-integration-with-nagios/</link>
		<comments>http://jaredwatkins.com/wordpress/2011/12/what-i-do-voice-integration-with-nagios/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 20:17:13 +0000</pubDate>
		<dc:creator>JaredWatkins</dc:creator>
				<category><![CDATA[Computing and Tech]]></category>
		<category><![CDATA[Geeky Stuff]]></category>
		<category><![CDATA[My Code]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[alert]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[broadsoft]]></category>
		<category><![CDATA[festival]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[notification]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[resume]]></category>
		<category><![CDATA[sln16]]></category>
		<category><![CDATA[tts]]></category>
		<category><![CDATA[voip]]></category>

		<guid isPermaLink="false">http://jaredwatkins.com/wordpress/?p=522</guid>
		<description><![CDATA[I was called on to provide a method of alerting from within nagios that was more active and direct than the usual use of email or SMS messages.  So I came up with a simple way to have a nagios notification place a phone call to our off hours tier3 support line to report certain [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft  wp-image-587" title="asterisk_logo" src="http://jaredwatkins.com/wordpress/wp-content/uploads/2011/12/asterisk_logo-150x150.png" alt="" width="120" height="120" />I was called on to provide a method of alerting from within <a target="_blank" title="Nagios NMS" href="http://nagios.org/">nagios</a> that was more active and direct than the usual use of email or SMS messages.  So I came up with a simple way to have a nagios notification place a phone call to our off hours tier3 support line to report certain very rare but serious problems.   This was actually a two part solution.  We were interested in looking for certain things coming out of the <a target="_blank" href="http://www.broadsoft.com/">Broadsoft</a> audit log that were important enough to wake someone up in the middle of the night.  So I wrote a daemonized script that tails the Broadsoft audit log and interprets it looking for these config changes and then reports this to a special <a target="_blank" href="http://bestpractical.com/rt/">RT3</a> queue.  It also notifies nagios (a push notification to a passive service check) over a socket connection. A listener script on the nagios box (using <a target="_blank" title="Net::Server Perl Module" href="http://search.cpan.org/~rhandom/Net-Server-0.99/lib/Net/Server.pod">net::server</a>) validates the syntax of the alert and lets nagios know.. which in turn triggers (and manages the scheduling) of the outgoing phone call(s) through <a target="_blank" href="http://www.asterisk.org/">asterisk</a>.</p>
<p>I used the <a target="_blank" title="Google TTS" href="http://techcrunch.com/2009/12/14/the-unofficial-google-text-to-speech-api/">google TTS</a> engine to record certain fixed statements that wold be common across calls.. converting the audio to the proper format for asterisk (SLN16) with sox.  For the specific alert text I&#8217;m using a simplified version of <a target="_blank" title="Festival Speech Engine" href="http://www.cstr.ed.ac.uk/projects/festival/">festival</a> from the command line called &#8216;flite&#8217;.   The asterisk part is done entirely in a <a target="_blank" title="Asterisk AGI" href="http://www.voip-info.org/wiki/view/Asterisk+AGI">perl agi</a> script and allows the called person to repeat the alert or acknowledge it within nagios. If they don&#8217;t answer or don&#8217;t ack the alert nagios will initiate another call in a few minutes.. and I&#8217;m able to use service escalations to notify different people if it goes too long without a response.</p>
<p>This project has more moving pieces than I usually like to use but it was interesting in just how easy it was to get working.  It&#8217;s gotten me thinking about doing a more full featured voice fronted to nagios that I could release.</p>
<p>See the code on page 2</p>
<p><span id="more-522"></span>Google TTS perl script:</p>
<div id="wpshdo_1" class="wp-synhighlighter-outer"><div id="wpshdt_1" class="wp-synhighlighter-collapsed"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_1"></a><a id="wpshat_1" class="wp-synhighlighter-title" href="#codesyntax_1"  onClick="javascript:wpsh_toggleBlock(1)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_1" onClick="javascript:wpsh_code(1)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_1" onClick="javascript:wpsh_print(1)" title="Print code"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_1" class="wp-synhighlighter-inner" style="display: none;"><pre class="perl" style="font-family:monospace;"><span class="co1">#!/usr/bin/perl</span>
&nbsp;
<span class="co1"># This takes a short string of text an spits out an mp3 audio</span>
<span class="co1"># file of it being spoken. This can then be converted for use</span>
<span class="co1"># in asterisk in the native sln16 format. </span>
&nbsp;
<span class="kw2">use</span> LWP<span class="sy0">;</span>
&nbsp;
<span class="re0">$speak</span> <span class="sy0">=</span> <span class="re0">$ARGV</span><span class="br0">&#91;</span>0<span class="br0">&#93;</span><span class="sy0">;</span>
<span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://perldoc.perl.org/functions/length.html"><span class="kw3">length</span></a><span class="br0">&#40;</span><span class="re0">$speak</span><span class="br0">&#41;</span> <span class="sy0">==</span>0 <span class="sy0">||</span> <a href="http://perldoc.perl.org/functions/length.html"><span class="kw3">length</span></a><span class="br0">&#40;</span><span class="re0">$speak</span><span class="br0">&#41;</span> <span class="sy0">&gt;</span> 100<span class="br0">&#41;</span> <span class="br0">&#123;</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="br0">&#40;</span><span class="st_h">'String is too long'</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">@headers1</span> <span class="sy0">=</span> <span class="br0">&#40;</span>
<span class="st_h">'Host'</span> <span class="sy0">=&gt;</span> <span class="st_h">'translate.google.com'</span><span class="sy0">,</span>
<span class="st_h">'User-Agent'</span> <span class="sy0">=&gt;</span> <span class="st_h">'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20111114 Ubuntu/9.10 (karmic) Firefox/8.0.1'</span><span class="sy0">,</span>
<span class="st_h">'Accept'</span> <span class="sy0">=&gt;</span> <span class="st_h">'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'</span><span class="sy0">,</span>
<span class="st_h">'Accept-Language'</span> <span class="sy0">=&gt;</span> <span class="st_h">'en-us,en;q=0.5'</span><span class="sy0">,</span>
<span class="st_h">'Accept-Encoding'</span> <span class="sy0">=&gt;</span> <span class="st_h">'gzip,deflate'</span><span class="sy0">,</span>
<span class="st_h">'Accept-Charset'</span> <span class="sy0">=&gt;</span> <span class="st_h">'ISO-8859-1,utf-8;q=0.7,*;q=0.7'</span><span class="sy0">,</span>
<span class="st_h">'Keep-Alive'</span> <span class="sy0">=&gt;</span> <span class="st_h">'300'</span><span class="sy0">,</span>
<span class="st_h">'Connection'</span> <span class="sy0">=&gt;</span> <span class="st_h">'keep-alive'</span><span class="sy0">,</span>
<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">$browser</span> <span class="sy0">=</span> LWP<span class="sy0">::</span><span class="me2">UserAgent</span><span class="sy0">-&gt;</span><span class="me1">new</span><span class="sy0">;</span>
&nbsp;
<span class="re0">$speak</span> <span class="sy0">=~</span> <span class="co2">s/ /+/g</span><span class="sy0">;</span>
&nbsp;
<span class="re0">$sec</span> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/time.html"><span class="kw3">time</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$resp</span> <span class="sy0">=</span> <span class="re0">$browser</span><span class="sy0">-&gt;</span><span class="me1">get</span><span class="br0">&#40;</span><span class="st0">&quot;http://translate.google.com/translate_tts?q=$speak&quot;</span><span class="sy0">,</span><span class="re0">@headers1</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<a href="http://perldoc.perl.org/functions/open.html"><span class="kw3">open</span></a><span class="br0">&#40;</span>FILE<span class="sy0">,</span><span class="st0">&quot;&gt;$sec.mp3&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> FILE <span class="re0">$resp</span><span class="sy0">-&gt;</span><span class="me1">content</span><span class="sy0">;</span>
<a href="http://perldoc.perl.org/functions/close.html"><span class="kw3">close</span></a><span class="br0">&#40;</span>FILE<span class="br0">&#41;</span><span class="sy0">;</span>
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;Wrote $sec.mp3<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
&nbsp;
<span class="co1"># To convert for asterisk use</span>
<span class="co1"># sox &lt;file.mp3&gt; -t raw outfile.sln16</span></pre></div></div>
<p>Nagios listener&#8230;</p>
<div id="wpshdo_2" class="wp-synhighlighter-outer"><div id="wpshdt_2" class="wp-synhighlighter-collapsed"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_2"></a><a id="wpshat_2" class="wp-synhighlighter-title" href="#codesyntax_2"  onClick="javascript:wpsh_toggleBlock(2)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_2" onClick="javascript:wpsh_code(2)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_2" onClick="javascript:wpsh_print(2)" title="Print code"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_2" class="wp-synhighlighter-inner" style="display: none;"><pre class="perl" style="font-family:monospace;"><span class="co1">#!/usr/bin/perl -w</span>
&nbsp;
<a href="http://perldoc.perl.org/functions/package.html"><span class="kw3">package</span></a> NagiosListener<span class="sy0">;</span>
&nbsp;
<span class="kw2">use</span> strict<span class="sy0">;</span>
<span class="kw2">use</span> Data<span class="sy0">::</span><span class="me2">Dumper</span><span class="sy0">;</span>
<span class="kw2">use</span> Net<span class="sy0">::</span><span class="me2">Server</span><span class="sy0">::</span><span class="me2">PreFork</span><span class="sy0">;</span>
<span class="kw1">our</span> <span class="re0">@ISA</span> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/qw.html"><span class="kw3">qw</span></a><span class="br0">&#40;</span>Net<span class="sy0">::</span><span class="me2">Server</span><span class="sy0">::</span><span class="me2">PreFork</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="kw2">use</span> Nagios<span class="sy0">::</span><span class="me2">Cmd</span><span class="sy0">;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">$NAGSOCKET</span> <span class="sy0">=</span> <span class="st_h">'/var/lib/nagios3/rw/nagios.cmd'</span><span class="sy0">;</span>
<span class="kw1">my</span> <span class="re0">$PIDfile</span> <span class="sy0">=</span> <span class="st0">&quot;/var/run/naglisten.pid&quot;</span><span class="sy0">;</span>
<span class="kw1">my</span> <span class="re0">$TIME</span> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/time.html"><span class="kw3">time</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">not</span> <span class="sy0">-</span>w <span class="re0">$NAGSOCKET</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="br0">&#40;</span><span class="st0">&quot;Unable to open $NAGSOCKET for writing<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">$nagios</span> <span class="sy0">=</span> Nagios<span class="sy0">::</span><span class="me2">Cmd</span><span class="sy0">-&gt;</span><span class="me1">new</span><span class="br0">&#40;</span> <span class="re0">$NAGSOCKET</span> <span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
NagiosListener<span class="sy0">-&gt;</span><span class="me1">run</span><span class="br0">&#40;</span>port<span class="sy0">=&gt;</span><span class="nu0">5777</span><span class="sy0">,</span> user<span class="sy0">=&gt;</span><span class="st_h">'nagios'</span><span class="sy0">,</span> group<span class="sy0">=&gt;</span><span class="st_h">'www-data'</span><span class="sy0">,</span> background<span class="sy0">=&gt;</span>1<span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<a href="http://perldoc.perl.org/functions/open.html"><span class="kw3">open</span></a> <span class="br0">&#40;</span>PID<span class="sy0">,</span> <span class="st_h">'&gt;'</span><span class="sy0">,</span> <span class="re0">$PIDfile</span><span class="br0">&#41;</span> <span class="kw1">or</span>
   <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Unable to open PID file for writing<span class="es0">\n</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> PID <span class="co5">$$</span> <span class="sy0">+</span><span class="nu0">1</span> <span class="sy0">.</span><span class="st0">&quot;<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<a href="http://perldoc.perl.org/functions/close.html"><span class="kw3">close</span></a> PID<span class="sy0">;</span>
&nbsp;
<span class="re0">$SIG</span><span class="br0">&#123;</span><span class="st_h">'TERM'</span><span class="br0">&#125;</span> <span class="sy0">=</span> <span class="kw2">sub</span>
<span class="br0">&#123;</span>
    <a href="http://perldoc.perl.org/functions/unlink.html"><span class="kw3">unlink</span></a> <span class="re0">$PIDfile</span> <span class="kw1">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="st0">&quot;Unable to remove PID file: $PIDfile<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="sy0">;</span>
&nbsp;
<span class="re0">$SIG</span><span class="br0">&#123;</span><span class="st_h">'HUP'</span><span class="br0">&#125;</span> <span class="sy0">=</span> <span class="kw2">sub</span>
<span class="br0">&#123;</span>
    <a href="http://perldoc.perl.org/functions/unlink.html"><span class="kw3">unlink</span></a> <span class="re0">$PIDfile</span> <span class="kw1">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="st0">&quot;Unable to remove PID file: $PIDfile<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
    <a href="http://perldoc.perl.org/functions/exec.html"><span class="kw3">exec</span></a><span class="br0">&#40;</span><span class="co3">$0</span><span class="sy0">,</span> <span class="st_h">''</span><span class="br0">&#41;</span> <span class="kw1">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="st0">&quot;Couldn't restart: $!<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="sy0">;</span>
&nbsp;
<span class="kw2">sub</span> process_request <span class="br0">&#123;</span>
    <span class="kw1">my</span> <span class="re0">$self</span> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/shift.html"><span class="kw3">shift</span></a><span class="sy0">;</span>
    <a href="http://perldoc.perl.org/functions/eval.html"><span class="kw3">eval</span></a>
    <span class="br0">&#123;</span>
        <a href="http://perldoc.perl.org/functions/local.html"><span class="kw3">local</span></a> <span class="re0">$SIG</span><span class="br0">&#123;</span><span class="st_h">'ALRM'</span><span class="br0">&#125;</span> <span class="sy0">=</span> <span class="kw2">sub</span> <span class="br0">&#123;</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="st0">&quot;Timed Out!<span class="es0">\n</span>&quot;</span> <span class="br0">&#125;</span><span class="sy0">;</span>
        <span class="kw1">my</span> <span class="re0">$timeout</span> <span class="sy0">=</span> <span class="nu0">300</span><span class="sy0">;</span> <span class="co1"># give the user 300 seconds to type some lines</span>
&nbsp;
        <span class="kw1">my</span> <span class="re0">$previous_alarm</span> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/alarm.html"><span class="kw3">alarm</span></a><span class="br0">&#40;</span><span class="re0">$timeout</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <span class="kw1">while</span> <span class="br0">&#40;</span><span class="re4">&lt;STDIN&gt;</span><span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            <span class="co2">s/\r?\n$//</span><span class="sy0">;</span>
            <span class="kw1">my</span> <span class="re0">$col</span> <span class="sy0">=</span> trim<span class="br0">&#40;</span><span class="co5">$_</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
            <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="kw2">STDERR</span> <span class="st0">&quot;Command: $col<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
&nbsp;
            <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$col</span> <span class="kw1">eq</span> <span class="st_h">'sysload'</span><span class="br0">&#41;</span>
            <span class="br0">&#123;</span>
                <span class="kw1">my</span> <span class="re0">$load</span> <span class="sy0">=</span> trim<span class="br0">&#40;</span><span class="st0">`uptime |tr -s ' ' |cut -d ' ' -f 11 |cut -d , -f 1`</span><span class="br0">&#41;</span><span class="sy0">;</span>
                <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;$load<span class="es0">\r</span><span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
                <span class="kw1">next</span><span class="sy0">;</span>
            <span class="br0">&#125;</span>
&nbsp;
            <span class="co1"># Check for a properly formatted response</span>
            <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$col</span> <span class="sy0">=~</span> <span class="co2">/^[\w\.]+;[\w\s_]+;\d{1}?;.+/</span><span class="br0">&#41;</span>
            <span class="br0">&#123;</span>
                <span class="kw1">my</span> <span class="br0">&#40;</span><span class="re0">$hostname</span><span class="sy0">,</span> <span class="re0">$service</span><span class="sy0">,</span> <span class="re0">$status</span><span class="sy0">,</span> <span class="re0">$desc</span><span class="br0">&#41;</span> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/split.html"><span class="kw3">split</span></a> <span class="co2">/;/</span><span class="sy0">,</span> <span class="re0">$col</span><span class="sy0">;</span>
&nbsp;
                <span class="re0">$nagios</span><span class="sy0">-&gt;</span><span class="me1">service_check</span><span class="br0">&#40;</span><span class="re0">$hostname</span><span class="sy0">,</span> <span class="re0">$service</span><span class="sy0">,</span> <span class="re0">$status</span><span class="sy0">,</span> <span class="re0">$desc</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
                <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;OK<span class="es0">\r</span><span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
                <span class="kw1">next</span><span class="sy0">;</span>
            <span class="br0">&#125;</span>
&nbsp;
            <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;ERROR: Invalid Command<span class="es0">\r</span><span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
&nbsp;
        <span class="br0">&#125;</span>
&nbsp;
        <a href="http://perldoc.perl.org/functions/alarm.html"><span class="kw3">alarm</span></a><span class="br0">&#40;</span><span class="re0">$previous_alarm</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="br0">&#125;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw1">if</span> <span class="br0">&#40;</span><span class="co5">$@</span> <span class="sy0">=~</span> <span class="co2">/timed out/i</span><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
           <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="kw2">STDOUT</span> <span class="st0">&quot;Timed Out.<span class="es0">\r</span><span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
           <a href="http://perldoc.perl.org/functions/return.html"><span class="kw3">return</span></a><span class="sy0">;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="kw2">sub</span> trim
<span class="br0">&#123;</span>
    <span class="kw1">my</span> <span class="re0">$string</span> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/shift.html"><span class="kw3">shift</span></a><span class="sy0">;</span>
    <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">not</span> <span class="re0">$string</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <a href="http://perldoc.perl.org/functions/return.html"><span class="kw3">return</span></a> <span class="re0">$string</span> <span class="br0">&#125;</span>
    <span class="re0">$string</span> <span class="sy0">=~</span> <span class="co2">s/^\s+//</span><span class="sy0">;</span>
    <span class="re0">$string</span> <span class="sy0">=~</span> <span class="co2">s/\s+$//</span><span class="sy0">;</span>
    <a href="http://perldoc.perl.org/functions/return.html"><span class="kw3">return</span></a> <span class="re0">$string</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="nu0">1</span><span class="sy0">;</span></pre></div></div>
<p>Asterisk AGI script&#8230;</p>
<div id="wpshdo_3" class="wp-synhighlighter-outer"><div id="wpshdt_3" class="wp-synhighlighter-collapsed"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_3"></a><a id="wpshat_3" class="wp-synhighlighter-title" href="#codesyntax_3"  onClick="javascript:wpsh_toggleBlock(3)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_3" onClick="javascript:wpsh_code(3)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_3" onClick="javascript:wpsh_print(3)" title="Print code"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_3" class="wp-synhighlighter-inner" style="display: none;"><pre class="perl" style="font-family:monospace;"><span class="co1">#!/usr/bin/perl</span>
&nbsp;
<span class="co1"># extensions.conf lines</span>
<span class="co1">#[nagios-out]</span>
<span class="co1">#exten =&gt; s,1,AGI(nagiosalert.pl,${Params})</span>
&nbsp;
<span class="kw2">use</span> strict<span class="sy0">;</span>
<span class="kw2">use</span> warnings<span class="sy0">;</span>
<span class="kw2">use</span> Nagios<span class="sy0">::</span><span class="me2">Cmd</span><span class="sy0">;</span>
<span class="kw2">use</span> Asterisk<span class="sy0">::</span><span class="me2">AGI</span><span class="sy0">;</span>
&nbsp;
<span class="co1"># Don't buffer output</span>
<span class="co5">$|</span><span class="sy0">=</span><span class="nu0">1</span><span class="sy0">;</span>
&nbsp;
<span class="co1">#my %input = $AGI-&gt;ReadParse();</span>
&nbsp;
<span class="kw1">my</span> <span class="br0">&#40;</span><span class="re0">$hostname</span><span class="sy0">,</span> <span class="re0">$service</span><span class="sy0">,</span> <span class="re0">$username</span><span class="sy0">,</span> <span class="re0">$message</span><span class="br0">&#41;</span> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/split.html"><span class="kw3">split</span></a> <span class="co2">/\|/</span><span class="sy0">,</span> <span class="re0">$ARGV</span><span class="br0">&#91;</span>0<span class="br0">&#93;</span><span class="sy0">;</span>
<span class="re0">$message</span> <span class="sy0">=~</span> <span class="co2">s/\+/,/g</span><span class="sy0">;</span>
&nbsp;
<span class="co1">#$message =~ s/'(.+)'/$1/;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">$NAGSOCKET</span> <span class="sy0">=</span> <span class="st_h">'/var/lib/nagios3/rw/nagios.cmd'</span><span class="sy0">;</span>
<span class="kw1">my</span> <span class="re0">$TIME</span> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/time.html"><span class="kw3">time</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="kw1">my</span> <span class="br0">&#40;</span><span class="re0">$digit</span><span class="sy0">,</span> <span class="re0">$t</span><span class="sy0">,</span> <span class="re0">$repeat</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">$AGI</span> <span class="sy0">=</span> <span class="kw2">new</span> Asterisk<span class="sy0">::</span><span class="me2">AGI</span><span class="sy0">;</span>
&nbsp;
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">not</span> <span class="sy0">-</span>w <span class="re0">$NAGSOCKET</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$AGI</span><span class="sy0">-&gt;</span><span class="me1">verbose</span> <span class="br0">&#40;</span><span class="st0">&quot;Unable to open $NAGSOCKET for writing. User: $&gt;  Group $)<span class="es0">\n</span>&quot;</span><span class="sy0">,</span> 1<span class="br0">&#41;</span><span class="sy0">;</span> <span class="br0">&#125;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">$nagios</span> <span class="sy0">=</span> Nagios<span class="sy0">::</span><span class="me2">Cmd</span><span class="sy0">-&gt;</span><span class="me1">new</span><span class="br0">&#40;</span> <span class="re0">$NAGSOCKET</span> <span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="co1"># Prepare the tts audio file</span>
<span class="re0">$t</span> <span class="sy0">=</span> <span class="st0">`flite -t &quot;$message&quot; -voice rms -o /tmp/$username.wav`</span><span class="sy0">;</span>
<span class="re0">$t</span> <span class="sy0">=</span> <span class="st0">`sox /tmp/$username.wav -t raw /tmp/$username.sln16`</span><span class="sy0">;</span>
<span class="re0">$t</span> <span class="sy0">=</span> <span class="st0">`chown asterisk.asterisk /tmp/$username.sln16`</span><span class="sy0">;</span>
<span class="re0">$t</span> <span class="sy0">=</span> <span class="st0">`cp /tmp/$username.sln16 /var/lib/asterisk/sounds/en/`</span><span class="sy0">;</span>
&nbsp;
<span class="re0">$AGI</span><span class="sy0">-&gt;</span><span class="me1">answer</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$AGI</span><span class="sy0">-&gt;</span><span class="me1">exec</span><span class="br0">&#40;</span><span class="st_h">'WAIT'</span><span class="sy0">,</span> <span class="st_h">'1'</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="re0">$AGI</span><span class="sy0">-&gt;</span><span class="me1">exec</span><span class="br0">&#40;</span><span class="st_h">'playback'</span><span class="sy0">,</span> <span class="st_h">'followingisanalert'</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="co1"># Playback the tts error message</span>
ERRMSG<span class="sy0">:</span> processDigit<span class="br0">&#40;</span><span class="re0">$AGI</span><span class="sy0">-&gt;</span><span class="me1">get_data</span><span class="br0">&#40;</span><span class="st0">&quot;$username&quot;</span><span class="sy0">,</span> <span class="st_h">'200'</span><span class="sy0">,</span> <span class="st_h">'1'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="re0">$repeat</span> <span class="sy0">=</span> <span class="nu0">2</span><span class="sy0">;</span>
<span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$repeat</span> <span class="sy0">&gt;</span> 0<span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    processDigit<span class="br0">&#40;</span><span class="re0">$AGI</span><span class="sy0">-&gt;</span><span class="me1">get_data</span><span class="br0">&#40;</span><span class="st_h">'1torepeat7toclear'</span><span class="sy0">,</span> <span class="st_h">'5000'</span><span class="sy0">,</span> <span class="st_h">'1'</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="re0">$repeat</span><span class="sy0">--;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">not</span> <span class="re0">$digit</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$AGI</span><span class="sy0">-&gt;</span><span class="me1">exec</span><span class="br0">&#40;</span><span class="st_h">'playback'</span><span class="sy0">,</span> <span class="st_h">'vm-goodbye'</span><span class="br0">&#41;</span><span class="sy0">;</span> <a href="http://perldoc.perl.org/functions/exit.html"><span class="kw3">exit</span></a> <span class="nu0">0</span><span class="sy0">;</span> <span class="br0">&#125;</span>
&nbsp;
<span class="kw2">sub</span> processDigit
<span class="br0">&#123;</span>
    <span class="kw1">my</span> <span class="br0">&#40;</span><span class="re0">$digit</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="co5">@_</span><span class="sy0">;</span>
&nbsp;
    <span class="co1">#$AGI-&gt;verbose(&quot;Digit:$digit&quot;);</span>
&nbsp;
    <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">not</span> <span class="re0">$digit</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <a href="http://perldoc.perl.org/functions/return.html"><span class="kw3">return</span></a><span class="sy0">;</span> <span class="br0">&#125;</span>
&nbsp;
    <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$digit</span> <span class="sy0">==</span> 1<span class="br0">&#41;</span> <span class="br0">&#123;</span> <a href="http://perldoc.perl.org/functions/goto.html"><span class="kw3">goto</span></a> ERRMSG<span class="sy0">;</span> <span class="br0">&#125;</span>
&nbsp;
    <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$digit</span> <span class="sy0">==</span> 7<span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
        <span class="re0">$nagios</span><span class="sy0">-&gt;</span><span class="me1">service_check</span><span class="br0">&#40;</span><span class="re0">$hostname</span><span class="sy0">,</span> <span class="re0">$service</span><span class="sy0">,</span> <span class="nu0">1</span><span class="sy0">,</span> <span class="st_h">'Alert Cleared Via Phone'</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
        <span class="re0">$AGI</span><span class="sy0">-&gt;</span><span class="me1">exec</span><span class="br0">&#40;</span><span class="st_h">'playback'</span><span class="sy0">,</span> <span class="st_h">'alert_ack'</span><span class="br0">&#41;</span><span class="sy0">;</span>
        <a href="http://perldoc.perl.org/functions/exit.html"><span class="kw3">exit</span></a> <span class="nu0">0</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
<span class="br0">&#125;</span></pre></div></div>
<p>Nagios Notification Script</p>
<div id="wpshdo_4" class="wp-synhighlighter-outer"><div id="wpshdt_4" class="wp-synhighlighter-collapsed"><table border="0" width="100%"><tr><td align="left" width="80%"><a name="#codesyntax_4"></a><a id="wpshat_4" class="wp-synhighlighter-title" href="#codesyntax_4"  onClick="javascript:wpsh_toggleBlock(4)" title="Click to show/hide code block">Source code</a></td><td align="right"><a href="#codesyntax_4" onClick="javascript:wpsh_code(4)" title="Show code only"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/code.png" /></a>&nbsp;<a href="#codesyntax_4" onClick="javascript:wpsh_print(4)" title="Print code"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/printer.png" /></a>&nbsp;<a href="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/About.html" target="_blank" title="Show plugin information"><img border="0" style="border: 0 none" src="http://jaredwatkins.com/wordpress/wp-content/plugins/wp-synhighlight/themes/default/images/info.gif" /></a>&nbsp;</td></tr></table></div><div id="wpshdi_4" class="wp-synhighlighter-inner" style="display: none;"><pre class="perl" style="font-family:monospace;"><span class="co1">#!/usr/bin/perl</span>
&nbsp;
<span class="co1">#use warnings;</span>
<span class="kw2">use</span> strict<span class="sy0">;</span>
<span class="kw2">use</span> Getopt<span class="sy0">::</span><span class="me2">Std</span><span class="sy0">;</span>
<span class="kw2">use</span> Switch<span class="sy0">;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">%options</span><span class="sy0">;</span>
<span class="kw1">my</span> <span class="br0">&#40;</span><span class="re0">$t</span><span class="sy0">,</span> <span class="re0">$dial</span><span class="sy0">,</span> <span class="re0">$text_raw</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
getopts<span class="br0">&#40;</span><span class="st0">&quot;H:m:s:p:&quot;</span><span class="sy0">,</span> <span class="re0">\%options</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">not</span> <span class="re0">$options</span><span class="br0">&#123;</span>H<span class="br0">&#125;</span> <span class="kw1">or</span> <span class="kw1">not</span> <span class="re0">$options</span><span class="br0">&#123;</span><a href="http://perldoc.perl.org/functions/m.html"><span class="kw3">m</span></a><span class="br0">&#125;</span> <span class="kw1">or</span> <span class="kw1">not</span> <span class="re0">$options</span><span class="br0">&#123;</span><a href="http://perldoc.perl.org/functions/s.html"><span class="kw3">s</span></a><span class="br0">&#125;</span> <span class="kw1">or</span> <span class="kw1">not</span> <span class="re0">$options</span><span class="br0">&#123;</span>p<span class="br0">&#125;</span> <span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    <a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;<span class="es0">\n</span>Usage: $0 -H 'host_name' -s 'service_name' -p 'phone number' -m 'tts message'<span class="es0">\n</span><span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
    <a href="http://perldoc.perl.org/functions/exit.html"><span class="kw3">exit</span></a><span class="sy0">;</span>
<span class="br0">&#125;</span>
&nbsp;
<span class="co1"># Depending on the kind of alert.. you may want to customize the message a litle.</span>
switch <span class="br0">&#40;</span><span class="re0">$options</span><span class="br0">&#123;</span><a href="http://perldoc.perl.org/functions/s.html"><span class="kw3">s</span></a><span class="br0">&#125;</span><span class="br0">&#41;</span>
<span class="br0">&#123;</span>
    <span class="kw1">case</span> <span class="co2">/international_forwarding_alert/i</span>		<span class="br0">&#123;</span> <span class="re0">$text_raw</span> <span class="sy0">=</span> <span class="st0">&quot;Possible fraud on, $options{H} $options{m}&quot;</span><span class="sy0">;</span> <span class="br0">&#125;</span>
&nbsp;
    <span class="kw1">else</span>			<span class="br0">&#123;</span> <span class="re0">$text_raw</span> <span class="sy0">=</span> <span class="st0">&quot;No match. Something is wrong on host $options{H}. The message is, $options{m}&quot;</span><span class="sy0">;</span> <span class="br0">&#125;</span>
&nbsp;
<span class="br0">&#125;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">$text</span> <span class="sy0">=</span> speechify<span class="br0">&#40;</span><span class="re0">$text_raw</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="co1"># Can't pass commas through asterisk parameter list</span>
<span class="re0">$text</span> <span class="sy0">=~</span> <span class="co2">s/,/+/g</span><span class="sy0">;</span>
&nbsp;
<span class="co1">#print &quot;$text\n&quot;;</span>
<span class="co1">#exit;</span>
&nbsp;
<span class="co1"># Generate the call file</span>
<span class="re0">$dial</span>  <span class="sy0">=</span> <span class="st0">&quot;Channel: SIP/SJC/$options{p}<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="re0">$dial</span> <span class="sy0">.=</span> <span class="st0">&quot;Callerid: Nagios &lt;7045551212&gt;<span class="es0">\n</span>&quot;</span><span class="sy0">;</span> <span class="co1"># Originating number..</span>
<span class="re0">$dial</span> <span class="sy0">.=</span> <span class="st0">&quot;MaxRetries: 5<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="re0">$dial</span> <span class="sy0">.=</span> <span class="st0">&quot;RetryTime: 60<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="re0">$dial</span> <span class="sy0">.=</span> <span class="st0">&quot;WaitTime: 60<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="re0">$dial</span> <span class="sy0">.=</span> <span class="st0">&quot;Context: nagios-out<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="re0">$dial</span> <span class="sy0">.=</span> <span class="st0">&quot;Extension: s<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="re0">$dial</span> <span class="sy0">.=</span> <span class="st0">&quot;Priority: 1<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="re0">$dial</span> <span class="sy0">.=</span> <span class="st0">&quot;Set: Params=$options{H}|$options{s}|$text<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
&nbsp;
<a href="http://perldoc.perl.org/functions/open.html"><span class="kw3">open</span></a> <span class="kw1">my</span> <span class="re0">$FP</span><span class="sy0">,</span> <span class="st_h">'&gt;'</span><span class="sy0">,</span> <span class="st0">&quot;/var/spool/asterisk/tmp/dial.call&quot;</span> <span class="kw1">or</span> <a href="http://perldoc.perl.org/functions/die.html"><span class="kw3">die</span></a> <span class="br0">&#40;</span><span class="st0">&quot;Unable to write temp call file&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="re0">$FP</span> <span class="re0">$dial</span><span class="sy0">;</span>
<a href="http://perldoc.perl.org/functions/close.html"><span class="kw3">close</span></a> <span class="re0">$FP</span><span class="sy0">;</span>
&nbsp;
<span class="re0">$t</span> <span class="sy0">=</span> <span class="st0">`chown asterisk.asterisk /var/spool/asterisk/tmp/dial.call`</span><span class="sy0">;</span>
<span class="re0">$t</span> <span class="sy0">=</span> <span class="st0">`mv /var/spool/asterisk/tmp/dial.call /var/spool/asterisk/outgoing/`</span><span class="sy0">;</span>
&nbsp;
<span class="kw2">sub</span> speechify
<span class="br0">&#123;</span>
    <span class="kw1">my</span> <span class="br0">&#40;</span><span class="re0">$r</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="co5">@_</span><span class="sy0">;</span>
&nbsp;
    <span class="co1"># Transform a into b to sound right when using TTS</span>
    <span class="kw1">my</span> <span class="sy0">%</span><a href="http://perldoc.perl.org/functions/s.html"><span class="kw3">s</span></a> <span class="sy0">=</span> <span class="br0">&#40;</span>
          <span class="st_h">'as1.iad01'</span> <span class="sy0">=&gt;</span> <span class="st_h">'a s 1 dot i a d 0 1, '</span><span class="sy0">,</span>
          <span class="st_h">'as2.iad01'</span> <span class="sy0">=&gt;</span> <span class="st_h">'a s 2 dot i a d 0 1, '</span><span class="sy0">,</span>
          <span class="st_h">'as1.sjc01'</span> <span class="sy0">=&gt;</span> <span class="st_h">'a s 1 dot s j c 0 1, '</span><span class="sy0">,</span>
          <span class="st_h">'as2.sjc01'</span> <span class="sy0">=&gt;</span> <span class="st_h">'a s 2 dot s j c 0 1, '</span><span class="sy0">,</span>
          <span class="st_h">'as1.ams01'</span> <span class="sy0">=&gt;</span> <span class="st_h">'a s 1 dot a m s 0 1, '</span><span class="sy0">,</span>
          <span class="st_h">'as2.ams02'</span> <span class="sy0">=&gt;</span> <span class="st_h">'a s 2 dot a m s 0 1, '</span><span class="sy0">,</span>
          <span class="st_h">'as1.smb01'</span> <span class="sy0">=&gt;</span> <span class="st_h">'a s 1 dot s m b 0 1, '</span><span class="sy0">,</span>
          <span class="st_h">'as2.smb01'</span> <span class="sy0">=&gt;</span> <span class="st_h">'a s 2 dot s m b 0 1, '</span><span class="sy0">,</span>
          <span class="st_h">'groupid'</span>   <span class="sy0">=&gt;</span> <span class="st_h">'group i d, '</span><span class="sy0">,</span>
          <span class="st_h">'userid'</span>    <span class="sy0">=&gt;</span> <span class="st_h">'user i d, '</span><span class="sy0">,</span>
          <span class="st_h">'calledby'</span>  <span class="sy0">=&gt;</span> <span class="st_h">'called by, '</span><span class="sy0">,</span>
         <span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
    <span class="kw1">my</span> <span class="sy0">@</span><a href="http://perldoc.perl.org/functions/split.html"><span class="kw3">split</span></a> <span class="sy0">=</span> <a href="http://perldoc.perl.org/functions/split.html"><span class="kw3">split</span></a> <span class="co2">/ /</span><span class="sy0">,</span> <span class="re0">$r</span><span class="sy0">;</span>
    <span class="kw1">my</span> <span class="re0">@out</span> <span class="sy0">=</span> <span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
    <span class="kw1">my</span> <span class="re0">$lastbite</span><span class="sy0">;</span>
&nbsp;
    BITE<span class="sy0">:</span> <span class="kw1">foreach</span> <span class="kw1">my</span> <span class="re0">$bite</span> <span class="br0">&#40;</span><span class="sy0">@</span><a href="http://perldoc.perl.org/functions/split.html"><span class="kw3">split</span></a><span class="br0">&#41;</span>
    <span class="br0">&#123;</span>
&nbsp;
        <span class="co1"># Check the hash for a known word replacement</span>
        <span class="kw1">foreach</span> <span class="kw1">my</span> <span class="re0">$key</span> <span class="br0">&#40;</span> <a href="http://perldoc.perl.org/functions/keys.html"><span class="kw3">keys</span></a> <span class="sy0">%</span><a href="http://perldoc.perl.org/functions/s.html"><span class="kw3">s</span></a> <span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$bite</span> <span class="sy0">=~</span> <span class="co2">/$key/i</span><span class="br0">&#41;</span>
            <span class="br0">&#123;</span>
                <span class="re0">$lastbite</span> <span class="sy0">=</span> <span class="re0">$bite</span><span class="sy0">;</span>
                <span class="re0">$bite</span> <span class="sy0">=~</span> <span class="co2">s/$bite/$s{$key}/i</span><span class="sy0">;</span>
                <a href="http://perldoc.perl.org/functions/push.html"><span class="kw3">push</span></a> <span class="re0">@out</span><span class="sy0">,</span> <span class="re0">$bite</span><span class="sy0">;</span>
                <span class="kw1">next</span> BITE<span class="sy0">;</span>
            <span class="br0">&#125;</span>
        <span class="br0">&#125;</span>
&nbsp;
        <span class="co1"># The thing/word folling any of these needs to be spelled out</span>
        <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$lastbite</span> <span class="sy0">=~</span> <span class="co2">/groupid/i</span> <span class="kw1">or</span> <span class="re0">$lastbite</span> <span class="sy0">=~</span> <span class="co2">/userid/i</span><span class="br0">&#41;</span>
        <span class="br0">&#123;</span>
            <span class="re0">$lastbite</span> <span class="sy0">=</span> <span class="re0">$bite</span><span class="sy0">;</span>
            <span class="re0">$bite</span> <span class="sy0">=~</span> <span class="co2">s/(\w)(?=\w)/$1 /g</span><span class="sy0">;</span>
            <a href="http://perldoc.perl.org/functions/push.html"><span class="kw3">push</span></a> <span class="re0">@out</span><span class="sy0">,</span> <span class="st0">&quot;$bite, &quot;</span><span class="sy0">;</span>
            <span class="kw1">next</span> BITE<span class="sy0">;</span>
        <span class="br0">&#125;</span>
&nbsp;
        <a href="http://perldoc.perl.org/functions/push.html"><span class="kw3">push</span></a> <span class="re0">@out</span><span class="sy0">,</span> <span class="re0">$bite</span><span class="sy0">;</span>
        <span class="re0">$lastbite</span> <span class="sy0">=</span> <span class="re0">$bite</span><span class="sy0">;</span>
    <span class="br0">&#125;</span>
&nbsp;
    <a href="http://perldoc.perl.org/functions/return.html"><span class="kw3">return</span></a> <span class="st0">&quot;@out&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://jaredwatkins.com/wordpress/2011/12/what-i-do-voice-integration-with-nagios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://translate.google.com/translate_tts?q=" length="0" type="audio/mpeg" />
		</item>
		<item>
		<title>Sketchy Things From China &#8211; &#8216;Apple&#8217; Power Supply</title>
		<link>http://jaredwatkins.com/wordpress/2011/11/sketchy-things-from-china-apple-power-supply/</link>
		<comments>http://jaredwatkins.com/wordpress/2011/11/sketchy-things-from-china-apple-power-supply/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 23:11:28 +0000</pubDate>
		<dc:creator>JaredWatkins</dc:creator>
				<category><![CDATA[Geeky Stuff]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[china]]></category>
		<category><![CDATA[ebay]]></category>
		<category><![CDATA[fake]]></category>
		<category><![CDATA[knock off]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[power supply]]></category>

		<guid isPermaLink="false">http://jaredwatkins.com/wordpress/?p=486</guid>
		<description><![CDATA[As part of a new project I needed a power connector for a macbook. Not wanting to shell out $65 for an official power supply just for the connector I picked one up from ebay for about $20. On first glance this looks like an apple power supply.. but something just seemed off about it.  [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jaredwatkins.com/wordpress/wp-content/uploads/2011/10/powersupplies.jpg"><img class="alignleft size-thumbnail wp-image-488" title="powersupplies" src="http://jaredwatkins.com/wordpress/wp-content/uploads/2011/10/powersupplies-150x150.jpg" alt="" width="150" height="150" /></a>As part of a new project I needed a power connector for a macbook. Not wanting to shell out $65 for an official power supply just for the connector I picked one up from ebay for about $20. On first glance this looks like an apple power supply.. but something just seemed off about it.  On closer inspection I found lots of things were different&#8230; this was clearly a knock off. Of course.. for my use I didn&#8217;t really care as I only needed the proprietary connector but I decided to do some testing and side by side comparisons just to find out.  First off.. there are no Apple logos or markings on this supply so it&#8217;s not technically pretending to be official.   The color of the plastic is a shade different.. it&#8217;s not white. The body has a sort of lavender tinge to it.. the removable plug has this as well but a bit lighter.   The under side of the removable plug has visible assembly screws (one with a stripped head) while the Apple one has none.  The &#8216;button&#8217; the removable piece snaps over is metal on the official supply while it&#8217;s plastic on the import. The power connector on the official one is metal while the import uses silver colored plastic.  The knock off is noticeably lighter but I don&#8217;t know why that is without opening them both up.. which I don&#8217;t plan to do.  The technical info is printed in a different location and I am highly suspicious of the CE stamp and I note a missing UL (underwriters labs) stamp.  So if you used this power supply and it started a fire.. would your insurance cover it since this is not an &#8216;approved&#8217; electrical device? I checked the output with a volt meter and found that it was putting out the right voltage.. but that&#8217;s all I can say about the electrical quality of the power supply.</p>
<p>Update: I can now report seeing three different behaviors from the various power plugs I&#8217;ve been playing with.  When my Macbook Pro is powered from the actual &#8216;official&#8217; apple wall supply it will charge the battery while running (obviously) AND continue to operate the laptop even with the battery removed.  The official airline supply cable can be run with about 14-16.5v and will run the laptop but not charge the battery and it won&#8217;t power the laptop with the battery removed.  My external solar/battery power supply using the chinese connector will run and charge the battery but will NOT power the laptop with the battery removed.  That last bit of behavior was unexpected and I have to wonder what else is going on there to cause that.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaredwatkins.com/wordpress/2011/11/sketchy-things-from-china-apple-power-supply/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WBT Next Talker Pitch</title>
		<link>http://jaredwatkins.com/wordpress/2011/11/wbt-next-talker-pitch/</link>
		<comments>http://jaredwatkins.com/wordpress/2011/11/wbt-next-talker-pitch/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 16:00:37 +0000</pubDate>
		<dc:creator>JaredWatkins</dc:creator>
				<category><![CDATA[Charlotte]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[contest]]></category>
		<category><![CDATA[economics]]></category>
		<category><![CDATA[next talker]]></category>
		<category><![CDATA[politics]]></category>
		<category><![CDATA[radio]]></category>
		<category><![CDATA[sarcasm]]></category>
		<category><![CDATA[wbt]]></category>

		<guid isPermaLink="false">http://jaredwatkins.com/wordpress/?p=515</guid>
		<description><![CDATA[The local news talk radio station is having a contest where the winner gets to host their own weekly show.  It&#8217;s only two hours a week on sunday night.. but it sounded like something that might be fun.  So this is my entry.  It was recorded and mixed with the open source Ardour digital workstation [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">The local news talk radio station is having a contest where the winner gets to host their own weekly show.  It&#8217;s only two hours a week on sunday night.. but it sounded like something that might be fun.  So this is my entry.  It was recorded and mixed with the open source <a href="http://ardour.org/">Ardour</a> digital workstation and the <a href="http://jackaudio.org/">Jack</a> audio sub system under OSX.</p>
<p><iframe src="http://www.youtube.com/embed/XgPL9Z9sgRw" frameborder="0" width="420" height="315"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://jaredwatkins.com/wordpress/2011/11/wbt-next-talker-pitch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 5/33 queries in 0.195 seconds using disk: basic
Object Caching 1052/1152 objects using disk: basic

Served from: jaredwatkins.com @ 2012-02-23 00:15:56 -->
