<?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/ -->
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:lj="https://www.livejournal.com">
  <id>urn:lj:livejournal.com:atom1:openvz</id>
  <title>OpenVZ</title>
  <subtitle>OpenVZ</subtitle>
  <author>
    <name>OpenVZ</name>
  </author>
  <link rel="alternate" type="text/html" href="https://openvz.livejournal.com/"/>
  <link rel="self" type="text/xml" href="https://openvz.livejournal.com/data/atom"/>
  <updated>2019-02-12T03:43:42Z</updated>
  <lj:journal userid="9392309" username="openvz" type="community"/>
  <link rel="service.feed" type="application/x.atom+xml" href="https://openvz.livejournal.com/data/atom" title="OpenVZ"/>
  <entry>
    <id>urn:lj:livejournal.com:atom1:openvz:42146</id>
    <author>
      <name>Kir Kolyshkin</name>
    </author>
    <lj:poster user="k001" userid="990679"/>
    <link rel="alternate" type="text/html" href="https://openvz.livejournal.com/42146.html"/>
    <link rel="self" type="text/xml" href="https://openvz.livejournal.com/data/atom/?itemid=42146"/>
    <title>vzubc: better cat /proc/user_beancounters</title>
    <published>2012-06-29T12:25:25Z</published>
    <updated>2019-02-12T03:43:42Z</updated>
    <category term="user beancounters"/>
    <category term="vzctl"/>
    <category term="vzubc"/>
    <category term="cli"/>
    <content type="html">Managing user beancounters is not for the faint of heart, I must say. One has to read through &lt;a href="http://wiki.openvz.org/UBC" target="_blank" rel="nofollow"&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="http://wiki.openvz.org/VSwap" target="_blank" rel="nofollow"&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="https://wiki.openvz.org/images/3/37/Vzubc-c-q-forkbomb.png" fetchpriority="high" /&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="https://wiki.openvz.org/images/9/9d/Vzubc-r-failcnt.png" loading="lazy" /&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="https://wiki.openvz.org/images/1/12/Vzubc-incremental.png" loading="lazy" /&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="https://wiki.openvz.org/Man/vzubc.8" target="_blank" rel="nofollow"&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;</content>
  </entry>
</feed>
