Here you will find the instructions and common techniques used to integrate your software with CloudLinux.
Detecting and Working with CloudLinux .
Displaying CPU, Memory & IO limits.
Integrating LVE Limits with Packages.
Detecting if system is running CloudLinux/CloudLinux kernel:
$ uname -r|grep lve
If you get an output, it means the system is running CloudLinux kernel. CloudLinux kernels have lve in its name, like: 2.6.32-458.18.1.lve1.2.44.el6.x86_64
Alternatively you can check for the presence of /proc/lve/list file.
Check if CageFS is enabled (as root ):
$ /usr/sbin/cagefsctl --cagefs-status
Check if CageFS is enabled for a particular user (as root ):
$ /usr/sbin/cagefsctl --user-status _USER_NAME_
Check if you are inside CageFS:
Check for the presence of /var/.cagefs/.cagefs.token file - if present, it means that you are inside CageFS.
Most control panels choose to display CloudLinux usage & limits to end customers. To simplify that, we lve-stats exports a file that can be easily read and processed by a control panel to display the necessary information.
The information is located in the /var/lve/info file. This information is updated every 5 minutes, and contains default limits (first line), as well as usage and limits for all customers. If a customer is not present in the file, it means that customer is not active (no scripts were executed recently for the customer), and a customer has default limits (so you can display no usage, and default limits in the control panel for that customer.
The data is stored in a form of one line per customer, with coma separated values.
| 0 | user id |
| 1 | entry processes |
| 2 | entry processes limit |
| 3 | CPU |
| 4 | CPU limit |
| 5 | Virtual Memory |
| 6 | Virtual Memory Limit |
| 7 | Number of virtual memory faults |
| 8 | Number of entry processes faults |
| 9 | Physical Memory Limit |
| 10 | Physical Memory |
| 11 | Number of Physical memory faults |
| 12 | Number of processes limit |
| 13 | Number of processes |
| 14 | Number of processes fault |
| 15 | Reserved |
| 16 | IO Usage |
| 17 | IO Limit |
With LVE version 4 (CloudLinux lve0.x) only the first 9 parameters are available. You can check the the version by reading the first byte of /proc/lve/list.
In the version 6 all 15 parameters should be available.
There are only 2 LVE versions currently used in production. Future versions might add more fields, but will not alter order of existing fields.
Memory is defined in 4KB pages (so, 1024 would mean 1024 4KB pages, or 4MB).
IO is defined as KB/s.
CPU is defined as % of total number of cores on a server.
[lve-utils 1.4+]
CloudLinux can automatically detect the most popular control panels, like cPanel - and allows to set different limits for users in different packages. It simplifies management as you don't have to choose between one limit that fits all your customers on the server, or individual limits for the customers.
If you have a custom made control panel, with your own 'package' implementation, you can still use CloudLinux framework to manage limits for your packages.
To do that, you would need:
Implement script that would map users to packages.
Configure lvectl to use your script.
Implementing script
A script can be written in any language, and it has to be executable.
It should accept the following arguments:
--list-all prints [userid package] pairs
Output should look like a list of space separate pairs of user Linux IDs and package names.
100 package1
101 package1
102 package2
103 package3
--userid=id prints package for a user specified
Output should contain package name, like:
package1
--package="package" prints users for a package specified.
Output should look like a list of user Linux IDs.
100
101
--list-packages prints the list of packages
Output contains a list of names of packages, like:
package1
package2
package3
Configuring lvectl to use your custom script
Edit /etc/sysconfig/cloudlinux file.
Edit or modify parameter CUSTOM_GETPACKAGE_SCRIPT, and set it to point to your script, like: CUSTOM_GETPACKAGE_SCRIPT=/absolute/path/to/your/script
For the script example please check the following article: https://cloudlinux.zendesk.com/hc/en-us/articles/115004529105-Integrating-LVE-limits-with-packages-for-unsupported-control-panels