The RAM API allows you to fetch details about the RAM of the server, by passing the server ID. The details consists of the amount of Physical RAM used, amount SWAP RAM being used, the total limit of the RAM as well the SWAP RAM and how much of it is available.
HTTP Request
https://hostname:4085/index.php?act=manageserver&changeserid=SERVERID
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | ram | Returns the RAM usage of the server | Yes |
changeserid | GET | Int | The ID of the server whose RAM info is needed, default value is zero | No |
Sample Code
<?php
require_once('/usr/local/virtualizor/sdk/admin.php');
$key = 'your_api_key';
$pass = 'your_api_pass';
$ip = 'your_server_ip';
$admin = new Virtualizor_Admin_API($ip, $key, $pass);
$serverid = 0;
$output = $admin->ram($serverid);
print_r(json_encode($output));
?>
Output
{
"used": 808,
"limit": 1989,
"swap": 1999,
"swap_used": 1,
"free": 1181,
"swap_free": 1998,
"percent": 40.62,
"percent_free": 59.38
}