Editing Setting UBC parameters
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | {{ | + | {{UBC toc}} |
[http://forum.swsoft.com/showthread.php?threadid=26770 This thread] has been summarized here on this page. | [http://forum.swsoft.com/showthread.php?threadid=26770 This thread] has been summarized here on this page. | ||
Line 20: | Line 20: | ||
vmguarpages 0 0 125000 2147483647 0 | vmguarpages 0 0 125000 2147483647 0 | ||
oomguarpages 59239 59367 125000 2147483647 0 | oomguarpages 59239 59367 125000 2147483647 0 | ||
− | numtcpsock 37 38 440 440 0 | + | numtcpsock 37 38 440 440 0 begin_of_the_skype_highlighting 37 38 440 440 0 end_of_the_skype_highlighting |
numflock 3 3 704 704 0 | numflock 3 3 704 704 0 | ||
numpty 1 1 44 44 0 | numpty 1 1 44 44 0 | ||
Line 113: | Line 113: | ||
We don't have such script but you can just take a look at the last column of /proc/user_beancounters. Nonzero values there mean that resource allocations were rejected. | We don't have such script but you can just take a look at the last column of /proc/user_beancounters. Nonzero values there mean that resource allocations were rejected. | ||
− | + | Thank you for everything, unfortunately the only way I have to help is to work with code, I leave something here that I hope you will enjoy and seet very usefully. | |
− | Thank you for everything, unfortunately the only way I have to help is to work with code, | ||
− | I leave something here that I hope you will enjoy and | ||
− | |||
− | |||
<pre> | <pre> | ||
#!/bin/bash | #!/bin/bash | ||
# Openvz Containers Memory Status | # Openvz Containers Memory Status | ||
− | # Version | + | # Version 0.6 |
# Reference: http://wiki.openvz.org/Setting_UBC_parameters | # Reference: http://wiki.openvz.org/Setting_UBC_parameters | ||
Line 127: | Line 123: | ||
# Author: Roberto Blandino Cisneros. | # Author: Roberto Blandino Cisneros. | ||
# Under any change please notify me | # Under any change please notify me | ||
− | # rojoblandino | + | # rojoblandino@yahoo.com |
+ | |||
− | # Advantages | + | # Advantages: |
# 1) Calculation of vz containers. | # 1) Calculation of vz containers. | ||
# 2) Percentage Calculation. | # 2) Percentage Calculation. | ||
− | # 3) Avoid | + | # 3) Avoid a char and offset entry. |
− | |||
− | |||
− | |||
# The usage of this script is easy. | # The usage of this script is easy. | ||
Line 155: | Line 149: | ||
# First thing to do is to get the list of containers | # First thing to do is to get the list of containers | ||
− | vzn= | + | vzn=`vzlist | wc -l` |
+ | # Save the output into a var and erase the first | ||
+ | # garbage line by subtracting 1. | ||
+ | let $n "n=vzn-1" | ||
case $# in | case $# in | ||
1) | 1) | ||
− | # | + | # We get the container to be calculated |
− | + | vm=$1 | |
− | |||
# Just avoiding our human error | # Just avoiding our human error | ||
− | datachk= | + | datachk=`echo $vm | grep -e [a-z] | wc -l` |
if let "datachk>0";then | if let "datachk>0";then | ||
− | + | echo "That's not a valid number!" | |
exit | exit | ||
fi | fi | ||
− | + | # Avoiding another mistake maybe we forgot the quantity of our containers | |
− | # Avoiding another mistake maybe | + | if let "vm>n";then |
− | if let " | + | echo "Container out of range, please try a number between 1 and "$n |
− | |||
exit | exit | ||
− | |||
− | |||
− | |||
fi | fi | ||
− | + | # Calculating lines to be jump from the output of user_bancounters. | |
− | # | + | # Becuase there is a first garbage line i need 26 spaces from the |
− | # | + | # beginning, then i need to show the last 24. |
− | + | # (n-vm) because i do not want to see it bacward if you want to change the | |
− | + | # order switch the comment with the following line: | |
− | + | # let $val "val=26+(24*vm)" | |
− | # | + | let $val "val=26+(24*(n-vm))" |
− | # | ||
− | |||
− | # | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | let $val "val= | ||
# If you want to see all values of the vm uncomment this | # If you want to see all values of the vm uncomment this | ||
− | #head -$val /proc/user_beancounters | tail -24 | + | #head -$val /proc/user_beancounters | tail -24 |
# The math start here. | # The math start here. | ||
Line 202: | Line 184: | ||
# you must read carefully the page http://wiki.openvz.org/Setting_UBC_parameters | # you must read carefully the page http://wiki.openvz.org/Setting_UBC_parameters | ||
# the only thing i do was to get the values explained already there. | # the only thing i do was to get the values explained already there. | ||
− | kmemsize= | + | kmemsize=`head -$val /proc/user_beancounters | tail -24 | head -1 | tail -1 | awk '{print $3}'` |
− | oomguarpages= | + | oomguarpages=`head -$val /proc/user_beancounters | tail -24 | head -9 | tail -1 | awk '{print $2}'` |
− | tcpsndbuf= | + | tcpsndbuf=`head -$val /proc/user_beancounters | tail -24 | head -14 | tail -1 | awk '{print $2}'` |
− | tcprcvbuf= | + | tcprcvbuf=`head -$val /proc/user_beancounters | tail -24 | head -15 | tail -1 | awk '{print $2}'` |
− | othersockbuf= | + | othersockbuf=`head -$val /proc/user_beancounters | tail -24 | head -16 | tail -1 | awk '{print $2}'` |
− | dgramrcvbuf= | + | dgramrcvbuf=`head -$val /proc/user_beancounters | tail -24 | head -17 | tail -1 | awk '{print $2}'` |
− | oomguarpages_barrier= | + | oomguarpages_barrier=`head -$val /proc/user_beancounters | tail -24 | head -9 | tail -1 | awk '{print $4}'` |
− | # | + | # We need to calculate three current values: |
# oomguarpages current value (MEM+SWAP actual usage) | # oomguarpages current value (MEM+SWAP actual usage) | ||
# socket buffers current value | # socket buffers current value | ||
− | # | + | # socket buffers current value |
let $resp "resp=((oomguarpages*4096)+tcpsndbuf+tcprcvbuf+othersockbuf+dgramrcvbuf+kmemsize)" | let $resp "resp=((oomguarpages*4096)+tcpsndbuf+tcprcvbuf+othersockbuf+dgramrcvbuf+kmemsize)" | ||
− | # | + | # We need to calculate the oom Barrier |
let $oom "oom=(oomguarpages_barrier*4096)" | let $oom "oom=(oomguarpages_barrier*4096)" | ||
− | |||
# Getting the percentage of the output | # Getting the percentage of the output | ||
let $porc "porc=(resp*100)/oom" | let $porc "porc=(resp*100)/oom" | ||
− | # | + | # We show the container ID and Percentage |
− | + | echo `head -$val /proc/user_beancounters | tail -24| head -1 | awk -F: '{print $1}'`" Status: "$porc"%" | |
− | + | # We show the two important values. | |
+ | echo -e "System Count:\t-\tOOM Barrier:" | ||
+ | echo -e $resp"\t-\t"$oom | ||
− | + | # Uncoment this if you just want to now if is below to barrier | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | # Uncoment this if you just want to now if | ||
# it means is healthy if resp is less than oom | # it means is healthy if resp is less than oom | ||
# if let "resp<oom";then | # if let "resp<oom";then | ||
Line 268: | Line 228: | ||
</pre> | </pre> | ||
− | === Can you please elaborate the difference between oomguarpages and privvmpages? === | + | === Can you please elaborate the difference between oomguarpages and privvmpages?=== |
− | + | Both seem to be showing mem + swap. Is the difference between two about allocated but not used pages? I mean, privvmpages show allocated (some of which might not be used) for mem + swap, whereas oomguarpages show allocated, all of which are used, mem + swap? ==== | |
− | Both seem to be showing mem + swap. Is the difference between two about allocated but not used pages? I mean, privvmpages show allocated (some of which might not be used) for mem + swap, whereas oomguarpages show allocated, all of which are used, mem + swap? | ||
− | |||
==== Answer: ==== | ==== Answer: ==== | ||
Yes, oomguarpages current value shows actual usage of MEM+SWAP. | Yes, oomguarpages current value shows actual usage of MEM+SWAP. |