Какой рейтинг вас больше интересует?
|
vzubc v.22011-05-20 14:21:39 (читать в оригинале)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: #!/bin/sh f=${1:-/proc/user_beancounters} cat $f | LANG=C awk ' function hr(res, v) { if ((v == 9223372036854775807) || (v == 2147483647) || (v == 0)) return "- "; i=1 if ((res ~ /pages$/) && (v != 0)) { v = v*4; i++ } while (v >= 1024) { v=v/1024 i++ } fmt="%d%c" if (v < 100) fmt="%.3g%c" return sprintf(fmt, v, substr(" KMGTPEZY", i, 1)) } function dp(p, d) { if ((d == 0) || (d == 9223372036854775807) || (d == 2147483647)) return "- " r = sprintf("%.2f", p / d * 100); fmt="%d" if (r < 10) fmt="%.2g" r = sprintf(fmt, r) if (r == 0) return "- " return r "%" } /^Version: / { if ($2 != "2.5") { print "Error: unknown version:", $2 > "/dev/stderr" exit 1 } next } /^[[:space:]]*uid / { next } /^[[:space:]]*dummy/ { id="" next } /^[[:space:]]*[0-9]+:/ { bcid=strtonum($1) printf "-------------------------------------------------------------------\n" printf "CT %-10s| HELD Bar%% Lim%%| MAXH Bar%% Lim%%| BAR | LIM | FAIL\n", bcid printf "-------------+-----------------+-----------------+-----+-----+-----\n" id=$2 held=$3 maxheld=$4 barrier=$5 limit=$6 failcnt=$7 } /^[[:space:]]*[a-z]+/ { id=$1 held=$2 maxheld=$3 barrier=$4 limit=$5 failcnt=$6 } (id!="") { printf "%13s|%5s %5s %5s|%5s %5s %5s|%5s|%5s| %5s\n", id, hr(id, held), dp(held, barrier), dp(held, limit), hr(id, maxheld), dp(maxheld, barrier), dp(maxheld, limit), hr(id, barrier), hr(id, limit), hr(id, failcnt) id="" } ' 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| - - - | - - - | - | - | -
|
Категория «Игры»
Взлеты Топ 5
Падения Топ 5
Популярные за сутки
|
Загрузка...
BlogRider.ru не имеет отношения к публикуемым в записях блогов материалам. Все записи
взяты из открытых общедоступных источников и являются собственностью их авторов.
взяты из открытых общедоступных источников и являются собственностью их авторов.