Monitoring API
Retrieve monitoring data for devices and services
Overview
The Monitoring API allows you to retrieve performance and monitoring data for devices and services. This includes metrics such as CPU usage, memory usage, disk I/O, network traffic, and other performance indicators.
GET Get Monitoring Data
Retrieve monitoring data for a specific device or service.
Request
{
"cmd": "monitoring.data.get",
"deviceid": 123,
"metric": "cpu",
"start": 1699123456,
"end": 1699127056,
"interval": "5m"
}
<?php
$params = http_build_query([
'cmd' => 'monitoring.data.get',
'deviceid' => 123,
'metric' => 'cpu',
'start' => 1699123456,
'end' => 1699127056,
'interval' => '5m'
]);
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?' . $params);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.get(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
params={
'cmd': 'monitoring.data.get',
'deviceid': 123,
'metric': 'cpu',
'start': 1699123456,
'end': 1699127056,
'interval': '5m'
},
headers={
'Authorization': 'Bearer YOUR_JWT_TOKEN'
}
)
data = response.json()
GET https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=monitoring.data.get&deviceid=123&metric=cpu&start=1699123456&end=1699127056&interval=5m Authorization: Bearer YOUR_JWT_TOKEN
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cmd |
string | Yes | Must be "monitoring.data.get" |
deviceid |
integer | Yes | Device ID to retrieve monitoring data for |
metric |
string | Yes | Metric type: "cpu", "memory", "disk", "network", etc. |
start |
integer | No | Start timestamp (Unix timestamp) |
end |
integer | No | End timestamp (Unix timestamp) |
interval |
string | No | Data aggregation interval (e.g., "5m", "1h", "1d") |
Response
{
"code": "OK",
"data": {
"deviceid": 123,
"metric": "cpu",
"start": 1699123456,
"end": 1699127056,
"interval": "5m",
"values": [
{
"timestamp": 1699123456,
"value": 45.2
},
{
"timestamp": 1699123756,
"value": 52.1
}
]
}
}
Available Metrics
The following metrics are typically available:
- cpu - CPU usage percentage
- memory - Memory usage statistics
- disk - Disk I/O and usage
- network - Network traffic statistics
The exact available metrics may vary depending on the device type and monitoring configuration. Check the API response for available metric types.
Error Responses
If an error occurs, the API will return a response with code: "FAULT":
{
"code": "FAULT",
"message": "Error message",
"error": {
"field1": "Error message 1",
"field2": "Error message 2"
}
}
Common error scenarios:
- Invalid device ID
- Invalid metric type
- Permission denied
- No monitoring data available for the specified time range