Changes

Jump to: navigation, search

Setting UBC parameters

1,577 bytes added, 17:49, 29 September 2016
Are you aware of a script that would run as a cron job and do the OOM math on a regular basis and email me if I've hit the red zone or maybe at 85-90%?
{{UBC tocWarning|The information below is obsoleted, you should just use [[VSwap]].}}
[http://forum.swsoft.com/showthread.php?threadid=26770 This thread] has been summarized here on this page.
vmguarpages 0 0 125000 2147483647 0
oomguarpages 59239 59367 125000 2147483647 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
numpty 1 1 44 44 0
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.
<pre>Rojoblandino wrote: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 see it very usefullyusefull.And yes therewas not any script but now there is one. Greetings and have fun.</pre> 
<pre>
#!/bin/bash
# Openvz Containers Memory Status# Version 01.5
# Reference: http://wiki.openvz.org/Setting_UBC_parameters
 
# The program is placed under the GNU Public License (GPL)
# Author: Roberto Blandino Cisneros.
# Under any change please notify me# rojoblandino@(at)yahoo.com # Advantages or changes:# 1) Calculation of vz containers.# 2) Percentage Calculation.# 3) Avoid simples wrong characters and out of range entry.# 4) Use the same same order of vzlist output.# 5) Problems on vzid param mistakes fixed.# 6) Fixed when 0 passed by param an error appear
# The usage of this script is easy.
# Each container get a number if you have three
# containers e.g. eva gira huna
# Depending of the order they are ar shown in
# /proc/user_beancounters that number of position
# will be taken.
# First thing to do is to get the list of containers
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
1)
# We get Get the container to be calculated vmvm_param=$1 
# Just avoiding our human error
datachk=`$(echo $vm vm_param | grep -e [a-z] | wc -l`)
if let "datachk>0";then
echo printf "That's not a valid number!\n"
exit
fi
  # Avoiding another mistake maybe we the user forgot the quantity of our containersvm allocated if let "vmvm_param>nvzn";then echo printf "Container out of range, please try a number between 1 and %d\n" "$nvzn"
exit
elif let "vm_param==0";then
printf "This value is not available, value must be higher than 0 \n"
exit
fi
  # Calculating lines Take the real position of the container to be jump get from the output of user_bancounters.vzlist # Becuase there is a for avoiding the first garbage line i need 26 spaces we add one line more, this mean that id # will be taken from the 2nd line ahead let $vm "vm=vm_param+1"  # beginning, then i need Uncomment this and comment the line above if you want to show switch the last 24.order # let $vm "vm=(n-vm_param)+2"  # Take the id from the vzlist output id_vm=$(vzlist | head -$vm| tail -1|awk '{print $1}') because i do not want to see it bacward if you want to change the  # order switch Get the comment with line where is located the following line:vm to be calculated # let $val "val=26+$(24*vmgrep -n $id_vm /proc/user_beancounters | awk -F: '{print $1}')"  # Adding the 23 block where the info is located let $val "val=2623+(24*(n-vm)val)"
# If you want to see all values of the vm uncomment this
#cat head -$val /proc/user_beancounters | head -$val | tail -24
# The math start here.
# 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.
kmemsize=`cat $(head -$val /proc/user_beancounters | head -$val | tail -24 | head -1 | tail -1 | awk '{print $3}'`) oomguarpages=`cat $(head -$val /proc/user_beancounters | head -$val | tail -24 | head -9 | tail -1 | awk '{print $2}'`) tcpsndbuf=`cat $(head -$val /proc/user_beancounters | head -$val | tail -24 | head -14 | tail -1 | awk '{print $2}'`) tcprcvbuf=`cat $(head -$val /proc/user_beancounters | head -$val | tail -24 | head -15 | tail -1 | awk '{print $2}'`) othersockbuf=`cat $(head -$val /proc/user_beancounters | head -$val | tail -24 | head -16 | tail -1 | awk '{print $2}'`) dgramrcvbuf=`cat $(head -$val /proc/user_beancounters | head -$val | tail -24 | head -17 | tail -1 | awk '{print $2}'`) oomguarpages_barrier=`cat $(head -$val /proc/user_beancounters | head -$val | tail -24 | head -9 | tail -1 | awk '{print $4}'`)
# We Three current values need to calculate three current valuesbe calculated:
# oomguarpages current value (MEM+SWAP actual usage)
# socket buffers current value
# socket buffers kmemsize current value
let $resp "resp=((oomguarpages*4096)+tcpsndbuf+tcprcvbuf+othersockbuf+dgramrcvbuf+kmemsize)"
# We need to calculate Calculating the oom Barrier
let $oom "oom=(oomguarpages_barrier*4096)"
 
# Getting the percentage of the output
let $porc "porc=(resp*100)/oom"
# We show Showing the container ID and Percentageof the container #echo `cat $(head -$val /proc/user_beancounters | head -$val | tail -24| head -1 | awk -F: '{print $1}'`)" Status: "$porc"%" # We show the two important values. echo -e printf "System Count%s Status:%d %%\tn" "$(head -\tOOM Barrier$val /proc/user_beancounters | tail -24| head -1 | awk -F:" echo -e '{print $resp1}' | sed "s/^\t-\t*//g")" "$oomporc"
# Showing the two important values. string1="System Count:" string2="OOM Barrier:" ls1=${#string1} ls2=${#resp} if let "ls1<ls2";then let $ls3 "ls3=ls2-ls1" for (( i=0;i<$ls3;i++ ));do space_line=$space_line" " done printf "System Count:%s\t-\tOOM Barrier:\n" "$space_line" printf "%s\t-\t%s\n" "$resp" "$oom" elif let "ls1>ls2";then let $ls3 "ls3=ls1-ls2" for (( i=0;i<$ls3;i++ ));do space_line=$space_line" " done printf "System Count:\t-\tOOM Barrier:\n" printf "%s%s\t-\t%s\n" "$resp" "$space_line" "$oom" else printf "System Count:\t-\tOOM Barrier:\n" printf "%s\t-\t%s\n" "$resp" "$oom" fi # Uncoment this if you just want to now if it is below to barrier
# it means is healthy if resp is less than oom
# if let "resp<oom";then
</pre>
=== 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? ==== 
==== Answer: ====
Yes, oomguarpages current value shows actual usage of MEM+SWAP.

Navigation menu