On 10/03/2013 12:03 PM, Mark J. wrote:
On Thu, Oct 03, 2013 at 10:41:41AM -0700, Kir Kolyshkin wrote:
Also, I wonder how much RAM do you have on your server, and how
many such containers do you run on it?
Nodes have 32G on them, this particular node only allows up to 40 vm's due to
the cPanel vm's having either 2, 3, or 4G depending on the plan.
This is severe oversell -- you have 32G but sell that as 80 to 160G.
At the very least you have to have an adequate amount of swap
on the node -- so that RAM+swap on the node should be more
than sum of all RAM and SWAP for all containers. Currently there
is no tool for that, but it's pretty easy to write such a script.
I went ahead and mocked up something. Please run the attached script on
your node
and share your results.
#!/bin/sh
ram=$(awk '/^MemTotal:/ {print $2/4}' < /proc/meminfo)
swap=$(awk '/^SwapTotal:/ {print $2/4}' < /proc/meminfo)
awk -v ram=$ram -v swap=$swap < /proc/bc/resources '
# converts a value to human-readable form
# v: value
# m: 1 if value is in 4K pages, 0 if in bytes
function hr(v, m) {
if ((v == 9223372036854775807) || (v == 2147483647) || (v == 0))
return "- ";
i=1
# translate pages to KB
if (m) {
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))
}
# hr() for pages
function hp(v) {
return hr(v, 1);
}
# hr() for bytes
function hb(v) {
return hr(v, 0);
}
function dp(p, d) {
if ((d == 0) || (d == 9223372036854775807) || (d == 2147483647))
return "- "
r = sprintf("%.1f", p / d * 100);
fmt="%d"
if (r < 10)
fmt="%.1g"
r = sprintf(fmt, r)
if (r == 0)
return "- "
return r "%"
}
function header() {
printf(" --------- RAM --------- -------- Swap ---------
Flags\n");
printf(" used peak limit fails used peak limit fails\n");
}
function footer() {
printf(" ----- ----- ----- ----- ----- ----- ----- -----\n");
printf(" TOTAL %5s %5s %5s %5s %5s %5s %5s %5s\n\n",
hp(t_ram_held), hp(t_ram_maxheld),
hp(t_ram_limit), hb(t_ram_failcnt),
hp(t_swap_held), hp(t_swap_maxheld),
hp(t_swap_limit), hb(t_swap_failcnt));
printf("RAM available: %5s allocated: %5s oversell: %s\n",
hp(ram), hp(t_ram_limit), dp(t_ram_limit, ram));
printf("Swap available: %5s allocated: %5s oversell: %s\n",
hp(swap), hp(t_swap_limit), dp(t_swap_limit, swap));
printf("RAM+Swap available: %5s allocated: %5s oversell: %s\n",
hp(ram+swap), hp(t_ram_limit+t_swap_limit),
dp(t_ram_limit+t_swap_limit, ram+swap));
}
function process_ct() {
if (bcid <= 0)
return
flags=""
if (ram_limit == 0 || ram_limit == 2147483647 || ram_limit ==
9223372036854775807) {
# Non-VSwap config!
flags="X"
# TODO: guess limit based on privvmpages / vm_overcommit
}
if (swap_failcnt > 0)
flags=flags"F"
else if (ram_failcnt < 0)
flags=flags"f"
t_ram_held += ram_held;
t_ram_maxheld += ram_maxheld;
t_ram_limit += ram_limit;
t_ram_failcnt += ram_failcnt;
t_swap_held += swap_held;
t_swap_maxheld += swap_maxheld;
t_swap_limit += swap_limit;
t_swap_failcnt += swap_failcnt;
printf("%10d %5s %5s %5s %5s %5s %5s %5s %5s %s\n",
bcid,
hp(ram_held), hp(ram_maxheld),
hp(ram_limit), hb(ram_failcnt),
hp(swap_held), hp(swap_maxheld),
hp(swap_limit), hb(swap_failcnt),
flags);
}
BEGIN {
bcid=-1
header()
}
/^Version: / {
if ($2 != "2.5") {
print "Error: unknown version:",
$2 > "/dev/stderr"
exit 1
}
next
}
/^[[:space:]]*uid / {
next
}
/^[[:space:]]*dummy/ {
next
}
/^[[:space:]]*[0-9]+:/ {
bcid=int($1)
}
/^[[:space:]]*physpages/ {
ram_held=$2
ram_maxheld=$3
ram_limit=$5
ram_failcnt=$6
}
/^[[:space:]]*swappages/ {
swap_held=$2
swap_maxheld=$3
swap_limit=$5
swap_failcnt=$6
process_ct()
}
END {
footer()
}'
_______________________________________________
Users mailing list
Users@openvz.org
https://lists.openvz.org/mailman/listinfo/users