<?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>Hungry Machine &#187; aim</title>
	<atom:link href="http://blog.hungrymachine.com/tag/aim/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hungrymachine.com</link>
	<description>The guys behind LivingSocial</description>
	<lastBuildDate>Sun, 25 Oct 2009 15:08:39 +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>Using a ruby-based AIM notifier in nagios</title>
		<link>http://blog.hungrymachine.com/2007/08/14/using-a-ruby-based-aim-notifier-in-nagios/</link>
		<comments>http://blog.hungrymachine.com/2007/08/14/using-a-ruby-based-aim-notifier-in-nagios/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 22:36:00 +0000</pubDate>
		<dc:creator>val</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Ops]]></category>
		<category><![CDATA[aim]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">blog.hungrymachine.com/2007/08/17/using-a-ruby-based-aim-notifier-in-nagios</guid>
		<description><![CDATA[If you use nagios for monitoring of your rails instances, you might want to get notification not only via email or SMS-messages but to your AIM when you are online. The script (libexec/aim_notifier.rb) utilizes the Net::TOC gem for sending out notifications:


#!/usr/bin/env ruby

 require 'rubygems'
 require 'net/toc'

 user = 'your_bot_name'
 password = 'bot_password'

 msg = ARGV[0].to_s.gsub('\n', [...]]]></description>
			<content:encoded><![CDATA[<p>If you use <a href="http://www.nagios.org/">nagios</a> for monitoring of your rails instances, you might want to get notification not only via email or <a href="http://www.sms411.net/2006/07/how-to-send-email-to-phone.html"><span class="caps">SMS</span>-messages</a> but to your <span class="caps">AIM</span> when you are online. The script (<em>libexec/aim_notifier.rb</em>) utilizes the <a href="http://rubyforge.org/projects/net-toc/">Net::TOC</a> gem for sending out notifications:</p>
<div class="CodeRay">
<div class="code">
<pre><span style="color:#888">#!/usr/bin/env ruby</span>

 require <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">rubygems</span><span style="color:#710">'</span></span>
 require <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">net/toc</span><span style="color:#710">'</span></span>

 user = <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">your_bot_name</span><span style="color:#710">'</span></span>
 password = <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">bot_password</span><span style="color:#710">'</span></span>

 msg = <span style="color:#038; font-weight:bold">ARGV</span>[<span style="color:#00D; font-weight:bold">0</span>].to_s.gsub(<span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">\n</span><span style="color:#710">'</span></span>, <span style="background-color:#fff0f0"><span style="color:#710">&quot;</span><span style="color:#04D">\n</span><span style="color:#710">&quot;</span></span>)

 client = <span style="color:#036; font-weight:bold">Net</span>::<span style="color:#036; font-weight:bold">TOC</span>.new(user, password)

 client.connect

 sleep <span style="color:#00D; font-weight:bold">3</span>

 buddies = []

 client.buddy_list.each_group { |g, b| buddies = b <span style="color:#080; font-weight:bold">if</span> g == <span style="background-color:#fff0f0"><span style="color:#710">'</span><span style="color:#D20">Friends</span><span style="color:#710">'</span></span> }

 buddies.each <span style="color:#080; font-weight:bold">do</span> |b|
   b.send_im(msg) <span style="color:#080; font-weight:bold">if</span> b.available?
 <span style="color:#080; font-weight:bold">end</span>

 sleep <span style="color:#00D; font-weight:bold">3</span>

 client.disconnect</pre>
</div>
</div>
<p> You need to add any account you want to be notified to bot&#8217;s friends (either by logging to <span class="caps">AIM</span> using the bot account or using Net::TOC&#8217;s ability to add friends).</p>
<p> The last piece is to add a new notifier in <em>etc/objects/commands.cfg</em> as:</p>
<div class="CodeRay">
<div class="code">
<pre> define command{
         command_name    notify-service-by-aim
         command_line    $USER1$/aim_notifier.rb $ARG1$ $ARG2$ &quot;***** Nagios *****\n\nNotification Ty
 pe: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState:
 $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$&quot;
         }</pre>
</div>
</div>
<p> and to append it to the list of notifiers defined for a contact template in <em>etc/objects/commands.cfg</em>:</p>
<div class="CodeRay">
<div class="code">
<pre> service_notification_commands   notify-service-by-email,notify-service-by-aim</pre>
</div>
</div>
<p>Repeat the configuration if you want to use the <span class="caps">AIM</span> notification for hosts as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hungrymachine.com/2007/08/14/using-a-ruby-based-aim-notifier-in-nagios/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
