<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HostingFu &#187; vzfree</title>
	<atom:link href="http://hostingfu.com/tag/vzfree/feed" rel="self" type="application/rss+xml" />
	<link>http://hostingfu.com</link>
	<description>Web Hosting Blog by a Software Developer</description>
	<lastBuildDate>Mon, 19 Jul 2010 09:27:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>vzfree &#8211; Checking Memory Usage inside OpenVZ VE</title>
		<link>http://hostingfu.com/article/vzfree-checking-memory-usage-inside-openvz-ve</link>
		<comments>http://hostingfu.com/article/vzfree-checking-memory-usage-inside-openvz-ve#comments</comments>
		<pubDate>Fri, 10 Oct 2008 06:03:07 +0000</pubDate>
		<dc:creator>scotty</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[openvz]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[vzfree]]></category>

		<guid isPermaLink="false">http://hostingfu.com/?p=172</guid>
		<description><![CDATA[Gee. It has been a while since I&#8217;ve last written here, and it will be a while again for my next post as I will be on holidays from next Monday (visiting families in Hong Kong and Taiwan). Let me share one small utility program that I wrote quite a while ago. We all know [...]]]></description>
			<content:encoded><![CDATA[<p>Gee. It has been a while since I&#8217;ve last written here, and it will be a while again for my next post as I will be on holidays from next Monday (visiting families in Hong Kong and Taiwan). Let me share one small utility program that I wrote quite a while ago.</p>
<p>We all know that the Linux command <code>free(1)</code> is pretty useless inside an OpenVZ VE, even those with meminfo virtualised. So I basically wrote this little util to grab the data from the dreadful <code>user_beancounters</code> and format them into something useful. It&#8217;s written in C and only depends on libc so it&#8217;s pretty light weight. It also does a little bit of analysis instead of just dumping the data, which I will explain later on.</p>
<p><span id="more-172"></span></p>
<h3 id="toc-download-and-install">Download and Install</h3>
<p>It should be pretty straight forward.</p>
<ul>
<li>Download <a href="http://hostingfu.com/files/vzfree/vzfree-0.1.tgz">vzfree-0.1.tgz</a> (1.5kb)</li>
<li>Unpack the tarball and change into the directory</li>
<li>Type &#8220;<code>make &amp;&amp; sudo make install</code>&#8220;</li>
</ul>
<p>The binary should then be installed to <code>/usr/local/bin/vzfree</code>. Note that as bean counters file is only readable by root in OpenVZ, you need to either (1) run <code>vzfree</code> as root, or (2) <code>chmod u+s vzfree</code>. Just a disclaimer &#8212; I am a rusty C coder and I am distributing this program <b>as it is</b>. No warranty. I am certainly not responsible if this simple program somehow got exploited and let h4x0rs pwn3d your VPS :)</p>
<h3 id="toc-usage">Usage</h3>
<p>I am running <code>vzfree</code> on my VPSLink VPS (256MB OpenVZ).</p>
<pre class="code">
<b># vzfree</b>
             Total     Used     Free
Kernel:     49.83M    3.57M   46.26M
Allocate:  250.00M  103.91M  146.09M (256M Guaranteed)
Commit:    147.93M   53.07M   94.86M (47.6% of Allocated)
Swap:                 0.03M          (0.1% of Committed)
</pre>
<p>So how do they make sense?</p>
<ul>
<li>
<p><b>Kernel</b> is the &#8220;unswappable memory allocated by the operating system kernel&#8221;. Each process will continue a bit of kernel memory.</p>
</li>
<li>
<p><b>Allocate</b> shows the maximum amount that your processes can allocate (via <code>malloc(3)</code> calls, i.e. the <em>burstable memory</em>), and how much has already been allocated. It also shows the guaranteed amount (i.e. the <em>guaranteed memory</em>).</p>
<p>You can see that on VPSLink, the burstable amount is actually less than the guaranteed amount and it&#8217;s a <em>feature</em> instead of a bug according to them to prevent overselling.</p>
</li>
<li>
<p><b>Commit</b> shows the actual memory pages that have been <em>used</em>. On Linux it&#8217;s possible to over-commit your memory as what you have allocated might not be the same as what you have used. I have <a href="http://hostingfu.com/article/xen-or-openvz">discussed them here</a>, and the amount under &#8220;Used&#8221; is the sum of physical pages + swapped pages.</p>
<p>The amount under &#8220;Total&#8221; is actually the out-of-memory kill guarantee, i.e. if the host node is running out of memory, processes in your VE <em>might</em> be killed if Used &gt; Total. In fact it is possible to commit more pages than OOM kill guarantee (so &#8220;Free&#8221; actually becomes negative). Watch out for that if you are on a server that&#8217;s massively oversold.</p>
<p>The last number also shows the ratio between &#8220;allocated&#8221; and &#8220;committed&#8221;. You&#8217;ll find this number very low if you are running apps such as Java, MySQL, etc who allocate big chunks of memory but don&#8217;t use all of them at once.</p>
</li>
<li>
<p><b>Swap</b> is my guess on how many pages have been swapped on the physical node. Bean counts tell you how many RAM pages are used so it should be possible to work out the proximity of swap from other values. If the percentage of committed memory have been swapped is high, then you know your host is overselling.</p>
</li>
</ul>
<p>Hopefully this little util is making more sense out of memory information from the bean counters.</p>
]]></content:encoded>
			<wfw:commentRss>http://hostingfu.com/article/vzfree-checking-memory-usage-inside-openvz-ve/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
