Skip to content

Get Stat for Several Entities

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

HTTP Request

POST /node/api/stat/search

Path parameters

No parameters required.

Body parameters

Work in Progress

This topic is a work in progress and may be incomplete.

Request body

[
    {
        "type": "objects",
        "id": "5e21b85b308c3c66d64e07d2"
    },
    {
        "type": "objects",
        "id": "5ae321a8fa62b9189509f51c"
    }
]

Response

Work in Progress

This topic is a work in progress and may be incomplete.

Examples

Request examples

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 example

[
    {
        "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
            }
        }
    }
]