<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Ruizs Place</title>
	
	<link>http://www.ruizs.org</link>
	<description>The ramblings of Steve-0</description>
	<lastBuildDate>Wed, 09 Mar 2011 19:55:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/RuizsPlace" /><feedburner:info uri="ruizsplace" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Using the Nexenta SA-API – nexenta-health plugin for Nagios</title>
		<link>http://feedproxy.google.com/~r/RuizsPlace/~3/pS1sdY-C-2w/163</link>
		<comments>http://www.ruizs.org/archives/163#comments</comments>
		<pubDate>Wed, 09 Mar 2011 19:55:02 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nexenta]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.ruizs.org/?p=163</guid>
		<description><![CDATA[This is the first script I created using the NexentaStor SA-API, the install of which is detailed in my previous post here. We use a combination of Nagios and Zabbix to monitor our infrastructure, and a very helpful component of that has been the check_netapp plugin available here, which reports any sort of failure on [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first script I created using the NexentaStor SA-API, the install of which is detailed in <a href="http://www.ruizs.org/archives/149">my previous post here</a>.  We use a combination of Nagios and Zabbix to monitor our infrastructure, and a very helpful component of that has been the check_netapp plugin available <a href="http://exchange.nagios.org/directory/Plugins/Hardware/Storage-Systems/SAN-and-NAS/NetApp/check_netapp-(combined-NetApp-Health-and-Quota-Check)/details">here</a>, which reports any sort of failure on the netapp, including array health, disk space/quota&#8217;s, etc.  Netapp provides most of this data with a custom SNMP MIB, but unfortunately NexentaStor doesn&#8217;t have one (yet at least).  I wanted the same functionality with our NexentaStor boxes, without having to remember to add a volume to our monitoring system every time I create a volume on the storage.</p>
<p>This script examines the state of each volume and the space used/free for each volume with a quota, and reports back any errors.  The layout is copied from the check_netapp plugin, and is fairly simple to follow along.  Of note, be sure to set the appropriate @INC path for your installation, and the location of your public key if using PKI with NexentaStor.  Unfortunately some of the API is not documented, and the functionality is incomplete &#8211; I had to play around with the $folder->execute() method to find the correct command to get the space used and quota allocated.  It seems like this should be a built in, documented method in the API, so here&#8217;s to hoping it makes it in.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7750346334646598";
/* 468x60, created 2/22/08 */
google_ad_slot = "6581891645";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">BEGIN</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">unshift</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@INC</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;/opt/build/NexentaStor-SDK-Linux/examples/perl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> NZA<span style="color: #339933;">::</span><span style="color: #006600;">Common</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> strict<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$ENV</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'NEXENTA_ID_RSA'</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">'/home/nagios/.ssh/id_rsa.pub'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#Configure space % threshold here for warnings</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$space_threshold</span> <span style="color: #339933;">=</span> <span style="color: #339933;">.</span>9<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$IPADDR</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">$IPADDR</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Usage: checkhealth.pl &lt;ip -ADDR&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">exit</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$volume</span> <span style="color: #339933;">=</span> nms_remote_obj<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$IPADDR</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'/Root/Volume'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$folder</span> <span style="color: #339933;">=</span> nms_remote_obj<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$IPADDR</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'/Root/Folder'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@errors</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$volnames</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">get_names</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$vol</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$volnames</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">#errors: No known data errors</span>
        <span style="color: #666666; font-style: italic;">#state: ONLINE</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$volstatus</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$volume</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">get_status</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$vol</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$volstatus</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'state'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">ne</span> <span style="color: #ff0000;">'ONLINE'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">push</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@errors</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Bad volume status for $vol: &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$volstatus</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'state'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span> <span style="color: #0000ff;">$</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$volstatus</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'errors'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/No known data errors/</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">push</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@errors</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Errors for $vol: &quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$volstatus</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#123;</span><span style="color: #ff0000;">'errors'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$folder_names</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$folder</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">get_names</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$fol</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$folder_names</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #0000ff;">$folder</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">reconstruct</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$fol</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$quota</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$used</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$lines</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$folder</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$fol</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;get -H used $fol&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$line</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$lines</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$used</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">$line</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$lines</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$folder</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$fol</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;get -H quota $fol&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$line</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$lines</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$quota</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">$line</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@data</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\s+/</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$used</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #0000ff;">$used</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@data</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\s+/</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$quota</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #0000ff;">$quota</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$quota</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/none/i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #b1b100;">next</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #0000ff;">$used</span> <span style="color: #339933;">=</span> convert_space_units<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$used</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #0000ff;">$quota</span> <span style="color: #339933;">=</span> convert_space_units<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$quota</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">#print &quot;$fol - used: $used, quota: $quota\n&quot;;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$quota</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$used</span><span style="color: #339933;">/</span><span style="color: #0000ff;">$quota</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #339933;">.</span>9 <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                <span style="color: #000066;">push</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@errors</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Volume almost full: $fol&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066;">scalar</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@errors</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Nexentastor healthcheck failed! &quot;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">for</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$error</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@errors</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;  $error.&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Nexentastor healthcheck OK<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> convert_space_units<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$)</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$string</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;"># K, M, G, T</span>
        <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">%factor</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>
                K <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1000</span><span style="color: #339933;">,</span>
                M <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1000000</span><span style="color: #339933;">,</span>
                G <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1000000000</span><span style="color: #339933;">,</span>
                T <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1000000000000</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$string</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/([.\d]+)(\w+)/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$factor</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000066;">return</span> <span style="color: #0000ff;">$1</span> <span style="color: #339933;">*</span> <span style="color: #0000ff;">$factor</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$2</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066;">return</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>ip<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<img src="http://feeds.feedburner.com/~r/RuizsPlace/~4/pS1sdY-C-2w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ruizs.org/archives/163/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ruizs.org/archives/163</feedburner:origLink></item>
		<item>
		<title>Setting up the Nexentastor SA-API on Centos/RHEL 5</title>
		<link>http://feedproxy.google.com/~r/RuizsPlace/~3/Rwch5QtK3lw/149</link>
		<comments>http://www.ruizs.org/archives/149#comments</comments>
		<pubDate>Tue, 01 Mar 2011 07:30:43 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.ruizs.org/?p=149</guid>
		<description><![CDATA[Nexentastor, a great storage appliance based on solaris/ZFS, has a pretty powerful API built in for remote management, but building the API on anything other than Ubuntu is an exercise in frustration. Included in this post are my notes on getting it installed and working, after a good bit of work by myself and their [...]]]></description>
			<content:encoded><![CDATA[<p>Nexentastor, a great storage appliance based on solaris/ZFS, has a pretty powerful API built in for remote management, but building the API on anything other than Ubuntu is an exercise in frustration.  Included in this post are my notes on getting it installed and working, after a good bit of work by myself and their support/development team.  I&#8217;m not going to clean it up too much, but if you follow the steps below on a Centos 5 machine you should be able to get it working.  The API tarball has a couple good readme&#8217;s that you will definitely want to read/reference, especially for setting up API authentication.<br />
<code><br />
yum install gcc make patch iso-codes-devel libnotify-devel NetworkManager-glib-devel libxml2 libxml2-devel dbus-libs dbus-glib-devel dbus-glib dbus-devel expat-devel perl-XML-Parser perl-XML-Twig</p>
<p>cd /root<br />
wget http://www.nexenta.com/corp/static/files-unstable/NexentaStor-SDK-Linux.tar.gz<br />
tar -xf NexentaStor-SDK-Linux.tar.gz<br />
cd NexentaStor-SDK-Linux/</p>
<p>./build_libs.sh        </p>
<p>cd ../examples/C/<br />
make<br />
./example</p>
<p>Enter appliance's IP address: 192.168.1.100</p>
<p>Connection is successful</p>
<p>perl -MCPAN -e shell<br />
cpan> o conf prerequisites_policy follow<br />
cpan> o conf commit<br />
cpan> install Carp::Assert<br />
cpan> install Net::DBus </p>
<p>#Back up /libXX directory, replace dbus libs<br />
mkdir /root/lib64-dbus.bak<br />
cd /lib64<br />
rsync -av *dbus* ~/lib64-dbus.bak/<br />
cd /root/NexentaStor-SDK-Linux/lib<br />
rsync -av *.so* /lib64/</p>
<p>cd /root/NexentaStor-SDK-Linux/examples/perl/<br />
./test.pl 192.168.1.100<br />
</code></p>
<p>
To setup authentication using ssh keys, do the following:<br />
On the client machine, generate a rsa key if one doesn&#8217;t already exist:<br />
<code>ssh-keygen -N "" -q -f ~/.ssh/id_rsa</code><br />
And on the nexentastor appliance, add that key.  The Key ID should be a name you recognize to keep track of the key, and the key value should start with ssh-rsa AAAAzxvdsa&#8230;.. and end with XXX==  &#8211; make sure you leave off the name at the end of the key, this is confusing:<br />
<code><br />
nmc@nexentastor:/$ setup appliance authentication keys add<br />
Key ID      : myclient<br />
Key Value   : ssh-rsa AAAAB3Nza<br />
......<br />
.....<br />
.... 1I89Q==</p>
<p>Authentication key 'myclient' added</p>
<p>
<script type="text/javascript"><!--
google_ad_client = "pub-7750346334646598";
/* 468x60, created 2/22/08 */
google_ad_slot = "6581891645";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p></code></p>
<img src="http://feeds.feedburner.com/~r/RuizsPlace/~4/Rwch5QtK3lw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ruizs.org/archives/149/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ruizs.org/archives/149</feedburner:origLink></item>
		<item>
		<title>PostgreSQL: Debugging “missing chunk number X for toast value Y” errors</title>
		<link>http://feedproxy.google.com/~r/RuizsPlace/~3/9vdaYI1e8zQ/138</link>
		<comments>http://www.ruizs.org/archives/138#comments</comments>
		<pubDate>Wed, 07 Apr 2010 17:17:07 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.ruizs.org/?p=138</guid>
		<description><![CDATA[If you found this through a search, you probably have seen something like this in your logs: ERROR: missing chunk number 0 for toast value 87246446 Searching for this issue on the net, I found that this is usually caused by a corrupt row in the database. The solution is to find the corrupt row, [...]]]></description>
			<content:encoded><![CDATA[<p>If you found this through a search, you probably have seen something like this in your logs:<br />
ERROR:  missing chunk number 0 for toast value 87246446</p>
<p>Searching for this issue on the net, I found that this is usually caused by a corrupt row in the database.  The solution is to find the corrupt row, and delete it (and/or update it with proper, non-corrupt values).</p>
<p>Unfortunately, there is no easy way to find the row that is giving you grief (or even the table if you don&#8217;t know what is causing this error).  You basically have to narrow down your search by looking at parts of the database.  If you have some sort of date or timestamp column in your table, you can narrow it down a lot more easily, if you know approximately when the error started:</p>
<p><code><br />
mydb=# select id from mytable where date_created > timestamp '2009-02-27 00:00:00'  and date_created < timestamp '2009-03-01 23:59:00';<br />
                  id<br />
--------------------------------------<br />
 3ab226cf-a972-463d-b5a1-148fe39672b5<br />
 10daca73-b2b3-470c-a258-5c92d21cfbb6<br />
(2 rows)<br />
</code></p>
<p>Luckily it's only two rows, and the first one is the culprit:<br />
</code><code><br />
mydb=# select * from mytable where id='3ab226cf-a972-463d-b5a1-148fe39672b5';<br />
ERROR:  missing chunk number 0 for toast value 87246446<br />
</code></p>
<p>Now, on to delete it:<br />
<code>mydb=# delete from mytable where id='3ab226cf-a972-463d-b5a1-148fe39672b5';</code></p>
<p>If you don&#8217;t have a date/timestamp column in your table, you could use LIMIT and OFFSET to narrow it down. I.e. a series of statements like (increasing the offset each time):<br />
<code><br />
select * from mytable order by id limit 1000 offset 5000;<br />
</code></p>
<p>
<!--adsense--></p>
<img src="http://feeds.feedburner.com/~r/RuizsPlace/~4/9vdaYI1e8zQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ruizs.org/archives/138/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ruizs.org/archives/138</feedburner:origLink></item>
		<item>
		<title>Terminal tips for OSX</title>
		<link>http://feedproxy.google.com/~r/RuizsPlace/~3/QpgnpzLxy54/127</link>
		<comments>http://www.ruizs.org/archives/127#comments</comments>
		<pubDate>Tue, 06 Apr 2010 21:36:13 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.ruizs.org/?p=127</guid>
		<description><![CDATA[I&#8217;ve been meaning to get around to it for the longest time, but I finally switched over my Mac&#8217;s to use bash as the default shell (previously I had it set to tcsh). I&#8217;ve become more accustomed to bash the past few years as its the default shell on pretty much any unix/linux nowadays, so [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to get around to it for the longest time, but I finally switched over my Mac&#8217;s to use bash as the default shell (previously I had it set to tcsh).  I&#8217;ve become more accustomed to bash the past few years as its the default shell on pretty much any unix/linux nowadays, so it was time to migrate.</p>
<p>The migration itself was pretty easy, but I wanted to gain some of bash&#8217;s features, specifically the emac-like keystrokes for moving forward/back a word in the command line, and also to the beginning and end of the line.  The keystrokes, among others, are:<br />
<code><br />
ctrl-a	 Move cursor to beginning of line<br />
ctrl-e	 Move cursor to end of line<br />
meta-b	 Move cursor back one word<br />
meta-f	 Move cursor forward one word<br />
ctrl-w	 Cut the last word<br />
ctrl-u	 Cut everything before the cursor<br />
ctrl-k	 Cut everything after the cursor<br />
ctrl-y	 Paste the last thing to be cut<br />
ctrl-_	 Undo<br />
</code></p>
<p>I&#8217;m a big fan of <a href="http://iterm.sourceforge.net/">iTerm</a> &#8211; I use it as my primary terminal and have been for the last few years, as it matured in terms of performance and has a lot of great features.  The most compelling feature it has over the built in OSX Terminal.app, for me, is that you can specify which characters to include when selecting words.  A common operation in a terminal is to select a path, i.e. /home/myuser/testfile.  In Terminal.app, if you double click on home, it will just select home &#8211; so you have to go back, double click on the first &#8220;/&#8221; character, and mouse right to get the whole word.  With iTerm, you can set a preference with characters to include when connecting, i.e. &#8220;/&#8221;, so when I double click on home in iTerm, it selects the full path.  Specifically, in iTerm -> Preferences -> Mouse, i have &#8220;Characters considered part of word:&#8221; set to /-_.  </p>
<p>One thing I couldn&#8217;t figure out was how to get the &#8220;meta&#8221; key in iterm set to the alt/option key on the mac keyboard.  Turns out it&#8217;s buried in a non-intuitive place, but it can be done.  In iTerm, go to Bookmarks->Manage Profiles, and under Keyboard Profiles select Global.  On the right side, you need to set Option Key as &#8220;+Esc&#8221; for this to work &#8211; yes, its strange that it has to be Esc instead of Meta, but hey, at least it all works.<br />
<!--adsense--></p>
<img src="http://feeds.feedburner.com/~r/RuizsPlace/~4/QpgnpzLxy54" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ruizs.org/archives/127/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ruizs.org/archives/127</feedburner:origLink></item>
		<item>
		<title>Setting up Oracle VM Server 2.2 with a NFS Repository</title>
		<link>http://feedproxy.google.com/~r/RuizsPlace/~3/rP4j1dgrMkE/129</link>
		<comments>http://www.ruizs.org/archives/129#comments</comments>
		<pubDate>Thu, 25 Mar 2010 21:50:08 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[oraclevm]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.ruizs.org/?p=129</guid>
		<description><![CDATA[Oracle&#8217;s documentation on this is a not very well organized, and simply doesn&#8217;t work out of the box, at least with the 2.2 install CD that&#8217;s available for download. The main problem is that the version of ovs-agent that ships with Oracle VM 2.2 is broken, so following the instructions you&#8217;ll end up frustrated and [...]]]></description>
			<content:encoded><![CDATA[<p>Oracle&#8217;s documentation on this is a not very well organized, and simply doesn&#8217;t work out of the box, at least with the 2.2 install CD that&#8217;s available for download.  The main problem is that the version of ovs-agent that ships with Oracle VM 2.2 is broken, so following the instructions you&#8217;ll end up frustrated and wondering what you did wrong, i.e.:<br />
<code>[root@oraclevm8 /]# /opt/ovs-agent-2.3/utils/repos.py --init<br />
Cluster not available.</code></p>
<p>To set up OracleVM 2.2 Server, with a NFS repository for VM&#8217;s:</p>
<ul>
<li>Download the ISO, and run through the install process</li>
<li>Once it is up and you are logged in:</li>
<li>Download and install the updated ovs-agent rpm from oracle here: <a href="http://oss.oracle.com/oraclevm/server/2.2/RPMS/ovs-agent-2.3-31.noarch.rpm">http://oss.oracle.com/oraclevm/server/2.2/RPMS/ovs-agent-2.3-31.noarch.rpm</a>
<ul>
<li>wget http://oss.oracle.com/oraclevm/server/2.2/RPMS/ovs-agent-2.3-31.noarch.rpm</li>
<li>rpm -Uvh ovs-agent-2.3-31.noarch.rpm</li>
</ul>
</li>
<li>Add your repository with the repos.py tool, make it the root repository, and initialize it:<br />
<code><br />
# /opt/ovs-agent-2.3/utils/repos.py --new mynfsserver.company.com:/volumes/datavol/ovs<br />
# /opt/ovs-agent-2.3/utils/repos.py -l<br />
# /opt/ovs-agent-2.3/utils/repos.py -r 7c885f7e-7dfe-4108-bae4-4dc329e2f017<br />
# /opt/ovs-agent-2.3/utils/repos.py -i<br />
</code></li>
</ul>
<p>At this point, you are ready to go, and can continue setting things up (including your Oracle VM Manager VM).</p>
<p>
<!--adsense--></p>
<img src="http://feeds.feedburner.com/~r/RuizsPlace/~4/rP4j1dgrMkE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ruizs.org/archives/129/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ruizs.org/archives/129</feedburner:origLink></item>
		<item>
		<title>Creating an NFS-root VM template for Xen / Oracle VM</title>
		<link>http://feedproxy.google.com/~r/RuizsPlace/~3/obIKZfAxPYQ/116</link>
		<comments>http://www.ruizs.org/archives/116#comments</comments>
		<pubDate>Mon, 15 Mar 2010 19:06:48 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[oraclevm]]></category>
		<category><![CDATA[p2v]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.ruizs.org/?p=116</guid>
		<description><![CDATA[Following up on my previous post about building a Xen / NFS-root kernel, this will take you through creating a VM template capable of using that kernel (or a P2V process for converting existing VM&#8217;s / linux servers to nfs-root). I think the intro from the last article still applies, so I&#8217;ll include it here: [...]]]></description>
			<content:encoded><![CDATA[<p>Following up on my previous post about building a Xen / NFS-root kernel, this will take you through creating a VM template capable of using that kernel (or a P2V process for converting existing VM&#8217;s / linux servers to nfs-root).  I think the intro from the last article still applies, so I&#8217;ll include it here:</p>
<blockquote><p>Over the past year or two, we have transitioned all our servers and hosting to Xen &#8211; specifically, we use the Oracle VM management tools on top of xen, and most of our VM&#8217;s are Centos 5 x86_64.  Since we use NFS NAS&#8217; as storage across our infrastructure, it would be very convenient if we could use a NFS volume as the root drive for VM&#8217;s.  With the NFS root, we gain things like easy use of filer snapshots, and on-the-fly volume resizing &#8211; if we&#8217;re ever running short on space in a given VM, its a single command (or a click on a web page) to expand the root drive.</p>
<p>The steps below are the result of a lot of work &#8211; the RHEL5 kernel has code in it for an NFS root, but I was never able to get it work correctly, at least under xen.  In the end, after lots of experimenting, I was able to build a new kernel from kernel source, that is compatible with Xen and a NFS-Root.  Repeat: you cannot build a custom RHEL5 kernel that is capable of booting from NFS under xen.</p>
<p>There are shortcomings/tradeoffs with this approach &#8211; you are not able to do any NFS exports from the nfs-root vm, and there is a bit more performance overhead with an NFS-root vm.  If you are using a VM to host a high-transaction DB, for instance, I wouldn&#8217;t recommend a NFS-root, but for most purposes, it works and performs just fine.</p></blockquote>
<li> Install linux / kickstart / etc to get a good, minimal install of linux, and configure it as you would any linux server.  I would suggest a minimal install for your requirements, turn off any unneeded services, lock down permissions, firewall, and any other deployment process you usually go through.  Since this is going to be a template, you want this to be ready for any task with minimal configuration changes.</li>
<li>On that configured linux system, mount a NFS share that will serve as your future NFS root (or storage for your VM template) to /mnt/tmp  </li>
<li>Shut down as many running services as possible, so there are no file conflicts/open databases/etc.</li>
<li>Copy over the kernel modules from your nfs-root kernel build:<code>rsync -av /path/to/kernel/modules/kernel-ver /mnt/tmp/lib/modules/</code></li>
<li><code>#copy all files over to nfs mount<br />
cd /<br />
cp -ax /{bin,dev,etc,lib,lib64,opt,root,sbin,usr,var,folders} /mnt/tmp<br />
mkdir /mnt/tmp/{home,proc,sys,tmp}<br />
chmod 777 /mnt/tmp/tmp</code></li>
<li>Edit /mnt/tmp/etc/fstab to look something like this, main change here is to /:<br />
<code><br />
/dev/nfs                /                       rootfs  defaults        0 0<br />
tmpfs                   /dev/shm                tmpfs   defaults        0 0<br />
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0<br />
sysfs                   /sys                    sysfs   defaults        0 0<br />
proc                    /proc                   proc    defaults        0 0<br />
rpc_pipefs              /var/lib/nfs/rpc_pipefs rpc_pipefs defaults     0 0<br />
</code></li>
<li>Edit /mnt/tmp/etc/sysconfig/network-scripts/ifcfg-eth0 as needed to setup the network</li>
<li>Create a vm.cfg file for the Xen vm.  If using this is an Oracle VM template, make sure to add a zero-byte disk image, and put this under the seed_pool directory.  Edit options as needed for your infrastructure.<br />
<code> dhcp = 'off'<br />
extra = 'nfsroot=10.0.0.1:/vol/nfsroot,noacl,nfsvers=3,tcp,rsize=32768,wsize=32768 selinux=0 acpi=off noapic'<br />
gateway = '10.0.0.254'<br />
hostname = 'nfsroot-vm.mycompany.com'<br />
ip = '10.0.0.10'<br />
kernel = '/OVS/P2V_STUFF/nfsboot-custom/vmlinuz-2.6.31.1nfsboot'<br />
memory = '512'<br />
name = 'nfsroot-vm'<br />
netmask = '255.255.255.0'<br />
on_crash = 'restart'<br />
on_reboot = 'restart'<br />
root = '/dev/nfs'<br />
uuid = '9af0a816-0123-4567-ad50-bc32be92bff7'<br />
vcpus = 2<br />
vfb = ['type=vnc,vncunused=1,vnclisten=0.0.0.0,vncpasswd=password']<br />
vif = ['bridge=vlan100,mac=00:16:3E:31:FF:37,type=netfront']<br />
vif_other_config = []<br />
</code></li>
<li>Start up the vm with Oracle VM manager, or start on the command line with xm create vm.cfg, and cross your fingers!</li>
<p>
<!--adsense--></p>
<img src="http://feeds.feedburner.com/~r/RuizsPlace/~4/obIKZfAxPYQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ruizs.org/archives/116/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ruizs.org/archives/116</feedburner:origLink></item>
		<item>
		<title>Build a custom Xen kernel capable of booting from a NFS Root Filesystem</title>
		<link>http://feedproxy.google.com/~r/RuizsPlace/~3/sujhtOiCXww/110</link>
		<comments>http://www.ruizs.org/archives/110#comments</comments>
		<pubDate>Mon, 15 Mar 2010 18:26:31 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[oraclevm]]></category>
		<category><![CDATA[p2v]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.ruizs.org/?p=110</guid>
		<description><![CDATA[Since we use NFS NAS' as storage across our infrastructure, it would be very convenient if we could use a NFS volume as the root drive for VM's.  With the NFS root, we gain things like easy use of filer snapshots, and on-the-fly volume resizing - if we're ever running short on space in a given VM, its a single command (or a click on a web page) to expand the root drive.]]></description>
			<content:encoded><![CDATA[<p>Over the past year or two, we have transitioned all our servers and hosting to Xen &#8211; specifically, we use the Oracle VM management tools on top of xen, and most of our VM&#8217;s are Centos 5 x86_64.  Since we use NFS NAS&#8217; as storage across our infrastructure, it would be very convenient if we could use a NFS volume as the root drive for VM&#8217;s.  With the NFS root, we gain things like easy use of filer snapshots, and on-the-fly volume resizing &#8211; if we&#8217;re ever running short on space in a given VM, its a single command (or a click on a web page) to expand the root drive.</p>
<p>The steps below are the result of a lot of work &#8211; the RHEL5 kernel has code in it for an NFS root, but I was never able to get it work correctly, at least under xen.  In the end, after lots of experimenting, I was able to build a new kernel from kernel source, that is compatible with Xen and a NFS-Root.  Repeat: you cannot build a custom RHEL5 kernel that is capable of booting from NFS under xen.</p>
<p>There are shortcomings/tradeoffs with this approach &#8211; you are not able to do any NFS exports from the nfs-root vm, and there is a bit more performance overhead with an NFS-root vm.  If you are using a VM to host a high-transaction DB, for instance, I wouldn&#8217;t recommend a NFS-root, but for most purposes, it works and performs just fine.</p>
<p>First, you need to build a kernel that supports both xen and an NFS-root &#8211; you&#8217;ll need a linux machine with a complete build environment, i.e. gcc, make, etc.  I have been through this process with 2.6.31, but I would guess that the latest stable kernel version available at http://kernel.org will work just fine.<br />
- Download the latest kernel source<br />
- unzip, cd into source directory<br />
- Copy in attached .config as starting point ( copy as …./linux-(version)/.config )<br />
- make menuconfig</p>
<p>Important config options are listed here:</p>
<p>http://www.virtuatopia.com/index.php/CentOS_5_-_Build_a_Custom_Xen_Kernel_with_NFS_Root_Filesystem_(CONFIG_ROOT_NFS)_Support</p>
<p>Most importantly, nfs client options and nfs_root need to be built into kernel (not as modules).  Also need to make sure to build Xen modules, and select most of the iptables filters (state is an important one). </p>
<p>- make<br />
- make modules_install</p>
<p>Once the make and install is complete, you will have a kernel capable of nfs-booting under xen.  To collect all the pieces needed:<br />
- copy over the file vmlinux in the base build directory (this one is ~85MB), this is the kernel  (can&#8217;t use bzImage with xen nfs boot).<br />
- Tar up /lib/modules/kernelVer to distribute to nfs client vm.</p>
<p> See the next article for creating a proper vm.cfg under xen / Oracle VM.</p>
<p>
<!--adsense--></p>
<img src="http://feeds.feedburner.com/~r/RuizsPlace/~4/sujhtOiCXww" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ruizs.org/archives/110/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ruizs.org/archives/110</feedburner:origLink></item>
		<item>
		<title>Mounting a xen disk image file on dom0</title>
		<link>http://feedproxy.google.com/~r/RuizsPlace/~3/sNyGF9rIYGo/104</link>
		<comments>http://www.ruizs.org/archives/104#comments</comments>
		<pubDate>Tue, 15 Sep 2009 22:14:33 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[oraclevm]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://www.ruizs.org/?p=104</guid>
		<description><![CDATA[If you need to get in and edit some files on your xen domU instance, i.e. it isn&#8217;t booting up properly, etc, here&#8217;s how to mount it on dom0. In this case, we want to mount the second partion on the virtual disk (our root partition): Print out the partition layout: fdisk -l /path/to/img/file.img Disk [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to get in and edit some files on your xen domU instance, i.e. it isn&#8217;t booting up properly, etc, here&#8217;s how to mount it on dom0.  In this case, we want to mount the second partion on the virtual disk (our root partition):</p>
<li>Print out the partition layout:<br />
<code>fdisk -l /path/to/img/file.img</p>
<p>Disk System.img: 0 MB, 0 bytes<br />
255 heads, 63 sectors/track, 0 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>     Device Boot      Start         End      Blocks   Id  System<br />
System.img1               1           4       32098+  83  Linux<br />
System.img2   *           <b>5</b>         619     4939987+  83  Linux<br />
System.img3             620         750     1052257+  82  Linux swap / Solaris</code>
</li>
<li>create directory to mount image under: <code>mkdir /mnt/tmp</code></li>
<li>mount the image using the offset from the fdisk output, the start block (in this case 5)<br />
<code>mount mount -o loop,offset=$((512*<b>5</b>) /path/to/img/file.img /mnt/tmp</code></li>
<li>Edit files as needed, and unmount when done.</li>
<p><!--adsense--></p>
<img src="http://feeds.feedburner.com/~r/RuizsPlace/~4/sNyGF9rIYGo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ruizs.org/archives/104/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ruizs.org/archives/104</feedburner:origLink></item>
		<item>
		<title>Synchronizing multiple iTunes libraries</title>
		<link>http://feedproxy.google.com/~r/RuizsPlace/~3/w3lF9OHn-aU/98</link>
		<comments>http://www.ruizs.org/archives/98#comments</comments>
		<pubDate>Fri, 11 Sep 2009 21:54:32 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.ruizs.org/?p=98</guid>
		<description><![CDATA[On and off over the past few years, I&#8217;ve looked for a good way to synchronize 2 or more iTunes libraries, and until recently, never found a good solution. The main problem is synchronizing library metadata &#8211; syncing files isn&#8217;t that difficult, but things like ratings, play counts, etc. is. My previous solution was simple [...]]]></description>
			<content:encoded><![CDATA[<p>On and off over the past few years, I&#8217;ve looked for a good way to synchronize 2 or more iTunes libraries, and until recently, never found a good solution.  The main problem is synchronizing library metadata &#8211; syncing files isn&#8217;t that difficult, but things like ratings, play counts, etc. is.  </p>
<p>My previous solution was simple &#8211; I considered one computer my &#8220;master&#8221;, and simply sync&#8217;ed all the files from it to my other computers.  Since I do most of my itunes listening (and rating) at work, I used my iMac as the master and my macbook and home desktop were the slaves.  This has its downfalls though, as anything I added or rated on my other systems never made its way back to the master system, and I had to make those changes manually.<br />
I decided to search again a few days ago, and found two applications that do exactly what I want:</p>
<p><a href="https://www.socketheadstudios.com/mytunesync/home.html">myTuneSync from SocketHead studios</a><br />
<a href="http://www.sonzea.com/syncopation/">Syncopation from Sonzea</a></p>
<p>I checked them both out, and they both work as advertised (both offer free time-limited trials).  You install the application, point it at the other itunes library to keep in sync with, and set them up for automatic updates.  Syncopation is the clear winner for me, with its cleaner interface, faster performance, and ability to synchronize file deletions as well.  Syncopation works only on macs, so if you have a mix of mac and Windows (or only Windows), myTuneSync is for you.  </p>
<p>Interestingly, I found these programs two days before the new iTunes 9 was released, and looking at the keynote, I wondered if I just wasted money on something that was now a standard feature of iTunes.  (Unfortunately) It turns out that the syncing included with iTunes is limited to purchases from the iTunes store, and doesn&#8217;t include anything added by you.  It also seems that the metadata does not get transferred over, only the purchased song files.<br />
<!--adsense--></p>
<img src="http://feeds.feedburner.com/~r/RuizsPlace/~4/w3lF9OHn-aU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ruizs.org/archives/98/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ruizs.org/archives/98</feedburner:origLink></item>
		<item>
		<title>Creating a true read-only user in PostgreSQL</title>
		<link>http://feedproxy.google.com/~r/RuizsPlace/~3/4QYfUE6uzwo/89</link>
		<comments>http://www.ruizs.org/archives/89#comments</comments>
		<pubDate>Tue, 25 Aug 2009 06:39:45 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://www.ruizs.org/?p=89</guid>
		<description><![CDATA[Since PostgreSQL is our database of choice, I started researching the process, thinking it would be a couple mysql-esqe GRANT statements and that would be it.  Turns out that it is a huge PITA in postgres - even my solution I'm documenting here has its shortcomings, but as far as I know is the best / only way to accomplish this task.]]></description>
			<content:encoded><![CDATA[<p>I develop a product at work that (among many other things) allows users to easily create and manage databases to interact with other packages on their appliance.  One feature that was requested and green-lighted is the ability to create a read-only user for existing databases- a user that can connect to a given database and access all tables and views in that DB, and nothing else.</p>
<p>Since PostgreSQL is our database of choice, I started researching the process, thinking it would be a couple mysql-esqe GRANT statements and that would be it.  Turns out that it is a huge PITA in postgres &#8211; even my solution I&#8217;m documenting here has its shortcomings, but as far as I know is the best / only way to accomplish this task.  I ran across quite a few sites that helped with pieces of this, but none that actually tied the process together for production usage.  I am by no means a Postgres expert, but do have a good bit of experience mucking around with back-end settings and figuring how to script common tasks.</p>
<p>There are two main things to watch out for when trying to create a read-only user in PostgreSQL, especially if you come from a DB like MySQL:</p>
<li>PostgreSQL only sets permissions on objects, not on databases, so you need to grant read access to all your tables/views/etc, and if you add a table down the line, you need to remember to manully grant read access to it after creating the table. </li>
<li>I&#8217;m guessing 95% of postgres users just use the default &#8220;public&#8221; schema, and as such, you need to revoke create privileges from the PUBLIC group.  Otherwise, your &#8220;read-only&#8221; user will still be allowed to create tables that it owns, even if you&#8217;ve only given it read only access to all other objects in your database.</li>
<p>For this example, we&#8217;ll use database name &#8220;mydb&#8221;, database user/owner &#8220;mydbuser&#8221;, and we&#8217;ll create a read-only user named &#8220;mydbuser_ro&#8221;.  This assumes that you did not define a schema for your database and are using the default &#8220;public&#8221; schema.</p>
<li>Revoke default permissions from public group:<br />
<code> REVOKE CREATE ON SCHEMA public FROM PUBLIC;<br />
REVOKE USAGE ON SCHEMA public FROM PUBLIC;</code></li>
<li>Add back permissions for your database owner:<br />
<code> GRANT CREATE ON SCHEMA public TO mydbuser;<br />
GRANT USAGE ON SCHEMA public TO mydbuser;</code></li>
<li>Create the new user via the command line, or pgadmin/etc:<br />
<code>psql -U postgres -t -c  "create role mydbuser_ro password 'abc123' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;</code></li>
<li>Grant usage permissions for your read-only user:<br />
<code> GRANT USAGE ON SCHEMA public TO mydbuser_ro;</code></li>
<li>Grant select permissions on all database tables from the command line:<br />
<code>psql -U postgres -qAt -c "select 'grant select on ' || tablename || ' to \"mydbuser_ro\";' from pg_tables where schemaname = 'public'" mydb | psql -U postgres mydb</code></li>
<li>Setup remote access for the read only user in pg_hba.conf as appropriate</li>
<p>Once complete, you can verify the settings with a quick sql query.  You should see something like this, with the user=UC (for Usage/Create), and user_ro=U (for Usage):<br />
<code> mydb=> select * from pg_namespace where nspname='public';<br />
 nspname | nspowner |                              nspacl<br />
---------+----------+------------------------------------------------------------------<br />
 public  |       10 |<br />
{postgres=UC/postgres,mydbuser=UC/postgres,mydbuser_ro=U/postgres}<br />
</code></p>
<p>
<!--adsense--></p>
<img src="http://feeds.feedburner.com/~r/RuizsPlace/~4/4QYfUE6uzwo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ruizs.org/archives/89/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ruizs.org/archives/89</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 1.321 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-01-30 10:17:20 -->

