Get Stat for Several Entities

POST /node/api/stat/search

Returns an array of stats for entities of the specified type. Note that if you don't have permissions to a certain entity, its stat won't be retrieved.

Request parameters

Body parameters

...

Response description

...

Examples

Request examples

Bash
JavaScript
NodeJS
Python
1
login=<...>
2
password=<...>
3
saymon_hostname=<...>
4
url=https://$saymon_hostname/node/api/stat/search
5
6
curl -X POST $url -u $login:$password \
7
-H "Content-Type: application/json" \
8
--data '[ \
9
{"type": "objects", "id": "5e21b85b308c3c66d64e07d2"}, \
10
{"type": "objects", "id": "5ae321a8fa62b9189509f51c"} \
11
]'
Copied!
1
let login = <...>
2
let password = <...>
3
let saymonHostname = <...>
4
let path = "/node/api/stat/search";
5
let auth = "Basic " + btoa(login + ":" + password);
6
7
let headers = new Headers();
8
headers.append("Content-Type", "application/json");
9
headers.append("Authorization", auth);
10
11
let data = JSON.stringify([
12
{
13
"type": "objects",
14
"id": "5e21b85b308c3c66d64e07d2"
15
},
16
{
17
"type": "objects",
18
"id": "5ae321a8fa62b9189509f51c"
19
}
20
]);
21
22
let requestOptions = {
23
method: "POST",
24
headers: headers,
25
body: data
26
};
27
28
fetch(saymonHostname + path, requestOptions)
29
.then(response => response.text())
30
.then(result => console.log(result))
31
.catch(error => console.log("error", error));
Copied!
1
const http = require("http");
2
3
let login = <...>
4
let password = <...>
5
let saymonHostname = <...>
6
let path = "/node/api/stat/search";
7
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
8
9
let options = {
10
"method": "POST",
11
"hostname": saymonHostname,
12
"headers": {
13
"Authorization": auth,
14
"Content-Type": "application/json"
15
},
16
"path": path
17
};
18
19
let req = http.request(options, function (res) {
20
let chunks = [];
21
22
res.on("data", function (chunk) {
23
chunks.push(chunk);
24
});
25
26
res.on("end", function (chunk) {
27
let body = Buffer.concat(chunks);
28
console.log(body.toString());
29
});
30
31
res.on("error", function (error) {
32
console.error(error);
33
});
34
});
35
36
let data = JSON.stringify([
37
{
38
"type": "objects",
39
"id": "5e21b85b308c3c66d64e07d2"
40
},
41
{
42
"type": "objects",
43
"id": "5ae321a8fa62b9189509f51c"
44
}
45
]);
46
47
req.write(data);
48
req.end();
Copied!
1
import requests
2
3
login = <...>
4
password = <...>
5
saymon_hostname = <...>
6
url = "https://" + saymon_hostname + "/node/api/stat/search"
7
8
body = [
9
{"type": "objects", "id": "5e21b85b308c3c66d64e07d2"},
10
{"type": "objects", "id": "5ae321a8fa62b9189509f51c"}
11
]
12
13
response = requests.request("POST", url, json=body, auth=(login, password))
14
print(response.text)
Copied!

Response example

1
[
2
{
3
"entityId": "5e21b85b308c3c66d64e07d2",
4
"entityType": "obj",
5
"taskType": "cpu",
6
"period": 1000,
7
"timestamp": 1584361056441,
8
"agentId": "5e21b85b308c3c66d64e07c8",
9
"agentVersion": "4.2.69-SNAPSHOT",
10
"agentBuild": "866cc",
11
"payload": {
12
"averageCpuLoad": {
13
"oneMinuteAverageLoad": 2.36,
14
"fiveMinutesAverageLoad": 1.5,
15
"fifteenMinutesAverageLoad": 0.97
16
},
17
"cpuInformation": {
18
"vendor": "Intel",
19
"model": "Core(TM) i5-7400 CPU @ 3.00GHz",
20
"mhz": 3500,
21
"cacheSize": 6144,
22
"totalCores": 4,
23
"totalSockets": 4,
24
"coresPerSocket": 16
25
},
26
"percentageUsage": {
27
"user": 6.297229219143577,
28
"system": 2.0151133501259446,
29
"nice": 0,
30
"idle": 91.43576826196474,
31
"wait": 0,
32
"irq": 0,
33
"softIrq": 0.2518891687657431,
34
"stolen": 0,
35
"combined": 8.312342569269521
36
}
37
}
38
},
39
{
40
"entityId": "5ae321a8fa62b9189509f51c",
41
"entityType": "obj",
42
"taskType": "ram",
43
"period": 60000,
44
"timestamp": 1587728030413,
45
"agentId": "5ae1f5df226d1548084c4b7c",
46
"agentVersion": "4.2.68",
47
"agentBuild": "84a9a",
48
"payload": {
49
"MEM": {
50
"memoryType": "MEM",
51
"bytesTotal": 7977361408,
52
"bytesUsed": 6253006848,
53
"bytesAvailable": 1724354560,
54
"percentUsed": 78.38439965537036
55
},
56
"SWAP": {
57
"memoryType": "SWAP",
58
"bytesTotal": 23009746944,
59
"bytesUsed": 13869596672,
60
"bytesAvailable": 9140150272,
61
"percentUsed": 60.277050007351875
62
},
63
"TOTAL": {
64
"memoryType": "TOTAL",
65
"bytesTotal": 30987108352,
66
"bytesUsed": 20122603520,
67
"bytesAvailable": 10864504832,
68
"percentUsed": 64.9386296114372
69
}
70
}
71
}
72
]
Copied!