Get Stat for Several Entities
Returns an array of stats for entities of the specified type.
Note
If you don't have permissions to a certain entity, its stat won't be retrieved.
Request
HTTP Request
Path parameters
No parameters required.
Body parameters
Request body contains an array of entities for which to return stats. This request allows you to search stats in both links and objects at the same time.
Each entry has the following parameters:
Parameter | Type | Description |
---|---|---|
type | String | Type of entity for which to retrieve stats. Possible types are objects and links . |
id | String | ID of entity for which to retrieve stats. |
Request body
Response
Returns an array of stats for objects specified in the request body.
The entity won't be included in the response in the following cases:
- specified entity has no stats.
- specified entity doesn't exist.
- entity's type doesn't match the `type` parameter in the request body.
Parameter | Type | Description |
---|---|---|
entityId | String | The ID of a link whose stats were retrieved. |
entityType | String | The type of an entity whose stats were retrieved. Possible values are obj and link . |
taskType | String | The probe type. See the Monitoring and checks settings - probes section on the SAYMON wiki for more information. |
period | Integer | The period between executing the monitoring processes (in milliseconds). |
timestamp | Integer | Timestamp of when the agent started performing the selected monitoring process. |
agentId | String | The ID of the agent. |
agentVersion | String | The version of the agent. |
agentBuild | String | The build number of the agent. |
Example
Request
login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/stat/search
curl -X POST $url -u $login:$password \
-H "Content-Type: application/json" \
--data '[ \
{"type": "objects", "id": "5e21b85b308c3c66d64e07d2"}, \
{"type": "objects", "id": "5ae321a8fa62b9189509f51c"} \
]'
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/stat/search";
let auth = "Basic " + btoa(login + ":" + password);
let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", auth);
let data = JSON.stringify([
{
"type": "objects",
"id": "5e21b85b308c3c66d64e07d2"
},
{
"type": "objects",
"id": "5ae321a8fa62b9189509f51c"
}
]);
let requestOptions = {
method: "POST",
headers: headers,
body: data
};
fetch(saymonHostname + path, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
const http = require("http");
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/stat/search";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let options = {
"method": "POST",
"hostname": saymonHostname,
"headers": {
"Authorization": auth,
"Content-Type": "application/json"
},
"path": path
};
let req = http.request(options, function (res) {
let chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
let body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
let data = JSON.stringify([
{
"type": "objects",
"id": "5e21b85b308c3c66d64e07d2"
},
{
"type": "objects",
"id": "5ae321a8fa62b9189509f51c"
}
]);
req.write(data);
req.end();
import requests
login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/stat/search"
body = [
{"type": "objects", "id": "5e21b85b308c3c66d64e07d2"},
{"type": "objects", "id": "5ae321a8fa62b9189509f51c"}
]
response = requests.request("POST", url, json=body, auth=(login, password))
print(response.text)
Response
[
{
"entityId": "5e21b85b308c3c66d64e07d2",
"entityType": "obj",
"taskType": "cpu",
"period": 1000,
"timestamp": 1584361056441,
"agentId": "5e21b85b308c3c66d64e07c8",
"agentVersion": "4.2.69-SNAPSHOT",
"agentBuild": "866cc",
"payload": {
"averageCpuLoad": {
"oneMinuteAverageLoad": 2.36,
"fiveMinutesAverageLoad": 1.5,
"fifteenMinutesAverageLoad": 0.97
},
"cpuInformation": {
"vendor": "Intel",
"model": "Core(TM) i5-7400 CPU @ 3.00GHz",
"mhz": 3500,
"cacheSize": 6144,
"totalCores": 4,
"totalSockets": 4,
"coresPerSocket": 16
},
"percentageUsage": {
"user": 6.297229219143577,
"system": 2.0151133501259446,
"nice": 0,
"idle": 91.43576826196474,
"wait": 0,
"irq": 0,
"softIrq": 0.2518891687657431,
"stolen": 0,
"combined": 8.312342569269521
}
}
},
{
"entityId": "5ae321a8fa62b9189509f51c",
"entityType": "obj",
"taskType": "ram",
"period": 60000,
"timestamp": 1587728030413,
"agentId": "5ae1f5df226d1548084c4b7c",
"agentVersion": "4.2.68",
"agentBuild": "84a9a",
"payload": {
"MEM": {
"memoryType": "MEM",
"bytesTotal": 7977361408,
"bytesUsed": 6253006848,
"bytesAvailable": 1724354560,
"percentUsed": 78.38439965537036
},
"SWAP": {
"memoryType": "SWAP",
"bytesTotal": 23009746944,
"bytesUsed": 13869596672,
"bytesAvailable": 9140150272,
"percentUsed": 60.277050007351875
},
"TOTAL": {
"memoryType": "TOTAL",
"bytesTotal": 30987108352,
"bytesUsed": 20122603520,
"bytesAvailable": 10864504832,
"percentUsed": 64.9386296114372
}
}
}
]