<?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:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tech@Sakana - A sysadmin's blog</title>
	
	<link>http://www.sakana.fr/blog</link>
	<description>Tech tips for the sysadmin (Solaris, Linux, Unix, Windows), networking stuff, coding / scripting (shell, perl), and so much more !</description>
	<lastBuildDate>Sat, 06 Mar 2010 10:31:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/sakana/articles" /><feedburner:info uri="sakana/articles" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by/2.5/</creativeCommons:license><xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /><image><link>http://www.sakana.fr/blog/</link><url>http://www.feedburner.com/fb/images/pub/fb_pwrd.gif</url><title>Tech@Sakana</title></image><feedburner:emailServiceId>sakana/articles</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Perl : Counting occurences of IP addresses in Apache logs</title>
		<link>http://feedproxy.google.com/~r/sakana/articles/~3/8LNpH8WkMZw/</link>
		<comments>http://www.sakana.fr/blog/2010/03/02/perl-counting-occurences-of-ip-addresses-in-apache-logs/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 11:41:57 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[apache logs]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=408</guid>
		<description><![CDATA[This Perl one-liner is intended to print the 10 most frequent client IP addresses in an Apache log file. It can easily be recycled to count anything, though.


?View Code TXT1
2
3
4
5
6
7
8
9
10
11
12
kattoo@roadrunner /files/toSave/home/kattoo/Downloads $ perl -ane '$c{$F[0]}++; END {print map {$_ . &#34;\t-&#62;\t&#34; . $c{$_} . &#34;\n&#34;} (sort {$c{$b} &#60;=&#62; $c{$a}} keys %c)[0..9]}' sakana.fr-28-02-2010.log 
XX.XX.XX.XXX	-&#62;	163
XX.XXX.XXX.XXX	-&#62;	150
XXX.XXX.XX.XX	-&#62;	136
XXX.XX.XXX.XXX	-&#62;	134
XX.XXX.XXX.XX	-&#62;	116
XX.XXX.XXX.XXX	-&#62;	110
XX.XX.XXX.XX	-&#62;	104
XX.XXX.XXX.XXX	-&#62;	90
XX.XXX.X.XXX	-&#62;	75
XXX.XXX.XX.XXX	-&#62;	72
kattoo@roadrunner /files/toSave/home/kattoo/Downloads $

Short [...]<p><a href="http://www.sakana.fr/blog/2010/03/02/perl-counting-occurences-of-ip-addresses-in-apache-logs/">Perl : Counting occurences of IP addresses in Apache logs</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This Perl one-liner is intended to print the 10 most frequent client IP addresses in an Apache log file. It can easily be recycled to count anything, though.<br />
<span id="more-408"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p408code2'); return false;">View Code</a> TXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4082"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p408code2"><pre class="txt" style="font-family:monospace;">kattoo@roadrunner /files/toSave/home/kattoo/Downloads $ perl -ane '$c{$F[0]}++; END {print map {$_ . &quot;\t-&gt;\t&quot; . $c{$_} . &quot;\n&quot;} (sort {$c{$b} &lt;=&gt; $c{$a}} keys %c)[0..9]}' sakana.fr-28-02-2010.log 
XX.XX.XX.XXX	-&gt;	163
XX.XXX.XXX.XXX	-&gt;	150
XXX.XXX.XX.XX	-&gt;	136
XXX.XX.XXX.XXX	-&gt;	134
XX.XXX.XXX.XX	-&gt;	116
XX.XXX.XXX.XXX	-&gt;	110
XX.XX.XXX.XX	-&gt;	104
XX.XXX.XXX.XXX	-&gt;	90
XX.XXX.X.XXX	-&gt;	75
XXX.XXX.XX.XXX	-&gt;	72
kattoo@roadrunner /files/toSave/home/kattoo/Downloads $</pre></td></tr></table></div>

<p>Short explanation of the command line switches :</p>
<ul>
<li><strong>-a</strong> : turns on autosplit, the different fields will then be accessible in the <em>@F</em> variable</li>
<li><strong>-e</strong> : specifies the code to execute</li>
<li><strong>-n</strong>  : wraps that code into a loop for each text line of the file to process from the standard input or the files specified on the command line</li>
</ul>
<p>This is equivalent to <a href="http://blog.anotherhomepage.org/post/2010/03/01/Nombre-d-occurences-d-un-champ-dans-un-fichier" target="_blank">Nils&#8217; approach in awk</a> but you know, I&#8217;ve always been partial to Perl <img src='http://www.sakana.fr/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Feel free to suggest any improvement&#8230; I know there must be many !</p>
<p><strong>Suggested reading</strong></p>
<ul>
<li><a href="http://www.amazon.com/gp/product/0596000278?ie=UTF8&#038;tag=tecsak-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=0596000278" target="_blank">Programming Perl (3rd Edition)</a><img src="http://www.assoc-amazon.com/e/ir?t=tecsak-20&#038;l=as2&#038;o=1&#038;a=0596000278" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> (on Amazon) : The reference guide for Perl programming, written by Perl Gods (Larry Wall, Tom Christiansen, John Orwant).</li>
<li><a href="http://articles.techrepublic.com.com/5100-10878_11-1044668.html" target="_blank">Use command-line Perl to make UNIX administration easier</a> (on techrepublic) : Short intro about perl 1-liners</li>
</ul>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4571688872511149";
/* 728x90, created 10/17/09 */
google_ad_slot = "0784069657";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><a href="http://www.sakana.fr/blog/2010/03/02/perl-counting-occurences-of-ip-addresses-in-apache-logs/">Perl : Counting occurences of IP addresses in Apache logs</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sakana/articles?a=8LNpH8WkMZw:viqmh7Bxjh0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=8LNpH8WkMZw:viqmh7Bxjh0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=8LNpH8WkMZw:viqmh7Bxjh0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=8LNpH8WkMZw:viqmh7Bxjh0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=8LNpH8WkMZw:viqmh7Bxjh0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=8LNpH8WkMZw:viqmh7Bxjh0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=8LNpH8WkMZw:viqmh7Bxjh0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=8LNpH8WkMZw:viqmh7Bxjh0:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sakana/articles/~4/8LNpH8WkMZw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/03/02/perl-counting-occurences-of-ip-addresses-in-apache-logs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.sakana.fr/blog/2010/03/02/perl-counting-occurences-of-ip-addresses-in-apache-logs/</feedburner:origLink></item>
		<item>
		<title>AIX : Use sar to check cpu usage</title>
		<link>http://feedproxy.google.com/~r/sakana/articles/~3/mQ9tFhVmIH8/</link>
		<comments>http://www.sakana.fr/blog/2010/01/30/aix-use-sar-to-check-cpu-usage/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 20:45:42 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[aix]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[sar]]></category>
		<category><![CDATA[top]]></category>
		<category><![CDATA[topas]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=405</guid>
		<description><![CDATA[If you&#8217;re looking for CPU usage statistics and system performance on IBM AIX, sar might just be the tool your looking for. It&#8217;ll display information for 5 minutes intervals from midnight to current time. The output looks like this :


?View Code TEXT1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
login@servername:/&#62; sar
&#160;
AIX servername 3 5 00CFE81B4C00    01/25/10
&#160;
Configuration du système : lcpu=20 [...]<p><a href="http://www.sakana.fr/blog/2010/01/30/aix-use-sar-to-check-cpu-usage/">AIX : Use sar to check cpu usage</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re looking for CPU usage statistics and system performance on IBM AIX, <tt>sar</tt> might just be the tool your looking for. It&#8217;ll display information for 5 minutes intervals from midnight to current time. The output looks like this :<br />
<span id="more-405"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p405code4'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4054"><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
</pre></td><td class="code" id="p405code4"><pre class="text" style="font-family:monospace;">login@servername:/&gt; sar
&nbsp;
AIX servername 3 5 00CFE81B4C00    01/25/10
&nbsp;
Configuration du système : lcpu=20 ent=8,00
&nbsp;
00:00:01    %usr    %sys    %wio   %idle   physc   %entc
00:05:01       2       2       0      96    0,40     5,0
00:10:01       3       2       0      94    0,48     6,0
00:15:00       1       1       0      98    0,21     2,6
00:20:01       1       1       0      98    0,23     2,9
00:25:01       2       1       1      97    0,25     3,2
00:30:01       1       1       0      98    0,23     2,9
00:35:00       2       1       1      96    0,31     3,8
00:40:01       1       1       0      98    0,21     2,6
00:45:01       1       1       0      98    0,22     2,7
00:50:00       1       1       0      98    0,23     2,8
00:55:00       1       1       0      98    0,21     2,6
01:00:00       1       1       0      98    0,21     2,6
01:05:00       2       1       0      96    0,35     4,4</pre></td></tr></table></div>

<p>The columns are the usual for this type of tools :</p>
<ol>
<li>%usr : the percent of time spent in user land. The higher the more CPU intensive processes you are running.</li>
<li>%sys : the percent of time spent in kernel. This is mostly due to I/O intensive processes and/or processes performing a lot of syscalls.</li>
<li>%wio : I&#8217;ve got no idea about that one &#8230; If you&#8217;ve got an explanation for this, feel free to hit the comments. I suspect this is the time spent waiting for I/Os to complete, or waiting after a busy device. This could be a sign of I/O (disk, network) bottlenecks</li>
<li>%idle : the percent of time spent doing &#8230; nothing. The higher this number, the more underused your machine</li>
<li>physc : no idea neither !</li>
<li>%entc : the number of CPU used to absorb the load</li>
</ol>
<p>If you&#8217;re looking for a <tt>top</tt> like tool, <tt>topas</tt> is the standard AIX equivalent.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-4571688872511149";
/* 728x90, created 10/17/09 */
google_ad_slot = "0784069657";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><a href="http://www.sakana.fr/blog/2010/01/30/aix-use-sar-to-check-cpu-usage/">AIX : Use sar to check cpu usage</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sakana/articles?a=mQ9tFhVmIH8:qy9RoM0d5M0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=mQ9tFhVmIH8:qy9RoM0d5M0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=mQ9tFhVmIH8:qy9RoM0d5M0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=mQ9tFhVmIH8:qy9RoM0d5M0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=mQ9tFhVmIH8:qy9RoM0d5M0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=mQ9tFhVmIH8:qy9RoM0d5M0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=mQ9tFhVmIH8:qy9RoM0d5M0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=mQ9tFhVmIH8:qy9RoM0d5M0:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sakana/articles/~4/mQ9tFhVmIH8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/01/30/aix-use-sar-to-check-cpu-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sakana.fr/blog/2010/01/30/aix-use-sar-to-check-cpu-usage/</feedburner:origLink></item>
		<item>
		<title>Perl+Twitter : Getting @mentions from command line</title>
		<link>http://feedproxy.google.com/~r/sakana/articles/~3/SNaUAJ1ry30/</link>
		<comments>http://www.sakana.fr/blog/2010/01/24/perltwitter-getting-mentions-from-command-line/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 09:56:09 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[@mentions]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=397</guid>
		<description><![CDATA[This code snippet demonstrates how easy it is to collect your twitter @mentions in Perl, coupled with curl for simplicity.


In this script, we use the JSON Twitter API. Perl has a JSON module to make parsing or JSON streams a bliss. I also used formats for easy

?Download twitter-mentions.pl1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /usr/bin/perl
&#160;
use strict;
use warnings;
&#160;
use JSON;
use Encode;
&#160;
my $json = [...]<p><a href="http://www.sakana.fr/blog/2010/01/24/perltwitter-getting-mentions-from-command-line/">Perl+Twitter : Getting @mentions from command line</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This code snippet demonstrates how easy it is to collect your twitter @mentions in Perl, coupled with curl for simplicity.<br />
<span id="more-397"></span><br />
<!--adsense--></p>
<p>In this script, we use the JSON Twitter API. Perl has a JSON module to make parsing or JSON streams a bliss. I also used formats for easy</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.sakana.fr/blog/wp-content/plugins/wp-codebox/wp-codebox.php?p=397&amp;download=twitter-mentions.pl">twitter-mentions.pl</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3977"><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
</pre></td><td class="code" id="p397code7"><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;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> JSON<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Encode<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$json</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSON<span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$json_stream</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/join.html"><span style="color: #000066;">join</span></a> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">,</span> <a href="http://perldoc.perl.org/functions/map.html"><span style="color: #000066;">map</span></a> <span style="color: #009900;">&#123;</span>decode<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$_</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">&lt;&gt;;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$mentions</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$json</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">decode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$json_stream</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$mention</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@$mentions</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$screen_name</span> <span style="color: #339933;">=</span> encode<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$mention</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>user<span style="color: #009900;">&#125;</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>screen_name<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$text</span> <span style="color: #339933;">=</span> encode<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$mention</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>text<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<a href="http://perldoc.perl.org/functions/format.html"><span style="color: #000066;">format</span></a> <span style="color: #339933;">=</span>
<span style="color: #339933;">@&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>    <span style="color: #339933;">^&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<span style="color: #0000ff;">$screen_name</span><span style="color: #339933;">,</span>      <span style="color: #0000ff;">$text</span>
                   <span style="color: #339933;">^&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span> <span style="color: #339933;">~~</span>
				   <span style="color: #0000ff;">$text</span>
<span style="color: #339933;">.</span>
	<a href="http://perldoc.perl.org/functions/write.html"><span style="color: #000066;">write</span></a><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>You&#8217;ll have to run it as demonstrated below :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p397code8'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3978"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p397code8"><pre class="text" style="font-family:monospace;">kattoo@roadrunner /files/toSave/home/kattoo $ curl -sS -u YourLoginHere:YourPasswordHere http://twitter.com/statuses/mentions.json | twitter-mentions.pl 
divarvel           @killermouse0 mon /boot est pas dans une
                   partition à part, et pour une install en
                   chroot je ne sais pas quoi faire (un autre
                   /boot ?)
fenice             @killermouse0 merci, c'est sympa. Tu tourne
                   sous Gentoo ?
[...]
kattoo@roadrunner /files/toSave/home/kattoo $</pre></td></tr></table></div>

<p>That&#8217;s all ! Of course this piece of code could use a lot of improvements, but this is intended as a kickstart sample&#8230; The curl part could have been directly integrated into the Perl code, but I like to keep it simple.</p>
<p>Now off to integrate this in <a href="http://www.sakana.fr/blog/2009/10/11/conky-integrating-rtorrent-downloads-monitoring/" target="_blank">my Conky layout</a> <img src='http://www.sakana.fr/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><strong>And by the way, you&#8217;ll find my twitter account on the right, in the &#8220;Follow me&#8221; section. Feel free to add me for updates !</strong></p>
<h4>Worth reading</h4>
<ul>
<li><a href="http://www.sakana.fr/blog/2007/03/17/twitter-send-free-sms-messages/">Twitter : Send free SMS messages to your friends</a> : now you can do this from the command line</li>
<li><a href="http://www.sakana.fr/blog/2007/03/18/scripting-twitter-with-curl/">Scripting Twitter with cURL</a></li>
<li><a href="http://www.sakana.fr/blog/2007/03/18/scripting-twitter-with-perl-lwp/">Scripting Twitter with Perl + LWP</a> : a script in Perl doing the same thing (much simpler).</li>
<li><a href="http://www.sakana.fr/blog/2010/01/24/perltwitter-getting-mentions-from-command-line/">Perl+Twitter : Getting @mentions from command line</a></li>
</ul>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2010/01/24/perltwitter-getting-mentions-from-command-line/">Perl+Twitter : Getting @mentions from command line</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sakana/articles?a=SNaUAJ1ry30:C6WlpeX3TWo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=SNaUAJ1ry30:C6WlpeX3TWo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=SNaUAJ1ry30:C6WlpeX3TWo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=SNaUAJ1ry30:C6WlpeX3TWo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=SNaUAJ1ry30:C6WlpeX3TWo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=SNaUAJ1ry30:C6WlpeX3TWo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=SNaUAJ1ry30:C6WlpeX3TWo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=SNaUAJ1ry30:C6WlpeX3TWo:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sakana/articles/~4/SNaUAJ1ry30" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/01/24/perltwitter-getting-mentions-from-command-line/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.sakana.fr/blog/2010/01/24/perltwitter-getting-mentions-from-command-line/</feedburner:origLink></item>
		<item>
		<title>Linux / Unix : Disk usage and identifying biggest files</title>
		<link>http://feedproxy.google.com/~r/sakana/articles/~3/VJeiMf6zYCc/</link>
		<comments>http://www.sakana.fr/blog/2010/01/17/linux-unix-disk-usage-and-identifying-biggest-files/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 17:41:16 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[df]]></category>
		<category><![CDATA[du]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[fs full]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=381</guid>
		<description><![CDATA[When working as a systems administrator, you&#8217;ll always end up having to solve a file system full error in a hurry. Here are a few commands and hints to help you get out of it quickly on a UNIX like system.

df command
The df (disk free) command will report how much of each file system is [...]<p><a href="http://www.sakana.fr/blog/2010/01/17/linux-unix-disk-usage-and-identifying-biggest-files/">Linux / Unix : Disk usage and identifying biggest files</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>When working as a systems administrator, you&#8217;ll always end up having to solve a <i>file system full</i> error in a hurry. Here are a few commands and hints to help you get out of it quickly on a UNIX like system.<br />
<span id="more-381"></span></p>
<h4>df command</h4>
<p>The <tt>df</tt> (disk free) command will report how much of each file system is used. You can combine this with with the <tt>sort</tt> command to get the fullest file systems at the end :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p381code14'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38114"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p381code14"><pre class="text" style="font-family:monospace;">kattoo@roadrunner ~/Downloads $ df | sort -n -k 5,5
Filesystem           1K-blocks      Used Available Use% Mounted on
shm                    2029696         0   2029696   0% /dev/shm
/dev/sda6              1968588      3232   1865356   1% /tmp
udev                     10240       228     10012   3% /dev
/dev/sda12           367628876  28899532 338729344   8% /files
/dev/sda7              1989820    246300   1743520  13% /var
/dev/sda9              1999932    260996   1738936  14% /usr/portage
/dev/sda5               244176     52264    191912  22% /
/dev/sda8              9990188   3161340   6828848  32% /usr
/dev/sda11            99947736  32910756  67036980  33% /files/vservers
/dev/sda10             3989912   1699372   2290540  43% /usr/portage/distfiles</pre></td></tr></table></div>

<p>The <tt>sort</tt> arguments are :</p>
<ul>
<li>-n : order numerically</li>
<li>-k 5,5 : order by the 5th field</li>
</ul>
<h4>du command</h4>
<p>When you found out that a specific file system is full, you need to quickly analyze which folders are the biggest.<br />
You can use the <tt>du</tt> (disk usage) command. This command will report the space used by a directory and sub-directories. I usually run something like :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p381code15'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38115"><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
</pre></td><td class="code" id="p381code15"><pre class="text" style="font-family:monospace;">kattoo@roadrunner /usr/portage $ du -sk * | sort -n | tail -20
5711	x11-misc
6056	app-misc
6224	dev-ruby
6320	app-dicts
7219	profiles
7428	net-analyzer
7686	app-text
8112	media-plugins
8777	kde-base
8883	media-libs
8943	sys-apps
9764	dev-util
9986	media-sound
10955	dev-libs
11295	dev-python
11479	dev-java
11645	net-misc
17553	dev-perl
112556	metadata
1705976	distfiles</pre></td></tr></table></div>

<p>This will show the 20 largest files or directories. <tt>du</tt> will display the size of each directories and sub-directories by default. The -s switch will make <tt>du</tt> display only the grand total for each arguments.</p>
<p>According to the results, you might want to go on repeating this command in the sub-directories, until you&#8217;ve narrowed down enough to find the culprit.</p>
<h4>find command</h4>
<p>The file system full error is more often than not due to a faulty script or program which logs are running wild due to a bug. This will usually lead to a huge file somewhere in a directory, hogging all the available space on the file system.</p>
<p>An easy way to spot it is to use the <tt>find</tt> command. The following snippet for example will search for files bigger than 10MB in the current directory and sub-directories and print the 10 largest ones :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p381code16'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38116"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p381code16"><pre class="text" style="font-family:monospace;">kattoo@roadrunner /usr/portage $ find . -type f -size +10000000c -exec ls -l \{} \; | sort -n -k 5,5 | tail -10
-rw-rw-r-- 1 portage portage 23416703 Oct  1 10:07 ./distfiles/samba-3.0.37.tar.gz
-rw-rw-r-- 1 portage portage 28749072 Jan 18  2008 ./distfiles/extremetuxracer-0.4.tar.gz
-rw-rw-r-- 1 portage portage 46905557 Oct 16 17:20 ./distfiles/firefox-3.5.4.source.tar.bz2
-rw-rw-r-- 1 portage portage 46914620 Dec  2 05:32 ./distfiles/firefox-3.5.6.source.tar.bz2
-rw-rw-r-- 1 portage portage 50380241 Oct  2 11:47 ./distfiles/VirtualBox-3.0.8-53138-Linux_amd64.run
-rw-rw-r-- 1 portage portage 50595281 Nov 17 10:44 ./distfiles/VirtualBox-3.0.12-54655-Linux_amd64.run
-rw-rw-r-- 1 portage portage 59368714 Aug  8 02:10 ./distfiles/gcc-4.3.4.tar.bz2
-rw-rw-r-- 1 portage portage 61494822 Sep 10 00:34 ./distfiles/linux-2.6.31.tar.bz2
-rw-rw-r-- 1 portage portage 125384668 Oct  1 13:58 ./distfiles/qt-x11-opensource-src-4.5.3.tar.gz
-rw-rw-r-- 1 portage portage 314942420 Jun 18  2008 ./distfiles/sauerbraten_2008_06_17_ctf_edition_linux.tar.bz2
kattoo@roadrunner /usr/portage $</pre></td></tr></table></div>

<p>I also like to filter out already compressed files, in order to collect the biggest files which I could compress to save some space with something like :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p381code17'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38117"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p381code17"><pre class="text" style="font-family:monospace;">find . -type f -size +10000000c \! -name &quot;*.Z&quot; \! -name &quot;*.gz&quot; \! -name &quot;*.bz2&quot; -exec ls -l \{} \;</pre></td></tr></table></div>

<p><strong>Tip</strong> : Set this as an alias in your profile by adding this to your <tt>.bashrc</tt> (if you&#8217;re using bash &#8230; otherwise check your shell documentation) :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p381code18'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38118"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p381code18"><pre class="text" style="font-family:monospace;">alias bigfiles='find . -type f -size +10000000c \! -name &quot;*.Z&quot; \! -name &quot;*.gz&quot; \! -name &quot;*.bz2&quot; -exec ls -l \{} \; | sort -n -k 5,5 | tail -10'</pre></td></tr></table></div>

<p>This will give you the 10 largest not-yet-compressed files in a single handy command.</p>
<p><!--adsense--></p>
<h4>Caveat</h4>
<p><b></i>&#8220;Too many arguments&#8221;</i> error</b> :</p>
<p>If you are working with directory holding an important number of files, you might get a &#8220;Too many arguments&#8221; error when using a star expansion (like in the <tt>du -sk *</tt> example above).</p>
<p>This is actually not the <tt>du</tt> command complaining, but the shell which gets too much data when expanding the star. When this happens, you are usually better off using the <tt>find</tt> command as explained above. </p>
<p>Another possibility is to pipe the output of <tt>find</tt> to the <tt>xargs</tt> command. Basically <tt>xargs</tt> will take everything on the standard input and give it as arguments to the specified command.</p>
<p><b>Deleting / compressing a file which is still open</b><br />
Also beware of this : if you delete or compress a file which is still being open by a process, then the space this file use won&#8217;t get freed before the process actually closes the file (I&#8217;ll explain why in a different post, this is an interesting topic on its own <img src='http://www.sakana.fr/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ).</p>
<p>If you deleted or compressed the file (so basically the big file disappeared or was replaced by a compressed version), but the space doesn&#8217;t get freed (which you can check with <tt>df</tt>), then you can bet that a process is still holding the file open. You can spot this with tools like lsof or fuser. Those tools vary greatly according to which variant of Unix you&#8217;re running. On <strong>IBM&#8217;s AIX</strong>, fuser had a handy -d option to spot files on the file system which have a link count of 0 and it will report the PID of the attached processes.</p>
<p>Better check those tools&#8217; man pages before you run into this situation !</p>
<h4>A word to the wise</h4>
<p>Those recipes will help you to find a way out when you are already facing a file system full problem. The best is of course to avoid them in the first place &#8230; The following ideas are a good start :</p>
<ul>
<li><strong>Set alerts</strong> to have an early warning and let you deal with it before applications start crashing. Tools like <a href="http://www.nagios.org/" target="_blank">Nagios</a> would be your friends here, but home made scripts running from cron and sending emails might be enough.</li>
<li><strong>Check the trends</strong> : You can use tools like <a href="http://www.cacti.net/">cacti</a> to graph the space occupation of your file systems over the time. This will let you anticipate when you&#8217;ll need to add more disks or if your log rotation and/or file archiving policies are adequate.</li>
</ul>
<p><strong>More ideas ? Tips to share ? Hit the comments !</strong></p>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2010/01/17/linux-unix-disk-usage-and-identifying-biggest-files/">Linux / Unix : Disk usage and identifying biggest files</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sakana/articles?a=VJeiMf6zYCc:Z_38Fxm0od8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=VJeiMf6zYCc:Z_38Fxm0od8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=VJeiMf6zYCc:Z_38Fxm0od8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=VJeiMf6zYCc:Z_38Fxm0od8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=VJeiMf6zYCc:Z_38Fxm0od8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=VJeiMf6zYCc:Z_38Fxm0od8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=VJeiMf6zYCc:Z_38Fxm0od8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=VJeiMf6zYCc:Z_38Fxm0od8:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sakana/articles/~4/VJeiMf6zYCc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/01/17/linux-unix-disk-usage-and-identifying-biggest-files/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.sakana.fr/blog/2010/01/17/linux-unix-disk-usage-and-identifying-biggest-files/</feedburner:origLink></item>
		<item>
		<title>Monitoring batches in IT environment : efficiently using emails</title>
		<link>http://feedproxy.google.com/~r/sakana/articles/~3/XpSAe0JGl38/</link>
		<comments>http://www.sakana.fr/blog/2010/01/09/batches-monitoring-emails/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 20:54:02 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[emails]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=378</guid>
		<description><![CDATA[Sometimes automatically running scripts in production environments are simply monitored by emails. Those scripts may run on schedule or be triggered by events and they send an email (for example to the technical support level 1) upon completion of the job. The content of the email will then give information about the outcome of the [...]<p><a href="http://www.sakana.fr/blog/2010/01/09/batches-monitoring-emails/">Monitoring batches in IT environment : efficiently using emails</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Sometimes automatically running scripts in production environments are simply monitored by emails. Those scripts may run on schedule or be triggered by events and they send an email (for example to the technical support level 1) upon completion of the job. The content of the email will then give information about the outcome of the execution of the script.</p>
<p>This posts lists a few ideas that you might find useful to implement when in such an environment.</p>
<p><span id="more-378"></span></p>
<ol>
<li>Try to avoid emails when the job processed correctly : It is not useful to swamp the tech support with emails requiring no action. Of course you&#8217;ll have to be able to differentiate between a script which ran fine and sent no email, and one which didn&#8217;t send an email because it didn&#8217;t run at all <img src='http://www.sakana.fr/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>Keep the subject of the email specific : It could be for example the name of the script and the status (OK or KO). This helps for faster (human or rule based) processing of the emails</li>
<li>Clearly state the priority of the email in the subject. This helps to decide efficiently in which order to deal with problems when many are occurring simultaneously.</li>
<li>Clearly mention which script produced the email : It IS annoying to have to find out first WHAT broke and ONLY THEN start analyzing and recovering &#8230;</li>
<li>The body of the email should clearly state the error condition.</li>
<li>When possible, the body of the email should give the recovery procedure. If this is not possible, it should point to the documentation</li>
</ol>
<p>So let&#8217;s say those are my &#8220;best practices&#8221; based on field experience. Have more tips or rules ? Share them in the comments !</p>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2010/01/09/batches-monitoring-emails/">Monitoring batches in IT environment : efficiently using emails</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sakana/articles?a=XpSAe0JGl38:hH_bXvOQfcY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=XpSAe0JGl38:hH_bXvOQfcY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=XpSAe0JGl38:hH_bXvOQfcY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=XpSAe0JGl38:hH_bXvOQfcY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=XpSAe0JGl38:hH_bXvOQfcY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=XpSAe0JGl38:hH_bXvOQfcY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=XpSAe0JGl38:hH_bXvOQfcY:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=XpSAe0JGl38:hH_bXvOQfcY:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sakana/articles/~4/XpSAe0JGl38" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/01/09/batches-monitoring-emails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.sakana.fr/blog/2010/01/09/batches-monitoring-emails/</feedburner:origLink></item>
		<item>
		<title>Firefox (Linux) : “Middle-click on page loads URL” annoyance</title>
		<link>http://feedproxy.google.com/~r/sakana/articles/~3/k6TPb6zPznA/</link>
		<comments>http://www.sakana.fr/blog/2010/01/03/firefox-linux-middle-click-on-page-loads-url-annoyance/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 20:52:20 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[annoyance]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=374</guid>
		<description><![CDATA[Firefox will load whatever URL is in the copy-paste buffer in the page if you middle click somewhere on a page. My mouse&#8217;s wheel also serves as the middle button, and I found it really annoying that when occasionally middle-clicking while scrolling the page, Firefox would try to load another page &#8230;
You can control this [...]<p><a href="http://www.sakana.fr/blog/2010/01/03/firefox-linux-middle-click-on-page-loads-url-annoyance/">Firefox (Linux) : &#8220;Middle-click on page loads URL&#8221; annoyance</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Firefox will load whatever URL is in the copy-paste buffer in the page if you middle click somewhere on a page. My mouse&#8217;s wheel also serves as the middle button, and I found it really annoying that when occasionally middle-clicking while scrolling the page, Firefox would try to load another page &#8230;</p>
<p>You can control this behaviour with this about:config property <tt>middlemouse.contentLoadURL</tt>. Set to true, the middle-click on the page will load the URL (if it is one) in the page, set to false it won&#8217;t.</p>
<p>Thanks <a href="http://aymanh.com/archives/2006/01/27/firefox-and-middle-click-clipboard-url" target="_blank">Ayman</a> !</p>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2010/01/03/firefox-linux-middle-click-on-page-loads-url-annoyance/">Firefox (Linux) : &#8220;Middle-click on page loads URL&#8221; annoyance</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sakana/articles?a=k6TPb6zPznA:P6DXNquYkGI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=k6TPb6zPznA:P6DXNquYkGI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=k6TPb6zPznA:P6DXNquYkGI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=k6TPb6zPznA:P6DXNquYkGI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=k6TPb6zPznA:P6DXNquYkGI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=k6TPb6zPznA:P6DXNquYkGI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=k6TPb6zPznA:P6DXNquYkGI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=k6TPb6zPznA:P6DXNquYkGI:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sakana/articles/~4/k6TPb6zPznA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2010/01/03/firefox-linux-middle-click-on-page-loads-url-annoyance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sakana.fr/blog/2010/01/03/firefox-linux-middle-click-on-page-loads-url-annoyance/</feedburner:origLink></item>
		<item>
		<title>Perl : Using the Finance::Quote module to get your stock prices</title>
		<link>http://feedproxy.google.com/~r/sakana/articles/~3/vfIhCFEhzvM/</link>
		<comments>http://www.sakana.fr/blog/2009/12/30/perl-using-the-financequote-module-to-get-your-stock-prices/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 15:02:25 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[conky]]></category>
		<category><![CDATA[Finance::Quote]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[stocks]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=367</guid>
		<description><![CDATA[Finance::Quote is a Perl module which can be used to obtain stock information from various internet sources. I thought I&#8217;d rather share this code snippet as an example showing how easy it is to use, before I turn it into a bloatware with an SQL backend to compute average price per share and what not [...]<p><a href="http://www.sakana.fr/blog/2009/12/30/perl-using-the-financequote-module-to-get-your-stock-prices/">Perl : Using the Finance::Quote module to get your stock prices</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://finance-quote.sourceforge.net/" target="_blank">Finance::Quote</a> is a Perl module which can be used to obtain stock information from various internet sources. I thought I&#8217;d rather share this code snippet as an example showing how easy it is to use, before I turn it into a bloatware with an SQL backend to compute <a href="http://www.investorglossary.com/average-price-per-share.htm" target="_blank">average price per share</a> and what not <img src='http://www.sakana.fr/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>So here is a simple snippet demonstrating how to get the price of a stock :<br />
<span id="more-367"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://www.sakana.fr/blog/wp-content/plugins/wp-codebox/wp-codebox.php?p=367&amp;download=get-stocks.pl">get-stocks.pl</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p36721"><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
</pre></td><td class="code" id="p367code21"><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;">use</span> strict<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> warnings<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Finance<span style="color: #339933;">::</span><span style="color: #006600;">Quote</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$q</span> <span style="color: #339933;">=</span> Finance<span style="color: #339933;">::</span><span style="color: #006600;">Quote</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">new</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@tickers</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;CS.PA&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;DEXB.PA&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;AF.PA&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;VIE.PA&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;KEYYO.PA&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$s</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$q</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;yahoo_europe&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">@tickers</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$stocks</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$k</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/each.html"><span style="color: #000066;">each</span></a> <span style="color: #0000ff;">%$s</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$stock</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$label</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$stock</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$label</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><a href="http://perldoc.perl.org/functions/split.html"><span style="color: #000066;">split</span></a> <span style="color: #0000ff;">$;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$k</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #0000ff;">$stocks</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$stock</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$label</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$v</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">@data</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@tickers</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: #b1b100;">not</span> <span style="color: #0000ff;">$stocks</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$_</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>success<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<a href="http://perldoc.perl.org/functions/push.html"><span style="color: #000066;">push</span></a> <span style="color: #0000ff;">@data</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> name <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">,</span> price <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;N/A&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<a href="http://perldoc.perl.org/functions/push.html"><span style="color: #000066;">push</span></a> <span style="color: #0000ff;">@data</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$stocks</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$_</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: #b1b100;">my</span> <span style="color: #0000ff;">@sorted</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/sort.html"><span style="color: #000066;">sort</span></a> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>name<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">cmp</span> <span style="color: #0000ff;">$b</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>name<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #0000ff;">@data</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">@data</span> <span style="color: #339933;">=</span> <a href="http://perldoc.perl.org/functions/undef.html"><span style="color: #000066;">undef</span></a><span style="color: #339933;">;</span>
&nbsp;
<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <a href="http://perldoc.perl.org/functions/sprintf.html"><span style="color: #000066;">sprintf</span></a> <span style="color: #ff0000;">&quot;% -20s %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;STOCK&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;PRICE&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@sorted</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<a href="http://perldoc.perl.org/functions/print.html"><span style="color: #000066;">print</span></a> <a href="http://perldoc.perl.org/functions/sprintf.html"><span style="color: #000066;">sprintf</span></a> <span style="color: #ff0000;">&quot;% -20s % 7.2f<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>name<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">-&gt;</span><span style="color: #009900;">&#123;</span>price<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The execution will provide something like that :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p367code22'); return false;">View Code</a> SHELL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p36722"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p367code22"><pre class="shell" style="font-family:monospace;">kattoo@roadrunner ~/bin $ ./get-stocks.pl 
STOCK                PRICE
AIR FRANCE - KLM       11.35
AXA                    16.64
DEXIA                   4.87
KEYYO                   3.30
VEOLIA ENVIRONN.       22.70
kattoo@roadrunner ~/bin $</pre></td></tr></table></div>

<p>That&#8217;s pretty simple so I won&#8217;t go into more details (feel free to ask if you need clarifications).</p>
<p>I&#8217;ve already added it into my <a href="http://www.sakana.fr/blog/2009/10/11/conky-integrating-rtorrent-downloads-monitoring/" target="_blank">conky layout</a> with an execpi directive, and it works like a charm <img src='http://www.sakana.fr/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://www.sakana.fr/blog/2009/12/30/perl-using-the-financequote-module-to-get-your-stock-prices/">Perl : Using the Finance::Quote module to get your stock prices</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sakana/articles?a=vfIhCFEhzvM:4mWg1SCmC2s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=vfIhCFEhzvM:4mWg1SCmC2s:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=vfIhCFEhzvM:4mWg1SCmC2s:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=vfIhCFEhzvM:4mWg1SCmC2s:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=vfIhCFEhzvM:4mWg1SCmC2s:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=vfIhCFEhzvM:4mWg1SCmC2s:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=vfIhCFEhzvM:4mWg1SCmC2s:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=vfIhCFEhzvM:4mWg1SCmC2s:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sakana/articles/~4/vfIhCFEhzvM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2009/12/30/perl-using-the-financequote-module-to-get-your-stock-prices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sakana.fr/blog/2009/12/30/perl-using-the-financequote-module-to-get-your-stock-prices/</feedburner:origLink></item>
		<item>
		<title>Gentoo Linux / Portage : How to know which package provided an installed file</title>
		<link>http://feedproxy.google.com/~r/sakana/articles/~3/pI0HjdI4kwQ/</link>
		<comments>http://www.sakana.fr/blog/2009/12/03/gentoo-linux-portage-how-to-know-which-package-provided-an-installed-file/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 08:33:37 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[equery]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[portage]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=364</guid>
		<description><![CDATA[If there&#8217;s a file installed on your disk for which you&#8217;d like to know what package provided it, you can use the equery command like below :


?View Code TEXT1
2
roadrunner ~ # equery belongs /etc/init.d/samba [ Searching for file(s) /etc/init.d/samba in *... ]
net-fs/samba-3.0.37 (/etc/init.d/samba)

equery is part of the gentoolkit package, which provides useful tools to maintain/investigate [...]<p><a href="http://www.sakana.fr/blog/2009/12/03/gentoo-linux-portage-how-to-know-which-package-provided-an-installed-file/">Gentoo Linux / Portage : How to know which package provided an installed file</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If there&#8217;s a file installed on your disk for which you&#8217;d like to know what package provided it, you can use the equery command like below :<br />
<span id="more-364"></span></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p364code25'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p36425"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p364code25"><pre class="text" style="font-family:monospace;">roadrunner ~ # equery belongs /etc/init.d/samba [ Searching for file(s) /etc/init.d/samba in *... ]
net-fs/samba-3.0.37 (/etc/init.d/samba)</pre></td></tr></table></div>

<p>equery is part of the gentoolkit package, which provides useful tools to maintain/investigate your gentoo packages.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p364code26'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p36426"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p364code26"><pre class="text" style="font-family:monospace;">roadrunner ~ # equery belongs /usr/bin/revdep-rebuild 
[ Searching for file(s) /usr/bin/revdep-rebuild in *... ]
app-portage/gentoolkit-0.2.4.5 (/usr/bin/revdep-rebuild)</pre></td></tr></table></div>

<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2009/12/03/gentoo-linux-portage-how-to-know-which-package-provided-an-installed-file/">Gentoo Linux / Portage : How to know which package provided an installed file</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sakana/articles?a=pI0HjdI4kwQ:82fT_0hKXLw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=pI0HjdI4kwQ:82fT_0hKXLw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=pI0HjdI4kwQ:82fT_0hKXLw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=pI0HjdI4kwQ:82fT_0hKXLw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=pI0HjdI4kwQ:82fT_0hKXLw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=pI0HjdI4kwQ:82fT_0hKXLw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=pI0HjdI4kwQ:82fT_0hKXLw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=pI0HjdI4kwQ:82fT_0hKXLw:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sakana/articles/~4/pI0HjdI4kwQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2009/12/03/gentoo-linux-portage-how-to-know-which-package-provided-an-installed-file/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.sakana.fr/blog/2009/12/03/gentoo-linux-portage-how-to-know-which-package-provided-an-installed-file/</feedburner:origLink></item>
		<item>
		<title>VirtualBox : Cloning a virtual hard disk</title>
		<link>http://feedproxy.google.com/~r/sakana/articles/~3/FhaXAvJyORE/</link>
		<comments>http://www.sakana.fr/blog/2009/11/18/virtualbox-cloning-a-virtual-hard-disk/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 09:50:22 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[clone]]></category>
		<category><![CDATA[clonehd]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[vm]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=358</guid>
		<description><![CDATA[If you&#8217;ve got a VirtualBox VM already installed and you wish to clone/copy it, follow the steps below :


Clone the disk image with a similar command line (you will have to adjust your paths) :

?View Code TEXT1
2
3
4
5
6
7
8
kattoo@roadrunner /files/toSave/home/kattoo $ VBoxManage clonehd /files/vservers/{VM1/disk1.vdi,VM2/disk2.vdi}
VirtualBox Command Line Management Interface Version 3.0.10
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
&#160;
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard [...]<p><a href="http://www.sakana.fr/blog/2009/11/18/virtualbox-cloning-a-virtual-hard-disk/">VirtualBox : Cloning a virtual hard disk</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve got a VirtualBox VM already installed and you wish to clone/copy it, follow the steps below :<br />
<span id="more-358"></span></p>
<ol>
<li>Clone the disk image with a similar command line (you will have to adjust your paths) :

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p358code28'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p35828"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p358code28"><pre class="text" style="font-family:monospace;">kattoo@roadrunner /files/toSave/home/kattoo $ VBoxManage clonehd /files/vservers/{VM1/disk1.vdi,VM2/disk2.vdi}
VirtualBox Command Line Management Interface Version 3.0.10
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.
&nbsp;
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'VDI'. UUID: 84956ae4-6c85-41cf-aa23-a265029d99a8
kattoo@roadrunner /files/toSave/home/kattoo $</pre></td></tr></table></div>

</li>
<li>Setup a new virtual machine through the virtualbox GUI or otherwise, with the same parameters as the original one and attach this new disk</li>
</ol>
<p>Note : This command doesn&#8217;t take care of potential snapshots you could have on the source disk image. It will only clone the base image, so you might have to merge the snapshots into the base image before cloning if you want those to be integrated in the copy.</p>
<p>References :</p>
<ul>
<li><a href="http://www.virtualbox.org/manual/UserManual.html#vboxmanage-clonevdi" target="_blank">VirtualBox manual : vboxmanage clonehd</a></li>
</ul>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2009/11/18/virtualbox-cloning-a-virtual-hard-disk/">VirtualBox : Cloning a virtual hard disk</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sakana/articles?a=FhaXAvJyORE:rjLyTRn-bu4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=FhaXAvJyORE:rjLyTRn-bu4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=FhaXAvJyORE:rjLyTRn-bu4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=FhaXAvJyORE:rjLyTRn-bu4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=FhaXAvJyORE:rjLyTRn-bu4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=FhaXAvJyORE:rjLyTRn-bu4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=FhaXAvJyORE:rjLyTRn-bu4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=FhaXAvJyORE:rjLyTRn-bu4:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sakana/articles/~4/FhaXAvJyORE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2009/11/18/virtualbox-cloning-a-virtual-hard-disk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sakana.fr/blog/2009/11/18/virtualbox-cloning-a-virtual-hard-disk/</feedburner:origLink></item>
		<item>
		<title>OpenSolaris : Exporting a ZFS filesystem with CIFS</title>
		<link>http://feedproxy.google.com/~r/sakana/articles/~3/yT4nxaiaEEA/</link>
		<comments>http://www.sakana.fr/blog/2009/11/11/opensolaris-exporting-a-zfs-filesystem-with-cifs/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 15:15:57 +0000</pubDate>
		<dc:creator>Stephane Kattoor</dc:creator>
				<category><![CDATA[Systems]]></category>
		<category><![CDATA[cifs]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[samba]]></category>
		<category><![CDATA[zfs]]></category>

		<guid isPermaLink="false">http://www.sakana.fr/blog/?p=347</guid>
		<description><![CDATA[If you need to export ZFS volumes through CIFS, follow this simple step by step procedure.

Step 1 : install the packages
(This step is optional if you already have them installed on the machine)

?View Code TEXT1
2
3
4
5
6
kattoo@backup3:~$ pfexec pkg install SUNWsmbskr
DOWNLOAD                 [...]<p><a href="http://www.sakana.fr/blog/2009/11/11/opensolaris-exporting-a-zfs-filesystem-with-cifs/">OpenSolaris : Exporting a ZFS filesystem with CIFS</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If you need to export ZFS volumes through CIFS, follow this simple step by step procedure.<br />
<span id="more-347"></span></p>
<h4>Step 1 : install the packages</h4>
<p>(This step is optional if you already have them installed on the machine)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code35'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34735"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p347code35"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ pfexec pkg install SUNWsmbskr
DOWNLOAD                                  PKGS       FILES    XFER (MB)
Completed                                  2/2       35/35      2.0/2.0 
&nbsp;
PHASE                                        ACTIONS
Install Phase                                  90/90</pre></td></tr></table></div>

<p>At this point, you&#8217;ll need to perform a reboot (if you can&#8217;t afford that, check in the references for a link to the full procedure).</p>
<h4>Step 2 : Join a WORKGROUP</h4>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code36'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34736"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p347code36"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ pfexec smbadm join -w SAKANA
After joining SAKANA the smb service will be restarted automatically.
Would you like to continue? [no]: yes
Successfully joined SAKANA
kattoo@backup3:~$</pre></td></tr></table></div>

<h4>Step 3 : Set passwords for users who will access the shares</h4>
<p>Add the following line into <b>/etc/pam.conf</b> :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code37'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34737"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p347code37"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ grep smb /etc/pam.conf 
other 	password required 	pam_smb_passwd.so.1 nowarn</pre></td></tr></table></div>

<p>Now reset the passwords for the users who will be access the shares :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code38'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34738"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p347code38"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ pfexec passwd kattoo
New Password: 
Re-enter new Password: 
passwd: password successfully changed for kattoo</pre></td></tr></table></div>

<h4>Step 4 : Share the filesystems</h4>
<p>You can then share any zfs filesystem with the following :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code39'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34739"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p347code39"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ pfexec zfs set sharesmb=on backup</pre></td></tr></table></div>

<p>To check what is exported, you can do this :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p347code40'); return false;">View Code</a> TEXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p34740"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p347code40"><pre class="text" style="font-family:monospace;">kattoo@backup3:~$ sharemgr show -pv
default nfs=()
zfs
    zfs/backup smb=()
	  backup=/backup
	  backup_roadrunner=/backup/roadrunner
	  backup_thekla=/backup/thekla
    zfs/storage smb=()
	  storage=/storage
kattoo@backup3:~$</pre></td></tr></table></div>

<p>Here, the backup_roadrunner and backup_thekla were automatically exported because the property sharesmb was inherited from backup.</p>
<p>References :</p>
<ul>
<li><a href="http://wiki.genunix.org/wiki/index.php/Getting_Started_With_the_Solaris_CIFS_Service" target="_blank">Genunix : Getting Started With the Solaris CIFS Service</a></li>
</ul>
<p><!--adsense--></p>
<p><a href="http://www.sakana.fr/blog/2009/11/11/opensolaris-exporting-a-zfs-filesystem-with-cifs/">OpenSolaris : Exporting a ZFS filesystem with CIFS</a> is a post from: <a href="http://www.sakana.fr/blog">Tech@Sakana - A sysadmin's blog</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/sakana/articles?a=yT4nxaiaEEA:ARJjwOWPngk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=yT4nxaiaEEA:ARJjwOWPngk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=yT4nxaiaEEA:ARJjwOWPngk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=yT4nxaiaEEA:ARJjwOWPngk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=yT4nxaiaEEA:ARJjwOWPngk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=yT4nxaiaEEA:ARJjwOWPngk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/sakana/articles?i=yT4nxaiaEEA:ARJjwOWPngk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/sakana/articles?a=yT4nxaiaEEA:ARJjwOWPngk:dnMXMwOfBR0"><img src="http://feeds.feedburner.com/~ff/sakana/articles?d=dnMXMwOfBR0" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/sakana/articles/~4/yT4nxaiaEEA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.sakana.fr/blog/2009/11/11/opensolaris-exporting-a-zfs-filesystem-with-cifs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.sakana.fr/blog/2009/11/11/opensolaris-exporting-a-zfs-filesystem-with-cifs/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.931 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-03-09 22:42:20 -->
