Editing Setting UBC parameters

Jump to: navigation, search

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 121: Line 121:
 
#!/bin/bash
 
#!/bin/bash
 
# Openvz Containers Memory Status
 
# Openvz Containers Memory Status
# Version 1.5
+
# Version 1
 
# Reference: http://wiki.openvz.org/Setting_UBC_parameters
 
# Reference: http://wiki.openvz.org/Setting_UBC_parameters
  
# The program is placed under the GNU Public License (GPL)
+
# The script is placed under the GNU Public License (GPL)
 
# Author: Roberto Blandino Cisneros.
 
# Author: Roberto Blandino Cisneros.
# Under any change please notify me
+
# Under any change or develop please notify me to
# rojoblandino(at)yahoo.com
+
# rojoblandino @yahoo.com
  
 
# Advantages or changes:
 
# Advantages or changes:
Line 155: Line 155:
  
 
# First thing to do is to get the list of containers
 
# First thing to do is to get the list of containers
vzn=$(($(vzlist | wc -l)-1))
+
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
Line 163: Line 166:
  
 
         # Just avoiding our human error
 
         # Just avoiding our human error
         datachk=$(echo $vm_param | grep -e [a-z] | wc -l)
+
         datachk=`echo $vm_param | grep -e [a-z] | wc -l`
 
         if let "datachk>0";then
 
         if let "datachk>0";then
                 printf "That's not a valid number!\n"
+
                 echo "That's not a valid number!"
 
                 exit
 
                 exit
 
         fi
 
         fi
  
 
         # Avoiding another mistake maybe the user forgot the quantity of vm allocated
 
         # Avoiding another mistake maybe the user forgot the quantity of vm allocated
         if let "vm_param>vzn";then
+
         if let "vm_param>n";then
                 printf "Container out of range, please try a number between 1 and %d\n" "$vzn"
+
                 echo "Container out of range, please try a number between 1 and "$n
 
                 exit
 
                 exit
 
elif let "vm_param==0";then
 
elif let "vm_param==0";then
printf "This value is not available, value must be higher than 0 \n"
+
echo "This value is not available, value must be higher than 0"
 
exit
 
exit
 
         fi
 
         fi
Line 184: Line 187:
  
 
         # Uncomment this and comment the line above if you want to switch the order
 
         # Uncomment this and comment the line above if you want to switch the order
         # let $vm "vm=(n-vm_param)+2"
+
         #let $vm "vm=(n-vm_param)+2"
  
 
         # Take the id from the vzlist output
 
         # Take the id from the vzlist output
         id_vm=$(vzlist | head -$vm | tail -1|awk '{print $1}')
+
         id_vm=`vzlist | head -$vm | tail -1|awk '{print $1}'`
  
 
         # Get the line where is located the vm to be calculated
 
         # Get the line where is located the vm to be calculated
         val=$(grep -n $id_vm /proc/user_beancounters | awk -F: '{print $1}')
+
         val=`grep -n $id_vm /proc/user_beancounters | awk -F: '{print $1}'`
  
 
         # Adding the 23 block where the info is located
 
         # Adding the 23 block where the info is located
Line 202: Line 205:
 
         # 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=$(head -$val /proc/user_beancounters | tail -24 | head -1 | tail -1 | awk '{print $3}')
+
         kmemsize=`head -$val /proc/user_beancounters | tail -24 | head -1 | tail -1 | awk '{print $3}'`
         oomguarpages=$(head -$val /proc/user_beancounters | tail -24 | head -9 | tail -1 | awk '{print $2}')
+
         oomguarpages=`head -$val /proc/user_beancounters | tail -24 | head -9 | tail -1 | awk '{print $2}'`
         tcpsndbuf=$(head -$val /proc/user_beancounters | tail -24 | head -14 | tail -1 | awk '{print $2}')
+
         tcpsndbuf=`head -$val /proc/user_beancounters | tail -24 | head -14 | tail -1 | awk '{print $2}'`
         tcprcvbuf=$(head -$val /proc/user_beancounters  | tail -24 | head -15 | tail -1 | awk '{print $2}')
+
         tcprcvbuf=`head -$val /proc/user_beancounters  | tail -24 | head -15 | tail -1 | awk '{print $2}'`
         othersockbuf=$(head -$val /proc/user_beancounters | tail -24 | head -16 | tail -1 | awk '{print $2}')
+
         othersockbuf=`head -$val /proc/user_beancounters | tail -24 | head -16 | tail -1 | awk '{print $2}'`
         dgramrcvbuf=$(head -$val /proc/user_beancounters | tail -24 | head -17 | tail -1 | awk '{print $2}')
+
         dgramrcvbuf=`head -$val /proc/user_beancounters | tail -24 | head -17 | tail -1 | awk '{print $2}'`
         oomguarpages_barrier=$(head -$val /proc/user_beancounters | tail -24 | head -9 | tail -1 | awk '{print $4}')
+
         oomguarpages_barrier=`head -$val /proc/user_beancounters | tail -24 | head -9 | tail -1 | awk '{print $4}'`
  
 
         # Three current values need to be calculated:
 
         # Three current values need to be calculated:
Line 223: Line 226:
  
 
         # Showing the ID and Percentage of the container
 
         # Showing the ID and Percentage of the container
         #echo $(head -$val /proc/user_beancounters | tail -24| head -1 | awk -F: '{print $1}')" Status: "$porc"%"
+
         echo `head -$val /proc/user_beancounters | tail -24| head -1 | awk -F: '{print $1}'`" Status: "$porc"%"
        printf "%s Status: %d %%\n" "$(head -$val /proc/user_beancounters | tail -24| head -1 | awk -F: '{print $1}' | sed "s/^\ *//g")" "$porc"
 
  
 
         # Showing the two important values.
 
         # Showing the two important values.
         string1="System Count:"
+
         echo -e "System Count:\t-\tOOM Barrier:"
        string2="OOM Barrier:"
+
         echo -e $resp"\t-\t"$oom
        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
 
         # Uncoment this if you just want to now if it is below to barrier
 
         # it means is healthy if resp is less than oom
 
         # it means is healthy if resp is less than oom
Line 268: Line 251:
 
</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.

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Template used on this page: