<?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>Screenage &#187; Raid</title>
	<atom:link href="http://www.screenage.de/blog/category/raid/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.screenage.de/blog</link>
	<description></description>
	<lastBuildDate>Sun, 13 Nov 2011 10:33:53 +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>My (unofficial) package of the day: 3ware-cli and 3dms for monitoring 3ware raid controllers</title>
		<link>http://www.screenage.de/blog/2008/10/13/my-unofficial-package-of-the-day-3ware-cli-and-3dms-for-monitoring-3ware-raid-controllers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=my-unofficial-package-of-the-day-3ware-cli-and-3dms-for-monitoring-3ware-raid-controllers</link>
		<comments>http://www.screenage.de/blog/2008/10/13/my-unofficial-package-of-the-day-3ware-cli-and-3dms-for-monitoring-3ware-raid-controllers/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 12:14:20 +0000</pubDate>
		<dc:creator>ccm</dc:creator>
				<category><![CDATA[Backup]]></category>
		<category><![CDATA[CommandLine]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[PackeOfTheDay]]></category>
		<category><![CDATA[Raid]]></category>
		<category><![CDATA[Recovery]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.screenage.de/blog/2008/10/13/my-unofficial-package-of-the-day-3ware-cli-and-3dms-for-monitoring-3ware-raid-controllers/</guid>
		<description><![CDATA[Having a real hardware raid controller is a nice thing: Especially in a server setup it helps you keeping data safe on multiple disks. Though, a common mistake is, having a raid controller and not monitoring it. Why? Let&#8217;s say, &#8230; <a href="http://www.screenage.de/blog/2008/10/13/my-unofficial-package-of-the-day-3ware-cli-and-3dms-for-monitoring-3ware-raid-controllers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Having a real hardware raid controller is a nice thing: Especially in a server setup it helps you keeping data safe on multiple disks. Though, a common mistake is, having a raid controller and not monitoring it. Why? Let&#8217;s say, you have a simple type 1 array (one disk mirrored to another) and one of the disks fails. If your raid systems works it will continue to work. But if you did not setup a monitoring for it, you won&#8217;t notice it and the chance of a total data loss increases as you are running on one disk now.</p>
<p>So monitoring a raid is actually the step that makes your raid system as safe as you wanted it when setting it up. Some raids are quite easy to monitor, like a Linux software raid system. Some need special software. As I recently got a bunch of dedicated (Hetzner DS8000 and other) servers with 3ware raid controllers, I checked the common software repositories for monitoring software and was surprised not finding any suitable. So a web research showed me that there are Linux tools from 3ware. Of course they don&#8217;t provide .deb packages so you need to take of this yourself if you don&#8217;t want to install the software manually.</p>
<p>But there exists an unofficial Debian repository by <a href="http://blog.brachium-system.net/">Jonas Genannt</a> (thank you!), providing recent packages of 3ware utilities under <a href="http://jonas.genannt.name/">http://jonas.genannt.name/</a>. Check the repository, it offers 3ware-3dms and 3ware-cli. 3ware-3dms is a web application for managing your raid controller via browser, BUT: think twice, if you want this. The application opens a privileged port (888) as it is not able to bind on the local interface and has a crappy user identification system. As I am not a friend of opening ports and closing them afterwards via firewall I dropped the web solution.</p>
<p>The &#8220;3ware-cli&#8221; utility is just a command line interface to 3ware controllers. Just grab a .deb from the repository above and install it via &#8220;dpkg -i xxx.deb&#8221;. Aftwerwards you stark asking your controller questions about it&#8217;s status. The command is called &#8220;tw_cli&#8221;, so let&#8217;s give it a try with &#8220;info&#8221; as parameter:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># tw_cli info</span>
Ctl   Model        <span style="color: #7a0874; font-weight: bold;">&#40;</span>V<span style="color: #7a0874; font-weight: bold;">&#41;</span>Ports  Drives   Units   NotOpt  RRate   VRate  BBU
<span style="color: #660033;">------------------------------------------------------------------------</span>
c0    <span style="color: #000000;">8006</span>-2LP     <span style="color: #000000;">2</span>         <span style="color: #000000;">2</span>        <span style="color: #000000;">1</span>       <span style="color: #000000;">0</span>       <span style="color: #000000;">2</span>       -      -</pre></div></div>

<p>tw_cli told us, that there is one controller (meaning a real piece of raid hardware) called &#8220;c0&#8243; with two drives. No we want more detailed information about the given controller:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># tw_cli info c0</span>
&nbsp;
Unit  UnitType  Status         <span style="color: #000000; font-weight: bold;">%</span>RCmpl  <span style="color: #000000; font-weight: bold;">%</span>V<span style="color: #000000; font-weight: bold;">/</span>I<span style="color: #000000; font-weight: bold;">/</span>M  Stripe  Size<span style="color: #7a0874; font-weight: bold;">&#40;</span>GB<span style="color: #7a0874; font-weight: bold;">&#41;</span>  Cache  AVrfy
<span style="color: #660033;">------------------------------------------------------------------------------</span>
u0    RAID-<span style="color: #000000;">1</span>    OK             -       -       -       <span style="color: #000000;">232.885</span>   ON     -      
&nbsp;
Port   Status           Unit   Size        Blocks        Serial
<span style="color: #660033;">---------------------------------------------------------------</span>
p0     OK               u0     <span style="color: #000000;">232.88</span> GB   <span style="color: #000000;">488397168</span>     6RYBP4R9
p1     OK               u0     <span style="color: #000000;">232.88</span> GB   <span style="color: #000000;">488397168</span>     6RYBSHJC</pre></div></div>

<p>tw_cli reports that controller c0 has one unit &#8220;u0&#8243;. A unit is the device that your operating system is working with &#8211; the &#8220;virtual&#8221; raid drive provided by the raid controller. There are two ports/drives in this unit, called &#8220;p0&#8243; and &#8220;p1&#8243;. Both of them have &#8220;OK&#8221; as status message meaning that the drives are running fine.</p>
<p>You also ask a drive directly by asking tw_cli for the port on the controller:</p>
<pre># tw_cli info c0 p0

Port   Status           Unit   Size        Blocks        Serial
---------------------------------------------------------------
p0     OK               u0     232.88 GB   488397168     6RYBP4R9            

# tw_cli info c0 p1

Port   Status           Unit   Size        Blocks        Serial
---------------------------------------------------------------
p1     OK               u0     232.88 GB   488397168     6RYBSHJC</pre>
<p>So you might already got the clue: As tw_cli is just a command line tool your task for an automated setup is setting up a cronjob checking the status of the ports (not the unit! the ports &#8211; trust me) regularly and sending a mail or nagios alarm when necessary. I just started writing a little shell script which, right now, just returns an exit status &#8211; 0 for a working raid and 1 for a problem:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">UNIT</span>=u0
<span style="color: #007800;">CONTROLLER</span>=c0
<span style="color: #007800;">PORTS</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span> p0 p1 <span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
tw_check<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">regex</span>=<span style="color: #800000;">${1:-${UNIT}</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">field</span>=<span style="color: #000000;">3</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$#</span> <span style="color: #660033;">-gt</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">field</span>=<span style="color: #000000;">2</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">check</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>tw_cli info <span style="color: #800000;">${CONTROLLER}</span> <span style="color: #007800;">$1</span> \
    <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">&quot;/^<span style="color: #007800;">$regex</span>/ { print <span style="color: #000099; font-weight: bold;">\$</span>{field} }&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;XOK&quot;</span> = <span style="color: #ff0000;">&quot;X<span style="color: #007800;">${check}</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
  <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #007800;">$?</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
tw_check <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">for</span> PORT <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #800000;">${PORTS[@]}</span>; <span style="color: #000000; font-weight: bold;">do</span>
tw_check <span style="color: #800000;">${PORT}</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>As you see you can configure unit, controller and ports. I have not checked this against systems with multiple controllers and units as I don&#8217;t have such a setup. But if you need you could just put the configuration stuff in a sourced configuration file.</p>
<p>After writing this little summary I checked all servers I am responsible of and noticed that nearly every server with hardware raid has a 3ware controller and can be checked with tw_cli. Fine&#8230;</p>
<p>Let me know how you manage your 3ware raid monitoring under GNU/Linux and Debian/Ubuntu based systems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.screenage.de/blog/2008/10/13/my-unofficial-package-of-the-day-3ware-cli-and-3dms-for-monitoring-3ware-raid-controllers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

