Customizing Openvz parameters

From ISPWiki

Jump to: navigation, search

VDSmanager does not use of all the limits in Openvz, but you may avoid this restriction. You can also change the parameters that were set automatically using Events. Describe the event by creating the /usr/local/ispmgr/etc/vdsmgr_mod_resource.xml file:

 <?xml version="1.0" encoding="UTF-8"?>
    <handler name="" type="cgi">
        <event after="yes">vds.edit</event>

Create the event handler using the /usr/local/ispmgr/addon/ file

 use CGI qw/:standard/;
 $q = new CGI;
 print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<doc>\n";
 $id = $q->param("id");
 if ($q->param("sok")) {
     # set values
     $mem = $q->param("mem");
     system("/usr/sbin/vzctl set $id --oomguarpages ". $mem*1024 ." --save");
 } else {
     # get values
     # nothing to do
 print "</doc>\n";

This example will set the oomguarpages parameter based on our formula. Please note, that parameters for working with memory are set in pages, 1 page is 4096 bytes.

If you override the VMGUARPAGES parameter, you need to write the handler of the memory limit return value. Otherwise VDSmanager will calculate the memory limit using the formula:

SoftLimit(ve.GetField("VMGUARPAGES")) * 4 / 1024;

If you wish to add additional parameters into the VPS properties form, see the example on how to add your fields. Instead of the parameters in var/, you need to call vzctl set, and read the /etc/vz/conf/ID.conf file to get them.

Was this helpful? Yes | No
Personal tools