Self Help Documentation
server/listresourceusage
Description
Lists server resource usage of all created SPanel user accounts for a given date.
Parameters
Additional parameters:
Field | Type | Required | Description |
---|---|---|---|
token | string | Yes | Authorizing API token – check API Basics for more information. |
action | string | Yes | The category and function being executed. |
username | string | No | Existing SPanel user to request data for. |
type | string | No | Type of data requested. Accepted values: “daily”, “weekly” or “monthly”. Defaults to “daily”. |
date | string | No | Date to look resource usage for, applicabe for “daily” type. Defaults to today’s date. Format: d.m.Y. |
week | string | No | Required if “type” is set to “weekly”. Week number to look data for. |
year | string | No | Required if “type” is set to “weekly” or “monthly”. Year to look data for. |
month | string | No | Required if “type” is set to “monthly”. Format: 1 to 12. Month to look data for. |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
$endpointUrl = 'https://123.123.123.123/spanel/api.php'; $postData = [ 'token' => 'provided_auth_token', // Check API Basics for more information 'action' => 'server/listresourceusage', //'username' => 'spanelio', //'date' => '1.3.2022', //1st of March 2022 //'type' => 'daily', //Possible values: daily, weekly, monthly //'week' => '34', //Number of week to look data for //'year' => '2024', //Year to look data for - only for "weekly" or "monthly" type. //'month' => '12' //Month to look data for (1 - 12). Required if "type" is set to "monthly" ]; $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $endpointUrl); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt( $ch, CURLOPT_POST, true); curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($postData)); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false); $jsonOutput = curl_exec( $ch ); |
Output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
{ "result": "success", "data": [ "userstats": { "label": "01", //This is the hourly data in this example "cpuusage": 3.05, "ramusage": 1.22 }, { "label": "02", "cpuusage": 2.14, "ramusage": 0.82 }, "topprocesses": { "username": "spanelio", "cpuusage": 0, "ramusage": 1, "cpulimithits": 0, "ramlimithits": 0, "maxcpulimit": 80, "maxramlimit": 768, "processname": "PHP" } ], "maxcpulimit": 0, "maxramlimit": 0 } |