Managing LVE via command line – lvectl

lvectl command – CloudLinux

Here, in this topic, I’m going to explain the basic usages of “lvectl” command. lvectl is the primary tool for LVE management. To manage this tool you must have the root privilege to your server. lvectl is a part of lve-utils package.

We already discussed the basics of CloudLinux and its administrations. CloudLinux is a Linux based Operating system especially used in a shared environment which isolates each user in its own light weight virtualized environemnts (LVE) which consumes predefined amount of resources allocated for each user.

That is, each user will be in a caged environment. The resource usage of any user won’t affect the stability of another users.

CloudLinux installation guide

Check the category CloudLinux for more related articles on this technology.

Here I’m explaining how we can manage LVE for a user from command line. The command “lvectl” is used for this purpose.

Syntax

lvectl command [lveid] [options]

Please see the available options with “lvectl” command:

apply : apply config settings to specified LVE
apply all : apply config settings to all the LVEs
apply-many : to apply LVE limits to multiple distinct LVEs (uids of users are read from stdin)
set : set parameters for a LVE and/or create a LVE
set-user : set parameters for a LVE and/or create a LVE using username instead of ID
list : list loaded LVEs
list-user : list loaded LVEs, display username instead of user id
limits : show limits for loaded LVEs
delete : delete LVE and set configuration for that LVE to defaults
delete-user : delete LVE and set configuration for that user to defaults
destroy : destroy LVE (configuration file remains unchanged)
destroy all : destroy all LVE (configuration file remains unchanged)
destroy-many : to destroy LVE limits to multiple distinct LVEs (uids of users are read from stdin)
package-set : set LVE parameters for a package
package-list : list LVE parameters for packages
package-delete : delete LVE parameters for a package
paneluserslimits : show current user's limits for control panel
limit : limit PID into specified LVE. Parameters PID LVE_ID
release : release PID from LVE. Parameters PID
set-binary : add binary to be run inside LVE on execution
del-binary : remove binary from being run inside LVE on execution
list-binaries : list all binaries to be run inside LVE on execution
load-binaries : load binaries (used on startup) from config file
reload-binaries : re-load list of binaries from config file
help (-h) : show this message
version (-v) : version number.
lve-version : LVE version number

Options

--cpu=N : limit CPU usage; (deprecated. Use --speed)
--speed=N% : limit CPU usage in percentage; 100% is one core
--speed=Nmhz\ghz : limit CPU usage in mhz\ghz
--ncpu=N : limit VCPU usage (deprecated)
--io=N : define io limits (KB/s)
--nproc=N : limit number of processes
--pmem=N : limit physical memory usage for aplications inside LVE
--iops=N : limit io per second
--mem=N : mem alias for vmem (deprecated)
--vmem=N : limit virtual memory for applications inside LVE
--maxEntryProcs=N : limit number of entry processes
--save : save configuration settings (use with set) (deprecated)
--save-all-parameters : save all parameters even if they match with defaults settings
--json : returns result of command json formatted
--unlimited : set all limits to unlimited
--save-username : save username in the config file. This parameter is used in conjunction with set-user

Here I’m showing some examples

Q. Where is the default settings (configuration) located for LVE?

That’s the first question. The default configuration file is “/etc/container/ve.cfg” Here we add the default values of different LVEs.

Q. How to show list of LVEs and their limits?

Here we can use the “list” and “list-user” option with the command lvectl to list LVE limits of users. Please see the examples:

# lvectl list|more

      ID   SPEED    NCPU    PMEM    VMEM      EP   NPROC      IO    IOPS
 default     100       1    2.0G      0K      20       0    4096    1024
       1     100       1    2.0G      0K      20       0    4096    1024
       3    4800      48    2.0G      0K      20       0       0    1024
      99     100       1    2.0G      0K      20       0    4096    1024
     501     100       1    2.0G      0K      20       0    4096    1024
     502     100       1    2.0G      0K      20       0    4096    1024
     503     100       1    2.0G      0K      20       0    4096    1024
     504     100       1    2.0G      0K      20       0    4096    1024
     505     100       1    2.0G      0K      20       0    4096    1024
# lvectl list-user|more
      ID   SPEED    NCPU    PMEM    VMEM      EP   NPROC      IO    IOPS
 default     100       1    2.0G      0K      20       0    4096    1024
   bindd     100       1    2.0G      0K      20       0    4096    1024
   admdf    4800      48    2.0G      0K      20       0       0    1024
  nobody     100       1    2.0G      0K      20       0    4096    1024
aadddder     100       1    2.0G      0K      20       0    4096    1024
 aseeeer     100       1    2.0G      0K      20       0    4096    1024
  beeee8     100       1    2.0G      0K      20       0    4096    1024

The list-user option shows username instead of user id.

Q. How to manage LVE limits (cpu, ncpu, io, nproc, pmem, vmem and entry processes) for different users?

We can use set and set-user options to set values to LVE. Consider the scenario, if we want to set all LVE limits of the user “crybit” to unlimited, you can use the following command:

# lvectl set-user crybit --unlimited

If you’re using the “set” option please use the LVE id instead of user name. You can use the “id” command to find out the LVE id.

id $username

Q. How to manage CPU limit?

The option “–speed=N%” is used to manage the CPU speed allocated for a LVE. Please see an example:

List current LVE limits for user crybit

# lvectl list-user|grep crybit
crybit     100       1    1.0G    1.0G      20     100    1024    1024

To reduce CPU speed by 50%

# lvectl set-user crybit --speed=50%
# lvectl list-user|grep crybit
crybit      50       1    1.0G    1.0G      20     100    1024    1024

See the CPU limit reduced to 50 for the user Crybit.

Q. Managing memory limit for LVE?

Here we can use “–pmem=” to manage memory allocation for LVEs.

Please see the example:

# lvectl set-user crybit --pmem=512
# lvectl list-user|grep crybit
crybit      50       1    512K    1.0G      20     100    1024    1024

Likewise, you can manage different LVE parameters using the options –ncpu=N, –io=N, –pmem=N etc..

Q. How to change default setting?

To change the default configuration, please use the following command:

# lvectl set default --speed=100% --pmem=256m

Q. How to reset all LVEs settings based on configuration in /etc/container/ve.cfg?

# lvectl apply all

Q. How to reset all LVE’s killing processes inside them?

# lvectl destroy all

Q. Quick command to list the LVE limits of a particular user (ID)?

Yeah, we already mention how to list the LVE limits of a particular user by using the list-user switch. It’s a simple way to list out the current LVE of a user. First you need to find out the ID of that user using id command.

# id crybit
uid=563(crybit) gid=574(crybit) groups=574(crybit)

563 is the ID of user crybit.

Execute the following command:

# lvectl limits 563
ID    SPEED    NCPU    PMEM    VMEM   EP   NPROC   IO    IOPS
563  100          1    2.0G    0 K    20   0       4096  1024

Cool.. Post a reply if you’ve any questions.

Arunlal Ashok

Sr. Linux Server Administrator. I'm managing Linux servers since 2012. I started this blog to share and discuss my ideas. Check My Profile in uPwork (oDesk) and create a job, if you need any administration help. Thanks!!

You may also like...

4 Responses

  1. check says:

    lvectl limits 500
    ID SPEED NCPU PMEM VMEM EP NPROC IO IOPS
    500 100 1 1.0G 0K 20 100 1024 1024

  2. James says:

    how to reset CPU Usage using command

    • This can be simply managed by using the switch “set-user.”

      Example

      Default : 100 %

      root@vps.crybit.com [~]# lvectl --list-user |grep 
       natalie     100       1    2.0G      0K      40       0    4096    102
      

      Setting new value

      root@vps.crybit.com [~]# lvectl set-user natalie --speed=75%
      root@vps.crybit.com[~]#
      
      
      root@vps.crybit.com [~]# lvectl --list-user |grep natalie
       natalie      75       1    2.0G      0K      40       0    4096    1024
      

Leave a Reply

Your email address will not be published. Required fields are marked *