<?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>Saiweb &#187; Nagios</title>
	<atom:link href="http://www.saiweb.co.uk/category/nagios/feed" rel="self" type="application/rss+xml" />
	<link>http://www.saiweb.co.uk</link>
	<description>Ramblings of a Sys admin</description>
	<lastBuildDate>Mon, 06 Feb 2012 14:57:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Nagios &#8211; Send alerts to twitter</title>
		<link>http://www.saiweb.co.uk/nagios/nagios-send-alerts-to-twitter</link>
		<comments>http://www.saiweb.co.uk/nagios/nagios-send-alerts-to-twitter#comments</comments>
		<pubDate>Mon, 24 Aug 2009 12:37:18 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[Nagios]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[alert]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[text]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=740</guid>
		<description><![CDATA[Pre-req reading: Nagios customization: Alerting via SMS, or anything you like! Making the bird tweet using python or Update twitter in a single line This entry will cover how to send nagios alerts to twitter, in the examples to follow curl will be used however you can choose to use the python example (link above) [...]]]></description>
			<content:encoded><![CDATA[<p>Pre-req reading:</p>
<p><a href="http://www.saiweb.co.uk/nagios/nagios-customization-alerting-via-sms-or-anything-you-like">Nagios customization: Alerting via SMS, or anything you like!</a></p>
<p><a href="http://www.saiweb.co.uk/linux/update-twitter-in-a-single-line">Making the bird tweet using python<br />
</a><br />
or<br />
<a href="http://www.saiweb.co.uk/python/making-the-bird-tweet-using-python">Update twitter in a single line</a></p>
<p>This entry will cover how to send nagios alerts to twitter, in the examples to follow curl will be used however you can choose to use the python example (link above) in place of this.</p>
<p>Firstly edit /usr/local/nagios/etc/objects/commands.cfg</p>
<p>And add the two following commands.</p>
<p><strong>UPDATE 24/03/2011</strong> Twitter no longer supports basic auth, use my oAuth updater <a href="https://github.com/Oneiroi/nagios_addons/blob/master/twitter/nagios_bot.py">here</a></p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">define <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; command_name &nbsp; &nbsp;notify-by-twitter<br />
&nbsp; &nbsp; &nbsp; &nbsp; command_line &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>curl <span style="color: #660033;">--basic</span> <span style="color: #660033;">--user</span> <span style="color: #ff0000;">&quot;twitteruser:twitterpassword&quot;</span> <span style="color: #660033;">--data-ascii</span> <span style="color: #ff0000;">&quot;status=[Nagios] <span style="color: #007800;">$NOTIFICATIONTYPE</span>$ <span style="color: #007800;">$HOSTALIAS</span>$/<span style="color: #007800;">$SERVICEDESC</span>$ is <span style="color: #007800;">$SERVICESTATE</span>$&quot;</span> http:<span style="color: #000000; font-weight: bold;">//</span>twitter.com<span style="color: #000000; font-weight: bold;">/</span>statuses<span style="color: #000000; font-weight: bold;">/</span>update.json<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<br />
define <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; command_name &nbsp; &nbsp;host-notify-by-twitter<br />
&nbsp; &nbsp; &nbsp; &nbsp; command_line &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>curl <span style="color: #660033;">--basic</span> <span style="color: #660033;">--user</span> <span style="color: #ff0000;">&quot;twitteruser:twitterpassword&quot;</span> <span style="color: #660033;">--data-ascii</span> <span style="color: #ff0000;">&quot;status=[Nagios] <span style="color: #007800;">$HOSTSTATE</span>$ alert for <span style="color: #007800;">$HOSTNAME</span>$&quot;</span> http:<span style="color: #000000; font-weight: bold;">//</span>twitter.com<span style="color: #000000; font-weight: bold;">/</span>statuses<span style="color: #000000; font-weight: bold;">/</span>update.json<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now define a contact for this twitter service</p>
<p>/usr/local/nagios/etc/objects/contacts.cfg</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">define contact<span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; contact_name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;twitter<br />
&nbsp; &nbsp; &nbsp; &nbsp; service_notification_commands &nbsp; notify-by-twitter<br />
&nbsp; &nbsp; &nbsp; &nbsp; host_notification_commands &nbsp; &nbsp; &nbsp;host-notify-by-twitter<br />
&nbsp; &nbsp; &nbsp; &nbsp; service_notification_period 24x7<br />
&nbsp; &nbsp; &nbsp; &nbsp; host_notification_period 24x7<br />
&nbsp; &nbsp; &nbsp; &nbsp; service_notification_options a<br />
&nbsp; &nbsp; &nbsp; &nbsp; host_notification_options a<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span></div></td></tr></tbody></table></div>
<p>Choose your own notification options, for my feed I only choose alerts, I also have this send updated to a &#8216;private feed&#8217; which I then follow.</p>
<p>Add this contact into your existing contact groups, i.e.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">define contactgroup<span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; contactgroup_name &nbsp; &nbsp; &nbsp; admins<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">alias</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Nagios Administrators<br />
&nbsp; &nbsp; &nbsp; &nbsp; members &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nagiosadmin,sms_alert,twitter<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#125;</span></div></td></tr></tbody></table></div>
<p>Then run a nagios-verify to ensure you have no syntax errors, and restart nagios.</p>
<p>Trigger an alert by manually switching a monitored service off or entering a manual result to test.</p>
<p><span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/nagios/nagios-send-alerts-to-twitter" data-text="Nagios &#8211; Send alerts to twitter" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fnagios%2Fnagios-send-alerts-to-twitter&#038;text=Nagios%20%26%238211%3B%20Send%20alerts%20to%20twitter" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/nagios/nagios-send-alerts-to-twitter/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>High Availability mySQL binlog position comparrison woes</title>
		<link>http://www.saiweb.co.uk/nagios/high-availability-mysql-binlog-position-comparrison-woes</link>
		<comments>http://www.saiweb.co.uk/nagios/high-availability-mysql-binlog-position-comparrison-woes#comments</comments>
		<pubDate>Tue, 16 Jun 2009 14:10:19 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[mySQL]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[high availability]]></category>
		<category><![CDATA[replication]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/?p=666</guid>
		<description><![CDATA[I ment to note this down yesterday but everything is going ten to the dozen at the moment. basically I have now authored a nagios addon for monitoring master-master replication between two servers, this carries out 4 stages of checks Validates all required data is passed by servers Slave IO is running on both servers [...]]]></description>
			<content:encoded><![CDATA[<p>I ment to note this down yesterday but everything is going ten to the dozen at the moment.</p>
<p>basically I have now authored a nagios addon for monitoring master-master replication between two servers, this carries out 4 stages of checks</p>
<ol>
<li>Validates all required data is passed by servers</li>
<li>Slave IO is running on both servers</li>
<li>Seconds_Behind_Master check, args can be passed to vary warn and critical thresholds</li>
<li>(slave) Master_Log_File == (master) File</li>
</ol>
<p>The 5th check was a comparison on the binlog positions themselves, comparing (slave) Read_Master_Log_Pos and (master) Position</p>
<p>Here in lies the problem, which took a while to track down, the problem is that no matter what I tried the slave was <strong>ALWAYS</strong> behind the master position &#8230; but why?</p>
<p>The reason is why I designed the High Availability solution in the first place &#8230; Very high traffic level, in the region of 20,800 transactions per second.</p>
<p>Why was this the problem? the two queries run to gather the data are done sequentially per server, using the python time library I was able to find that there is a 0.02s interval between gathering datasets (20 milliseconds) &#8230; in that time 416 transactions had take place.</p>
<p>i.e.</p>
<p>time: binlog pos</p>
<p>Slave A</p>
<p>0.000: 100</p>
<p>Master B</p>
<p>0.020: 516</p>
<p>This unfortunately has now lead to some 32 lines of code being commented out, as I can see no way to reliably use the binlog positions for monitoring the replication in this situation, if any delay occurs anywhere at any point during the dataset collection i.e. network latency, delay in query processing due to traffic peak on one server &#8230; etc. the collected samples will always be different</p>
<p>The only way I ever see this working is if you can validate that the datasets came from the same exact point in time down to the nanosecond, this however is again not possible, on the network the servers currently reside there is a 0.13 millisecond ping response time this works out to 13,000 nanoseconds (0.00013 * 10^9)</p>
<p>If anyone has any theories on how to overcome this please let me know.</p>
<p>NOTE: At present due to the programming of this addon being done during working hours the nagios addons are not for public release at this time, this may be subject to change in the future should my employers allow their release.</p>
<p><span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/nagios/high-availability-mysql-binlog-position-comparrison-woes" data-text="High Availability mySQL binlog position comparrison woes" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fnagios%2Fhigh-availability-mysql-binlog-position-comparrison-woes&#038;text=High%20Availability%20mySQL%20binlog%20position%20comparrison%20woes" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/nagios/high-availability-mysql-binlog-position-comparrison-woes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nagios customization: Alerting via SMS, or anything you like!</title>
		<link>http://www.saiweb.co.uk/nagios/nagios-customization-alerting-via-sms-or-anything-you-like</link>
		<comments>http://www.saiweb.co.uk/nagios/nagios-customization-alerting-via-sms-or-anything-you-like#comments</comments>
		<pubDate>Fri, 22 Feb 2008 13:28:13 +0000</pubDate>
		<dc:creator>Buzz</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[alerting]]></category>
		<category><![CDATA[customization]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[phone]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[txt]]></category>

		<guid isPermaLink="false">http://www.saiweb.co.uk/nagios/nagios-customization-alerting-via-sms-or-anything-you-like</guid>
		<description><![CDATA[So I find myself needing to tweak my Nagios installation a little bit, in this case I found the need for &#8220;out of hours&#8221; SMS alerts. Nagios doesn&#8217;t cater for this natively, rather it does however allow you to create your own custom commands, this allows you to specify a script to be executed. Now [...]]]></description>
			<content:encoded><![CDATA[<p>So I find myself needing to tweak my <a href="http://www.nagios.org/" title="Nagios" target="_blank">Nagios</a> installation a little bit, in this case I found the need for &#8220;out of hours&#8221; SMS alerts.</p>
<p><a href="http://www.nagios.org/" title="Nagios" target="_blank">Nagios</a> doesn&#8217;t cater for this natively, rather it does however allow you to create your own custom commands, this allows you to specify a script to be executed.</p>
<p>Now I am going to assume you are already quite familiar with <a href="http://www.nagios.org/" title="Nagios" target="_blank">Nagios</a> , so here is the command definition from my installation.</p>
<p><font color="#c0c0c0"><br />
</font></p>
<p align="left"><font color="#3366ff"> # &#8216;alert-by-sms&#8217; command definition<br />
</font><font color="#3366ff"> define command{<br />
</font><font color="#3366ff"> command_name    alert-by-sms<br />
</font><font color="#3366ff"> command_line    /etc/nagios/alert-by-sms.php &#8220;** $NOTIFICATIONTYPE$ alert &#8211; $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **&#8221;<br />
</font><font color="#3366ff"> }</font></p>
<p>As you can see all this command definition realy does is execute a php script, bear in mind that</p>
<p>&#8220;/path/to/php /path/to/script &#8221;</p>
<p>as the command_line does not seem to work, so just add &#8220;#!/path/to/php -q&#8221; to the top of the php script (before the opening &lt;?PHP tag). and CHMOD +X the file.</p>
<p>The php script used here takes $argv[1] and passes it into a function specific to the SMS api I use, the phone number and API definitions are hard coded ito the script.<br />
You don&#8217;t really need me to upload my script, and if you do then you shouldn&#8217;t be attempting this &#8230;</p>
<p>Basically <a href="http://www.nagios.org/" title="Nagios" target="_blank">Nagios</a> will execute the script, as defined at command_line, the script can do anything you choose.</p>
<p>Now to implement the command so it is actually used, I am pretty sure this entry in &#8220;timeperiods.cfg&#8221; is the default but just incase here it is.</p>
<p><font color="#3366ff"># &#8216;nonworkhours&#8217; timeperiod definition<br />
define timeperiod{<br />
timeperiod_name nonworkhours<br />
alias           Non-Work Hours<br />
sunday          00:00-24:00<br />
monday          00:00-09:00,17:00-24:00<br />
tuesday         00:00-09:00,17:00-24:00<br />
wednesday       00:00-09:00,17:00-24:00<br />
thursday        00:00-09:00,17:00-24:00<br />
friday          00:00-09:00,17:00-24:00<br />
saturday        00:00-24:00<br />
}</font></p>
<p>This is what I use for the &#8220;out of hours&#8221; definition, now to implement the SMS alerting, for this I have simply created a new contact definition in &#8220;contacts.cfg&#8221;, granted this means there are now two contact definitions for myself.</p>
<p><font color="#3366ff">define contact{<br />
contact_name                    out_of_hours<br />
alias                           Out Of Hours Mobile</font></p>
<p><font color="#3366ff">service_notification_period     nonworkhours<br />
host_notification_period        nonworkhours<br />
service_notification_options    c,u,r,f<br />
host_notification_options       d,u,r<br />
service_notification_commands   alert-by-sms<br />
host_notification_commands      alert-by-sms<br />
email                          <span class="mh-email"><a href='http://www.google.com/recaptcha/mailhide/d?k=01zJpju87KejH2_v9OHtypaA==&amp;c=JMG0BHkI6S2YtKdtj6NrCTwsZvVuhpgmhlck_1ZKmIM=' onclick="window.open('http://www.google.com/recaptcha/mailhide/d?k=01zJpju87KejH2_v9OHtypaA==&amp;c=JMG0BHkI6S2YtKdtj6NrCTwsZvVuhpgmhlck_1ZKmIM=', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;" title="This email is protected with reCaptcha, please click the link to retrieve the email">HIDDEN EMAIL</a></span></font></p>
<p><font color="#3366ff">}</font></p>
<p>This can be further customized depending on your setup, in this case the contact is me and I want to receive alerts for all servers &amp; services, so I just add the contact  &#8220;out_of_hours&#8221; into the admins contact group.</p>
<p><font color="#3366ff">define contactgroup{<br />
contactgroup_name       admins<br />
alias                   Nagios Administrators<br />
members                 nagios-admin,out_of_hours<br />
}</font></p>
<p>So there you have it, you now have the ground work to potentially make <a href="http://www.nagios.org/" title="Nagios" target="_blank">Nagios</a> fire you alerts anyway you like, you could go as far as having it call you via attached modem, if you _realy_ want, but when you want your servers talking to you via phone call is the day you need to switch to decaff, and head out to the pub once in a while.</p>
<p>Now just &#8220;nagios -v /path/to/nagios.cfg&#8221; to do a quick sanity check and make sure there are no errors (if you have any go back and fix them and run nagios -v again!), if all is ok /etc/init.d/nagios restart (or equivalent for your distribution).</p>
<p>As always if you run into problems drop me a comment <img src='http://cdn.saiweb.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <span style="float: left;" ><a class="twitter-share-button"  data-via="Saiweb" data-count="horizontal" data-related="Saiweb:David Busby" data-lang="en" data-url="http://www.saiweb.co.uk/nagios/nagios-customization-alerting-via-sms-or-anything-you-like" data-text="Nagios customization: Alerting via SMS, or anything you like!" href="http://twitter.com/share?via=Saiweb&#038;count=horizontal&#038;related=Saiweb%3ADavid%20Busby&#038;lang=en&#038;url=http%3A%2F%2Fwww.saiweb.co.uk%2Fnagios%2Fnagios-customization-alerting-via-sms-or-anything-you-like&#038;text=Nagios%20customization%3A%20Alerting%20via%20SMS%2C%20or%20anything%20you%20like%21" >Tweet</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.saiweb.co.uk/nagios/nagios-customization-alerting-via-sms-or-anything-you-like/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using apc
Database Caching 8/29 queries in 0.069 seconds using apc
Object Caching 735/795 objects using apc
Content Delivery Network via Rackspace Cloud Files: cdn.saiweb.co.uk

Served from: www.saiweb.co.uk @ 2012-02-08 16:09:38 -->
