<?xml version='1.0' encoding='utf-8' ?>
<!--  If you are running a bot please visit this policy page outlining rules you must respect. https://www.livejournal.com/bots/  -->
<rss version='2.0'  xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:media='http://search.yahoo.com/mrss/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>OpenVZ</title>
  <link>https://openvz.livejournal.com/</link>
  <description>OpenVZ - LiveJournal.com</description>
  <lastBuildDate>Fri, 29 Jun 2012 12:25:25 GMT</lastBuildDate>
  <generator>LiveJournal / LiveJournal.com</generator>
  <lj:journal>openvz</lj:journal>
  <lj:journalid>9392309</lj:journalid>
  <lj:journaltype>community</lj:journaltype>
  <image>
    <url>https://l-userpic.livejournal.com/128680075/9392309</url>
    <title>OpenVZ</title>
    <link>https://openvz.livejournal.com/</link>
    <width>100</width>
    <height>100</height>
  </image>

  <item>
  <guid isPermaLink='true'>https://openvz.livejournal.com/42146.html</guid>
  <pubDate>Fri, 29 Jun 2012 12:25:25 GMT</pubDate>
  <title>vzubc: better cat /proc/user_beancounters</title>
  <author>k001</author>
  <link>https://openvz.livejournal.com/42146.html</link>
  <description>Managing user beancounters is not for the faint of heart, I must say. One has to read through &lt;a href=&quot;http://wiki.openvz.org/UBC&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;a lot of documentation&lt;/a&gt; and understand all this stuff pretty well. Despite the fact we have made a great improvement recently, a feature called &lt;a href=&quot;http://wiki.openvz.org/VSwap&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;VSwap&lt;/a&gt;, many people still rely on traditional beancounters.&lt;br /&gt;&lt;br /&gt;This post is about a utility I initially wrote for myself in May 2011. Surely I have added it to vzctl, it is available since vzctl 3.0.27. Simply speaking, it is just a replacement for cat /proc/user_beancounters, and of course it can do much more than cat.&lt;br /&gt;&lt;br /&gt;Here&amp;#39;s a brief list of vzubc features:&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Shows human-readable held, maxheld, barrier, limit, and fail counter for every beancounter, fitting into standard 80-columns terminal (unlike /proc/user_beancounters on an x86_64 system)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Values that are in pages (such as physpages) are converted to bytes&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Long values are then converted to kilo-, mega-, gigabytes etc, similar to -h flag for ls or df&lt;/li&gt;&lt;br /&gt;&lt;li&gt;For held and maxheld, it shows how close the value to the barrier and the limit, in per cent&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Can be used both inside CT and on HN&lt;/li&gt;&lt;br /&gt;&lt;li&gt;User can specify CTIDs or CT names to output info about specific containers only&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Optional top-like autoupdate mode (internally using &amp;quot;watch&amp;quot; utility)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Optional &amp;quot;relative failcnt&amp;quot; mode (show increase in UBC fail counters since the last run&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Optional quiet mode (only shows &amp;quot;worth to look at&amp;quot; UBCs, ie ones close to limits and/or with failcnt)&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;Now, this is how default vzubc output for a particular VE (with non-vswap configuration) looks like:&lt;br /&gt;&lt;pre&gt;
# vzubc 1009
----------------------------------------------------------------
CT 1009      | HELD Bar% Lim%| MAXH Bar% Lim%| BAR | LIM | FAIL
-------------+---------------+---------------+-----+-----+------
     kmemsize|1.52M  11%  10%|1.81M  13%  12%|13.7M|14.1M|    - 
  lockedpages|   -    -    - |   -    -    - |   8M|   8M|    - 
  privvmpages| 2.6M   1%   1%|4.32M   2%   2%| 256M| 272M|    - 
     shmpages|   -    -    - |   -    -    - |  84M|  84M|    - 
      numproc|  10    4%   4%|  15    6%   6%| 240 | 240 |    - 
    physpages|17.3M   -    - |18.6M   -    - |   - |   - |    - 
  vmguarpages|   -    -    - |   -    -    - | 132M|   - |    - 
 oomguarpages|1.52M   2%   - |1.52M   2%   - | 102M|   - |    - 
   numtcpsock|   2  0.6% 0.6%|   3  0.8% 0.8%| 360 | 360 |    - 
     numflock|   1  0.5% 0.5%|   2    1%   1%| 188 | 206 |    - 
       numpty|   -    -    - |   -    -    - |  16 |  16 |    - 
   numsiginfo|   -    -    - |   6    2%   2%| 256 | 256 |    - 
    tcpsndbuf|34.1K   2%   1%|51.1K   3%   2%|1.64M|2.58M|    - 
    tcprcvbuf|  32K   2%   1%|  48K   2%   2%|1.64M|2.58M|    - 
 othersockbuf|2.26K 0.2% 0.1%|14.6K   1% 0.7%|1.07M|   2M|    - 
  dgramrcvbuf|   -    -    - |   -    -    - | 256K| 256K|    - 
 numothersock|  44   12%  12%|  47   13%  13%| 360 | 360 |    - 
   dcachesize| 618K  18%  17%| 627K  18%  17%|3.25M|3.46M|    - 
      numfile| 114    1%   1%| 125    1%   1%|9.09K|9.09K|    - 
    numiptent|  20   15%  15%|  20   15%  15%| 128 | 128 |    - 
    swappages|   -    -    - |   -    -    - |   - |   - |    - 
----------------------------------------------------------------
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As you can see, it shows all beancounters in human-readable form. Zero or unlimited values are shown by a dash. It also shows the ratio of held and maxheld to barrier and limit, in per cent.&lt;br /&gt;&lt;br /&gt;Now, let&amp;#39;s try to explore functionality available via command-line switches.&lt;br /&gt;&lt;br /&gt;First of all, &lt;b&gt;-q or --quiet enables quiet mode&lt;/b&gt; to only show beancounters with fails and those with held/maxheld values close to limits. If vzubc --q produces empty output, that probably means you don&amp;#39;t have to worry about anything related to UBC. There are two built-in thresholds for quiet mode, one for barrier and one for limit. They can be changed to your liking using -qh and -qm options.&lt;br /&gt;&lt;br /&gt;Next, &lt;b&gt;-c or --color&lt;/b&gt; enables using colors to highlight interesting fields. In this mode &amp;quot;warnings&amp;quot; are shown in yellow, and &amp;quot;errors&amp;quot; are in red. Here a warning means a parameter close to limit (same thresholds are used as for the quiet mode), and an error means non-zero fail counter.&lt;br /&gt;&lt;br /&gt;The following screenshot demonstrates the effect of -c and -q options. I have run a forkbomb inside CT to create a resource shortage:&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://wiki.openvz.org/images/3/37/Vzubc-c-q-forkbomb.png&quot; fetchpriority=&quot;high&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Now, &lt;b&gt;-r or --relative&lt;/b&gt; is the ultimate answer to the frequently asked &amp;quot;how do I reset failcnt?&amp;quot; question. Basically it saves the current failcnt value during the first run, and shows its delta (rather than the absolute value) during the next runs. This is how it works:&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://wiki.openvz.org/images/9/9d/Vzubc-r-failcnt.png&quot; loading=&quot;lazy&quot; /&gt;&lt;br /&gt;&lt;br /&gt;There is also &lt;b&gt;-i or --incremental&lt;/b&gt; flag to activate a mode in which an additional column shows a difference in held value from the previous run, so you can see the change in usage. This option also affects quiet mode: all lines with changed held values are shown.&lt;br /&gt;&lt;br /&gt;Here&amp;#39;s a screenshot demonstrating the &amp;quot;color, relative, incremental, quiet&amp;quot; mode for vzubc:&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://wiki.openvz.org/images/1/12/Vzubc-incremental.png&quot; loading=&quot;lazy&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Finally, you can use &lt;b&gt;-w or --watch&lt;/b&gt; to enable a la top mode, to monitor beancounters. It&amp;#39;s not as powerful as top, in fact it just uses watch(1) tool to run vzubc every 2 seconds and that&amp;#39;s it. Please note that this mode is not compatible with --color, and you have to press Ctrl-C to quit. Oh, and since I am not a big fan of animated gifs, there will be no screenshot.&lt;br /&gt;&lt;br /&gt;Man page &lt;a href=&quot;https://wiki.openvz.org/Man/vzubc.8&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;vzubc(8)&lt;/a&gt; man page gives you more formal description of vzubc, including some minor options I haven&amp;#39;t described here. Enjoy.&lt;br /&gt;&lt;br /&gt;</description>
  <category>user beancounters</category>
  <category>vzctl</category>
  <category>vzubc</category>
  <category>cli</category>
  <lj:security>public</lj:security>
  <lj:poster>k001</lj:poster>
  <lj:posterid>990679</lj:posterid>
  <lj:reply-count>0</lj:reply-count>
  </item>
</channel>
</rss>
