May 20th, 2011

nepal

vzubc v.2

This is a second version of vzubc script. The script is written in AWK, it parses /proc/user_beancounters and tries to output it in a more human-readable format.

FEATURES:
1. Held, maxheld, barrier, limit, and fail counter are shown for every beancounter.
2. Values that are in pages are converted to bytes
3. Long values are converted to kilo-, mega-, gigabytes etc.
4. For held and maxheld it shows how close the value to the barrier and the limit, in per cent
5. Can be used both inside CT and on HN

CHANGES from v.1:
* Added barrier and limit display
* Added percentage of held/maxheld to limit (it was only for barrier)
* More proper long values display, now with decimal point if possible (similar to ls -lh)
* ASCII table like output
* Zeroes and 'unlimited' are shown as '-'

TODO:
* colors
* recognize vSwap
* use /proc/bc/*/resources if available
* quieter mode (only show values close to limits and/or with failcnt > 0)
* save failcnt and show the difference from the prev. run
* add interactive mode (top-like) using watch
* add UBC consistency check a la vzcfgvalidate (helpful for CT owner!)
* rewrite in C??

Script source:Collapse )

Example output:
-------------------------------------------------------------------
CT 60        | HELD  Bar%  Lim%| MAXH  Bar%  Lim%| BAR | LIM | FAIL
-------------+-----------------+-----------------+-----+-----+-----
     kmemsize| 933K    5%    5%|1.92M   12%   11%|15.8M|16.8M|    - 
  lockedpages|   -     -     - |   -     -     - | 128K| 128K|    - 
  privvmpages|4.15M  1.1% 0.99%|10.4M    2%    2%| 384M| 418M|    - 
     shmpages|   -     -     - |   -     -     - |  32M|  32M|    - 
      numproc|   7     5%    5%|  17    13%   13%| 130 | 130 |    - 
    physpages|2.63M    -     - |7.86M    -     - |   - |   - |    - 
  vmguarpages|   -     -     - |   -     -     - |  24M|   - |    - 
 oomguarpages|2.63M   10%    - |7.86M   32%    - |  24M|   - |    - 
   numtcpsock|   2     2%    2%|   2     2%    2%|  80 |  80 |    - 
     numflock|   2     2%  1.8%|   3     3%    2%| 100 | 110 |    - 
       numpty|   -     -     - |   -     -     - |  16 |  16 |    - 
   numsiginfo|   -     -     - |   2  0.78% 0.78%| 256 | 256 |    - 
    tcpsndbuf|   -     -     - |   -     -     - | 312K| 512K|    - 
    tcprcvbuf|   -     -     - |   -     -     - | 312K| 512K|    - 
 othersockbuf|2.27K 0.88% 0.34%|8.12K    3%  1.2%| 258K| 658K|    - 
  dgramrcvbuf|   -     -     - |8.27K    6%    6%| 129K| 129K|    - 
 numothersock|   3     3%    3%|  10    12%   12%|  80 |  80 |    - 
   dcachesize|   -     -     - |   -     -     - |   2M|   3M|    - 
      numfile| 169     2%    2%| 290     3%    3%|   8K|   8K|    - 
    numiptent|   -     -     - |   -     -     - | 128 | 128 |    - 
-------------------------------------------------------------------
CT 0         | HELD  Bar%  Lim%| MAXH  Bar%  Lim%| BAR | LIM | FAIL
-------------+-----------------+-----------------+-----+-----+-----
     kmemsize|3.69M    -     - |4.72M    -     - |   - |   - |    - 
  lockedpages|   -     -     - |29.4M    -     - |   - |   - |    - 
  privvmpages|15.7M    -     - |61.5M    -     - |   - |   - |    - 
     shmpages|2.56M    -     - |2.62M    -     - |   - |   - |    - 
      numproc|  77     -     - |  86     -     - |   - |   - |    - 
    physpages| 8.8M    -     - |16.3M    -     - |   - |   - |    - 
  vmguarpages|   -     -     - |   -     -     - |   - |   - |    - 
 oomguarpages| 8.8M    -     - |16.3M    -     - |   - |   - |    - 
   numtcpsock|   3     -     - |   5     -     - |   - |   - |    - 
     numflock|   1     -     - |   2     -     - |   - |   - |    - 
       numpty|   1     -     - |   1     -     - |   - |   - |    - 
   numsiginfo|   -     -     - |   2     -     - |   - |   - |    - 
    tcpsndbuf|81.7K    -     - |81.7K    -     - |   - |   - |    - 
    tcprcvbuf|  48K    -     - |   -     -     - |   - |   - |    - 
 othersockbuf|31.7K    -     - |50.8K    -     - |   - |   - |    - 
  dgramrcvbuf|   -     -     - |10.8K    -     - |   - |   - |    - 
 numothersock|  30     -     - |  34     -     - |   - |   - |    - 
   dcachesize|   -     -     - |   -     -     - |   - |   - |    - 
      numfile|1.18K    -     - |1.29K    -     - |   - |   - |    - 
    numiptent|   -     -     - |   -     -     - |   - |   - |    -