buy
Resource Limits

Description

Manage cGroups v2–based Resource Limit Plans for users via the Webuzo API. You can create, edit, delete, assign, and remove resource limit plans directly from the server.

Create Resource Limit Plan

Parameters

Sample Code

curl --insecure -u "username:password" -d "save=1" -d "plan=plan_name" -d "cpuquota=50" -d "read_bw=1G" -d "write_bw=1G" -d "diskread=1000" -d "diskwrite=1000" -d "mem_max=1G" -d "memhigh=800M" -d "maxtask=100" -X POST "https://Server-IP:2005/index.php?api=json&act=resource_limits"
<?php
$user = 'your_user';
$pass = 'your_password';
$ip = 'your_ip';
 
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$ip.':2005/index.php?api=json&act=resource_limits';

$post = [
    'save' => '1',
    'plan' => 'basic_plan',
    'cpuquota' => '50',
    'read_bw' => '1G',
    'write_bw' => '1G',
    'diskread' => '1000',
    'diskwrite' => '1000',
    'mem_max' => '1G',
    'memhigh' => '800M',
    'maxtask' => '100'
];

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);

// The response will hold a string as per the API response method. In this case its PHP JSON
$res = json_decode($resp, true);

// Done ?
if(!empty($res['done'])){
	print_r($res['done']);
// Error
}else{
	print_r($res['error']);
}

Output

Array ( [msg] => Resource limits successfully saved )

Edit Resource Limit Plan

Parameters

Sample Code

curl --insecure -u "username:password" -d "save=1" -d "plan=new_plan_name" -d "edit=plan_name" -d "cpuquota=75" -d "mem_max=2G" -d "memhigh=1500M" -X POST "https://Server-IP:2005/index.php?api=json&act=resource_limits"
<?php
$user = 'your_user';
$pass = 'your_password';
$ip = 'your_ip';
 
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$ip.':2005/index.php?api=json&act=resource_limits';

$post = [
    'save'     => '1',
    'plan'     => 'new_plan_name',
    'edit'     => 'basic_plan',
    'cpuquota' => '75',
    'mem_max'  => '2G',
    'memhigh'  => '1500M'
];

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);

// The response will hold a string as per the API response method. In this case its PHP JSON
$res = json_decode($resp, true);

// Done ?
if(!empty($res['done'])){
	print_r($res['done']);
// Error
}else{
	print_r($res['error']);
}

Output

Array ( [msg] => Resource limits successfully saved )

Delete Resource Limit Plan

Parameters

Sample Code

curl --insecure -u "username:password" -d "delete=plan_name" -X POST "https://Server-IP:2005/index.php?api=json&act=resource_limits"
<?php
$user = 'your_user';
$pass = 'your_password';
$ip = 'your_ip';
 
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$ip.':2005/index.php?api=json&act=resource_limits';

$post = [
    'delete' => 'basic_plan'
];

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);

// The response will hold a string as per the API response method. In this case its PHP JSON
$res = json_decode($resp, true);

// Done ?
if(!empty($res['done'])){
	print_r($res['done']);
// Error
}else{
	print_r($res['error']);
}

Output

Array ( [msg] => Resource Limit Plan deleted successfully )

Assign Plan to Users

Parameters

Sample Code

curl --insecure -u "username:password" -d "assign_plan=1" -d "plan=plan_name" -d "users[]=user1" -d "users[]=user2" -X POST "https://Server-IP:2005/index.php?api=json&act=resource_limits"
<?php
$user = 'your_user';
$pass = 'your_password';
$ip = 'your_ip';
 
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$ip.':2005/index.php?api=json&act=resource_limits';

$post = [
    'assign_plan' => '1',
    'plan'        => 'plan_name',
    'users'       => ['user1', 'user2']
];

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);

// The response will hold a string as per the API response method. In this case its PHP JSON
$res = json_decode($resp, true);

// Done ?
if(!empty($res['done'])){
	print_r($res['done']);
// Error
}else{
	print_r($res['error']);
}

Output

Array ( [msg] => Plan assigned to users successfully )

Assign Plan to All Users

Parameters

Sample Code

curl --insecure -u "username:password" -d "assign_plan=1" -d "plan=plan_name" -d "allusers=true" -X POST "https://Server-IP:2005/index.php?api=json&act=resource_limits"
<?php
$user = 'your_user';
$pass = 'your_password';
$ip = 'your_ip';
 
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$ip.':2005/index.php?api=json&act=resource_limits';

$post = [
    'assign_plan' => '1',
    'plan'        => 'plan_name',
    'allusers'    => 'true'
];

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);

// The response will hold a string as per the API response method. In this case its PHP JSON
$res = json_decode($resp, true);

// Done ?
if(!empty($res['done'])){
	print_r($res['done']);
// Error
}else{
	print_r($res['error']);
}

Output

Array ( [msg] => Plan assigned to users successfully )

Remove Plan from User

Parameters

Sample Code

curl --insecure -u "username:password" -d "remove_user=1" -d "user=user1" -d "plan=plan_name" -X POST "https://Server-IP:2005/index.php?api=json&act=resource_limits"
<?php
$user = 'your_user';
$pass = 'your_password';
$ip = 'your_ip';
 
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$ip.':2005/index.php?api=json&act=resource_limits';

$post = [
    'remove_user' => '1',
    'user'        => 'user1',
    'plan'        => 'plan_name'
];

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);

// The response will hold a string as per the API response method. In this case its PHP JSON
$res = json_decode($resp, true);

// Done ?
if(!empty($res['done'])){
	print_r($res['done']);
// Error
}else{
	print_r($res['error']);
}

Output

Array ( [msg] => Plan successfully removed from the user )
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list