<?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>MrBrown blob</title>
	
	<link>http://charles.lescampeurs.org</link>
	<description>random bits about sysadmin</description>
	<lastBuildDate>Mon, 12 Oct 2009 11:20:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</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" href="http://feeds.feedburner.com/MrbrownBlob" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Optimizing Servers and Processes for Speed with ionice, nice, ulimit</title>
		<link>http://feedproxy.google.com/~r/MrbrownBlob/~3/R6s3tPFCNfY/optimizing-servers-and-processes-for-speed-with-ionice-nice-ulimit</link>
		<comments>http://charles.lescampeurs.org/2009/10/12/optimizing-servers-and-processes-for-speed-with-ionice-nice-ulimit#comments</comments>
		<pubDate>Mon, 12 Oct 2009 11:20:59 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[Optimization]]></category>
		<category><![CDATA[ionice]]></category>
		<category><![CDATA[nice]]></category>
		<category><![CDATA[ulimit]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=202</guid>
		<description><![CDATA[Just found this very good article about optimizing servers.
]]></description>
			<content:encoded><![CDATA[<p>Just found this very good article about <a title="Optimizing Servers and Processes for Speed with ionice, nice, ulimit" href="http://feeds.askapache.com/~r/apache/htaccess/~3/9U5RRoy_zhs/optimize-nice-ionice.html" target="_blank">optimizing servers</a>.</p>
<img src="http://feeds.feedburner.com/~r/MrbrownBlob/~4/R6s3tPFCNfY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2009/10/12/optimizing-servers-and-processes-for-speed-with-ionice-nice-ulimit/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://charles.lescampeurs.org/2009/10/12/optimizing-servers-and-processes-for-speed-with-ionice-nice-ulimit</feedburner:origLink></item>
		<item>
		<title>Quickly check hosts with ping</title>
		<link>http://feedproxy.google.com/~r/MrbrownBlob/~3/7ZCVY7w0PI0/quickly-check-hosts-with-ping</link>
		<comments>http://charles.lescampeurs.org/2009/08/14/quickly-check-hosts-with-ping#comments</comments>
		<pubDate>Fri, 14 Aug 2009 11:46:02 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[Command line]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[netcat]]></category>
		<category><![CDATA[ping]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=198</guid>
		<description><![CDATA[I needed a script for a quick health check of a bunch of servers.
This is how I did it using the ping command:
for((i=1;i&#60;42;i++)); do
    ping -c 1 -W 3 host${i}.domain.com &#38;&#62; /dev/null
    if [ $? -ne 0 ] ; then
        echo "host${i} [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a script for a quick health check of a bunch of servers.<br />
This is how I did it using the <a href="http://linux.die.net/man/8/ping" target="_blank">ping command</a>:</p>
<pre>for((i=1;i&lt;42;i++)); do
    ping -c 1 -W 3 host${i}.domain.com &amp;&gt; /dev/null
    if [ $? -ne 0 ] ; then
        echo "host${i} is down"
    else
        echo "host${i} is up"
    fi
done</pre>
<p>You can also use netcat and check a specific port:</p>
<pre>netcat -z -w 2  host${i}.domain.com 80 &amp;&gt; /dev/null</pre>
<img src="http://feeds.feedburner.com/~r/MrbrownBlob/~4/7ZCVY7w0PI0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2009/08/14/quickly-check-hosts-with-ping/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://charles.lescampeurs.org/2009/08/14/quickly-check-hosts-with-ping</feedburner:origLink></item>
		<item>
		<title>Set Terminal tab title in Mac OS X</title>
		<link>http://feedproxy.google.com/~r/MrbrownBlob/~3/hCRFn7iZd1M/set-terminal-tab-title-in-mac-os-x</link>
		<comments>http://charles.lescampeurs.org/2009/08/11/set-terminal-tab-title-in-mac-os-x#comments</comments>
		<pubDate>Tue, 11 Aug 2009 12:12:07 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[Command line]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=195</guid>
		<description><![CDATA[
I wrote previously a how-to to set your iTerm tab title.
I finally found a tool to do the same thing with the default Mac OS X Terminal.
Check it out here, it works perfectly for me!
]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-196" title="Picture 2" src="http://charles.lescampeurs.org/wp-content/uploads/2009/08/Picture-2.png" alt="Picture 2" width="209" height="84" /></p>
<p>I wrote previously a how-to to <a href="http://charles.lescampeurs.org/2008/05/07/automatically-set-title-on-iterm-tabs" target="_blank">set your iTerm tab title</a>.</p>
<p>I finally found a tool to do the same thing with the default Mac OS X Terminal.</p>
<p>Check it out <a href="http://purpleamy.com/magicwrap/" target="_blank">here</a>, it works perfectly for me!</p>
<img src="http://feeds.feedburner.com/~r/MrbrownBlob/~4/hCRFn7iZd1M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2009/08/11/set-terminal-tab-title-in-mac-os-x/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://charles.lescampeurs.org/2009/08/11/set-terminal-tab-title-in-mac-os-x</feedburner:origLink></item>
		<item>
		<title>Set the number of reserved filesystem blocks of a disk</title>
		<link>http://feedproxy.google.com/~r/MrbrownBlob/~3/yPxd7PrbQNs/set-the-number-of-reserved-filesystem-blocks-of-a-disk</link>
		<comments>http://charles.lescampeurs.org/2009/06/30/set-the-number-of-reserved-filesystem-blocks-of-a-disk#comments</comments>
		<pubDate>Tue, 30 Jun 2009 07:55:25 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[tune2fs]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=188</guid>
		<description><![CDATA[The default value of &#8220;Reserved block count&#8221; takes 5% of usable disk. On a large fs like 813G, it represents about 40G.
These blocks are reserved to the super user to recover from situations where user processes fill up filesystems.
It is absolutely safe to reduce this space to one hundred or so MB.

check disk space of [...]]]></description>
			<content:encoded><![CDATA[<p>The default value of &#8220;Reserved block count&#8221; takes 5% of usable disk. On a large fs like 813G, it represents about 40G.</p>
<p>These blocks are reserved to the super user to recover from situations where user processes fill up filesystems.<br />
It is absolutely safe to reduce this space to one hundred or so MB.</p>
<ul>
<li>check disk space of our filesystem:</li>
</ul>
<pre>$ df -h /dev/sda4
/dev/sda4             813G  418G  354G  55% /home</pre>
<p>Before the tuning, we have 354G free.</p>
<ul>
<li>check the current number of reserved blocks:</li>
</ul>
<pre>$ tune2fs -l /dev/sda4
...
Reserved block count:     10816865
...</pre>
<p>Change this number to 20000.<br />
The blocksize is 4096, 20000 blocks represent about 80MB.</p>
<pre>$ tune2fs -r20000 /dev/sda4
...
Reserved block count:     20000
...</pre>
<ul>
<li>check disk space of our filesystem:</li>
</ul>
<pre>$ df -h /dev/sda4
/dev/sda4             813G  418G  395G  52% /home</pre>
<p>We now have a gain of 40GB of free space!</p>
<img src="http://feeds.feedburner.com/~r/MrbrownBlob/~4/yPxd7PrbQNs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2009/06/30/set-the-number-of-reserved-filesystem-blocks-of-a-disk/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://charles.lescampeurs.org/2009/06/30/set-the-number-of-reserved-filesystem-blocks-of-a-disk</feedburner:origLink></item>
		<item>
		<title>Finding the total size of a set of files with awk</title>
		<link>http://feedproxy.google.com/~r/MrbrownBlob/~3/hlHmrmcYCMs/finding-the-total-size-of-a-set-of-files-with-awk</link>
		<comments>http://charles.lescampeurs.org/2009/04/17/finding-the-total-size-of-a-set-of-files-with-awk#comments</comments>
		<pubDate>Fri, 17 Apr 2009 09:12:22 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[Command line]]></category>
		<category><![CDATA[awk]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=185</guid>
		<description><![CDATA[If you need to sum the total size of files in a directory or matching a pattern, an easy solution is to use awk.
I needed to calculate this total for a set of javascript files, I used this command line:
$ find App/ -name '*.js' -exec ls -l \{\} \; &#124; awk '{sum+=$5} END {print sum}'
1929403
For [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to sum the total size of files in a directory or matching a pattern, an easy solution is to use <em>awk</em>.</p>
<p>I needed to calculate this total for a set of javascript files, I used this command line:</p>
<pre>$ find App/ -name '*.js' -exec ls -l \{\} \; | awk '{sum+=$5} END {print sum}'
1929403</pre>
<p>For a human readable result, you can divide your result and use printf to format it:</p>
<pre>$ find App/ -name '*.js' -exec ls -l \{\} \; | awk '{sum+=$5} END {printf("%.2fM\n", sum/1024/1024)}'
1.84M</pre>
<img src="http://feeds.feedburner.com/~r/MrbrownBlob/~4/hlHmrmcYCMs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2009/04/17/finding-the-total-size-of-a-set-of-files-with-awk/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://charles.lescampeurs.org/2009/04/17/finding-the-total-size-of-a-set-of-files-with-awk</feedburner:origLink></item>
		<item>
		<title>Permanent redirect with nginx</title>
		<link>http://feedproxy.google.com/~r/MrbrownBlob/~3/5qWHlByJoKQ/permanent-redirect-with-nginx</link>
		<comments>http://charles.lescampeurs.org/2009/03/20/permanent-redirect-with-nginx#comments</comments>
		<pubDate>Fri, 20 Mar 2009 05:12:42 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[http]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=164</guid>
		<description><![CDATA[server {
    server_name domain.com;
    rewrite ^(.*)$ http://www.domain.com$1 permanent;
}
]]></description>
			<content:encoded><![CDATA[<pre>server {
    server_name domain.com;
    rewrite ^(.*)$ http://www.domain.com$1 permanent;
}</pre>
<img src="http://feeds.feedburner.com/~r/MrbrownBlob/~4/5qWHlByJoKQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2009/03/20/permanent-redirect-with-nginx/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://charles.lescampeurs.org/2009/03/20/permanent-redirect-with-nginx</feedburner:origLink></item>
		<item>
		<title>Memory usage by group of processes</title>
		<link>http://feedproxy.google.com/~r/MrbrownBlob/~3/BMVRj4YHxSg/memory-usage-by-group-of-processes</link>
		<comments>http://charles.lescampeurs.org/2009/03/13/memory-usage-by-group-of-processes#comments</comments>
		<pubDate>Fri, 13 Mar 2009 14:14:26 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[Benchmarks]]></category>
		<category><![CDATA[Command line]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=173</guid>
		<description><![CDATA[While monitoring a http/php server, I needed to do some statistics about php-cgi memory usage.
Playing with memory_limit in PHP, we wanted to know the average memory usage per php-cgi process. This is easily calculated with our best friend awk.
First, get the number of php running processes:
# ps aux &#124; grep php-cgi &#124; grep -v grep [...]]]></description>
			<content:encoded><![CDATA[<p>While monitoring a http/php server, I needed to do some statistics about php-cgi memory usage.</p>
<p>Playing with <em>memory_limit</em> in PHP, we wanted to know the average memory usage per php-cgi process. This is easily calculated with our best friend awk.</p>
<p>First, get the number of php running processes:</p>
<pre># ps aux | grep php-cgi | grep -v grep | wc -l
126</pre>
<p>Then, use awk to calculate the average memory usage for these processes:</p>
<pre># ps aux | grep --exclude=grep php-cgi | grep -v grep | awk 'BEGIN{s=0;}{s=s+$6;}END{print s/126;}'
33987.8</pre>
<p>The number used in the calculation is the field RSS given by ps. The ps manual page says:</p>
<blockquote><p>rss: resident set size, the non-swapped physical memory that a task has used (in kiloBytes)</p></blockquote>
<p>You can also calculate the total memory used by all php-cgi processes:</p>
<pre># ps aux | grep --exclude=grep php-cgi | grep -v grep | awk 'BEGIN{s=0;}{s=s+$6;}END{print s;}'
4302028</pre>
<p>If you need to watch the trend of this average memory usage, a little shell loop does the trick:</p>
<pre># while [ 1 ]; do ps aux | grep --exclude=grep php-cgi | grep -v grep | awk 'BEGIN{s=0;}{s=s+$6;}END{print s/126;}'; sleep 2; done
34401.3
34405.1
34408.4
34409.4
34414.2
34417</pre>
<img src="http://feeds.feedburner.com/~r/MrbrownBlob/~4/BMVRj4YHxSg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2009/03/13/memory-usage-by-group-of-processes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://charles.lescampeurs.org/2009/03/13/memory-usage-by-group-of-processes</feedburner:origLink></item>
		<item>
		<title>permanently load enable HTTP Accept Filter FreeBSD kernel module (accf_http)</title>
		<link>http://feedproxy.google.com/~r/MrbrownBlob/~3/3jX_S9mixJc/permanently-load-enable-http-accept-filter-freebsd-kernel-module-accf_http</link>
		<comments>http://charles.lescampeurs.org/2009/03/12/permanently-load-enable-http-accept-filter-freebsd-kernel-module-accf_http#comments</comments>
		<pubDate>Thu, 12 Mar 2009 04:04:36 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[Optimization]]></category>
		<category><![CDATA[FreeBSD]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=171</guid>
		<description><![CDATA[While reading articles about optimization, I read about the accf_http module.
The man page of the module is here, where you can read:
The utility of accf_http is such that a server will not have to context switch several times before performing the initial parsing of the request.
To load this module, use the following command:
# kldload accf_http
To [...]]]></description>
			<content:encoded><![CDATA[<p>While reading articles about optimization, I read about the <em>accf_http</em> module.</p>
<p>The man page of the module is <a title="accf_http man page" href="http://www.freebsd.org/cgi/man.cgi?query=accf_http" target="_blank">here</a>, where you can read:</p>
<blockquote><p><em>The utility of <strong>accf_http</strong> is such that a server will not have to context switch several times before performing the initial parsing of the request.</em></p></blockquote>
<p>To load this module, use the following command:</p>
<pre># kldload accf_http</pre>
<p>To load it at boot time, add the following line in <em>/boot/loader.conf</em>:</p>
<pre>accf_http_load="YES"</pre>
<p>To check if the module is loaded, use the command <em>kldstat</em>:</p>
<pre># kldstat
Id Refs Address    Size     Name
 1    4 0xc0400000 906518   kernel
 2    1 0xc0d07000 6a32c    acpi.ko
 3    1 0xc5e65000 2000     accf_http.ko</pre>
<img src="http://feeds.feedburner.com/~r/MrbrownBlob/~4/3jX_S9mixJc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2009/03/12/permanently-load-enable-http-accept-filter-freebsd-kernel-module-accf_http/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://charles.lescampeurs.org/2009/03/12/permanently-load-enable-http-accept-filter-freebsd-kernel-module-accf_http</feedburner:origLink></item>
		<item>
		<title>Munin and Use of uninitializer value in eval</title>
		<link>http://feedproxy.google.com/~r/MrbrownBlob/~3/v0VswrdcSr0/munin-and-use-of-uninitializer-value-in-eval</link>
		<comments>http://charles.lescampeurs.org/2009/03/11/munin-and-use-of-uninitializer-value-in-eval#comments</comments>
		<pubDate>Wed, 11 Mar 2009 06:51:26 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[etch]]></category>
		<category><![CDATA[munin]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=166</guid>
		<description><![CDATA[On some of freshly installed servers (Debian Etch), I encountered these error messages in /var/log/munin/munin-node.log:
Use of uninitialized value in eval {block} exit at /usr/sbin/munin-node line 456, &#60;CHILD&#62; line 8.
What a great error message  
After digging into Google results, I found it was just a problem with host_name variable in the configuration. Default value is [...]]]></description>
			<content:encoded><![CDATA[<p>On some of freshly installed servers (Debian Etch), I encountered these error messages in <em>/var/log/munin/munin-node.log</em>:</p>
<pre>Use of uninitialized value in eval {block} exit at /usr/sbin/munin-node line 456, &lt;CHILD&gt; line 8.</pre>
<p>What a great error message <img src='http://charles.lescampeurs.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>After digging into Google results, I found it was just a problem with host_name variable in the configuration. Default value is <em>hostname.localdomain</em>. I&#8217;ve replaced it with a valid hostname and it works!</p>
<img src="http://feeds.feedburner.com/~r/MrbrownBlob/~4/v0VswrdcSr0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2009/03/11/munin-and-use-of-uninitializer-value-in-eval/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://charles.lescampeurs.org/2009/03/11/munin-and-use-of-uninitializer-value-in-eval</feedburner:origLink></item>
		<item>
		<title>Nginx and worker_connections are more than open file resource limit warning</title>
		<link>http://feedproxy.google.com/~r/MrbrownBlob/~3/7VyrlkfYppQ/nginx-and-worker_connections-are-more-than-open-file-resource-limit-warning</link>
		<comments>http://charles.lescampeurs.org/2009/03/09/nginx-and-worker_connections-are-more-than-open-file-resource-limit-warning#comments</comments>
		<pubDate>Mon, 09 Mar 2009 20:30:26 +0000</pubDate>
		<dc:creator>CharlyBr</dc:creator>
				<category><![CDATA[Distro]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ulimit]]></category>

		<guid isPermaLink="false">http://charles.lescampeurs.org/?p=160</guid>
		<description><![CDATA[If you encounter this warning message under Linux:
2009/03/09 21:23:19 [warn] 26827#0: 4096 worker_connections are more than open file resource limit: 1024
A solution is to use the command ulimit in nginx start script, just before lunching nginx:
[...]
ulimit  -n 65536
[...]
]]></description>
			<content:encoded><![CDATA[<p>If you encounter this warning message under Linux:</p>
<pre>2009/03/09 21:23:19 [warn] 26827#0: 4096 worker_connections are more than open file resource limit: 1024</pre>
<p>A solution is to use the command ulimit in nginx start script, just before lunching nginx:</p>
<pre>[...]
ulimit  -n 65536
[...]</pre>
<img src="http://feeds.feedburner.com/~r/MrbrownBlob/~4/7VyrlkfYppQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://charles.lescampeurs.org/2009/03/09/nginx-and-worker_connections-are-more-than-open-file-resource-limit-warning/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://charles.lescampeurs.org/2009/03/09/nginx-and-worker_connections-are-more-than-open-file-resource-limit-warning</feedburner:origLink></item>
	</channel>
</rss>
