<?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>Abbas &#124; Bassu &#187; customize default raid mdadm email template</title>
	<atom:link href="http://bashukhan.com/tag/customize-default-raid-mdadm-email-template/feed/" rel="self" type="application/rss+xml" />
	<link>http://bashukhan.com</link>
	<description>Life&#039;s having zeros and ones all over</description>
	<lastBuildDate>Sat, 04 Sep 2010 23:55:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>More Raid tidbits &#8211; Monitoring all raid events and changing default email template</title>
		<link>http://bashukhan.com/more-raid-tidbits-monitoring-all-raid-events-and-changing-default-email-template/</link>
		<comments>http://bashukhan.com/more-raid-tidbits-monitoring-all-raid-events-and-changing-default-email-template/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 19:27:41 +0000</pubDate>
		<dc:creator>Abbas</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[check all raid events]]></category>
		<category><![CDATA[customize default raid mdadm email template]]></category>
		<category><![CDATA[mdadm monitor warning level events]]></category>
		<category><![CDATA[monitor all raid events linux]]></category>
		<category><![CDATA[photoblog]]></category>

		<guid isPermaLink="false">http://bashukhan.com/?p=157</guid>
		<description><![CDATA[A geek really knows the importance of his or her data and backups that just avoids pulling the hair off! When one of my hard drives on a server just died after having a well served 6000+ hours of life span, I found myself really lucky as other array component of RAID1 came to the [...]]]></description>
			<content:encoded><![CDATA[<p>A geek really knows the importance of his or her data and backups that just avoids pulling the hair off! When one of my hard drives on a server just died after having a well served 6000+ hours of life span, I found myself really lucky as other array component of RAID1 came to the rescue. Reason was a perhaps a short circuit which could have cost me the biggest loss of my data ever, I had in my life, so a blazing smile was well deserved. Electric power is one of the infinite things that doesn&#8217;t work here like it always (oh, its a long story &#8211; I should tell some of it sometime later)!</p>
<p>I got an email from mdmonitor telling me about DegradedArray event. So, when I was rebuilding the array, I noticed I got no alerts about rebuild process or  array status updates which I really wanted to investigate. Till that time, I wasn&#8217;t event knowing that &#8216;mdadm &#8211;monitor&#8217; only sends you the critical updates. So, I pulled up man pages and saw these are critical events:</p>
<ul>
<li>DeviceDisappeared</li>
<li> Fail</li>
<li> FailSpare</li>
<li> DegradedArray</li>
</ul>
<p>Rest of the events are not reported at all! Also, that RHEL5&#8242;s mdadm package has pre-compiled template of email that mdadm sends upon occurrence of a critical event which I wanted to change from as well cause it looks pretty immature:</p>
<pre class="brush: bash;">
This is an automatically generated mail message from mdadm running on HOSTNAME
A DegradedArray event had been detected on md device /dev/md1.
Faithfully yours, etc.

P.S. The /proc/mdstat file currently contains the following:
bla bla bla
</pre>
<p>Seriously, it says &#8220;faithfully&#8221;&#8230; wth? Lol. We know that all machines are faithful to a human unless they&#8217;re not broken or gay! <img src='http://bashukhan.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  It definitely needed to be changed. Checking /etc/init.d/mdmonitor at least gave an idea that its not something changeable but it uses default template when MAILADDR is specified while it doesn&#8217;t when PROGRAM parameter is used in /etc/mdadm.conf by passing on RAID array as arguments to the script which is used, instead.</p>
<p>I did this then.</p>
<pre class="brush: bash;">

# mdadm --detail --scan &gt;&gt; /etc/mdadm.conf

# echo &quot;PROGRAM /etc/raidalerter&quot; &gt;&gt; /etc/mdadm.conf
# sed -e '1i\DEVICE partitions' -i  /etc/mdadm.conf
# cat /etc/raidalerter    (create this file with below script)

#!/bin/bash
echo -e &quot;Likely an unfavourable or a bad thing just happened to your RAID. Even if its recovering, it was a bad thing which caused this! \n\n\n&quot; $(cat -A /proc/mdstat | sed 's/\$/\\n/g') | mail -s &quot;$1 on $2 $3 at $HOSTNAME&quot; some-mail-address@example.com

# chmod +x /etc/raidalerter
# service mdmonitor restart
</pre>
<p>Provided that you&#8217;ve an MTA working fine, mails would be delivered upon any of RAID incidents to the maximum verbosity possible. I don&#8217;t think that any of the hardware raids does so?!<br />
I then tested it on a small array to make sure that alerts are deliverable.</p>
<pre class="brush: bash;">

# mdadm /dev/md0 -f /dev/sdb1 -r /dev/sdb1
mdadm: set /dev/sdb1 faulty in /dev/md0
mdadm: hot removed /dev/sdb1
# mdadm /dev/md0 -a /dev/sdb1
mdadm: re-added /dev/sdb1
</pre>
<p><a href="http://bashukhan.com/wp-content/uploads/2010/03/Mdmonitor-Report-all-mdadm-monitor-events-.png" rel="lightbox[157]"><img class="aligncenter size-full wp-image-165" title="Mdmonitor - Report all mdadm monitor events" src="http://bashukhan.com/wp-content/uploads/2010/03/Mdmonitor-Report-all-mdadm-monitor-events-.png" alt="" width="693" height="292" /></a></p>
<p><strong>Preview: </strong></p>
<blockquote><p>Subject: RebuildFinished on /dev/md0 at ToughGuy<br />
Likely an unfavorable or a bad thing just happened to your RAID. Even if its recovering, it was a bad thing which caused this!   Personalities :</p></blockquote>
<blockquote><p>[raid1]<br />
md1 : active<br />
raid1 sdb3[1] sda3[0]<br />
724555520 blocks [2/2] [UU]<br />
md0 : active<br />
raid1 sdb1[1] sda1[0]<br />
4008064 blocks [2/2] [UU]<br />
unused devices: &lt;none&gt;</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://bashukhan.com/more-raid-tidbits-monitoring-all-raid-events-and-changing-default-email-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.385 seconds -->
