Тестирование свойств мониторинга

Тестирует свойства мониторинга используя свойства из тела запроса на объекте с указанным ID.

Запрос

HTTP Запрос

POST /node/api/objects/:objectId/monitoring/test

Права

objectPermissions & (manage-properties | manage-objects)

Параметры пути

Параметр Тип Описание

objectId

String
обязательно

ID объекта, на котором система выполнит тест.

Параметры тела

Тело запроса использует модель Свойство.

Тело запроса

Тело запроса содержит свойства мониторинга, которые будут использоваться для тестирования проверки.

[
    {
        "name": "AgentId",
        "value": "66f14e6a55f73e02aa881125"
    },
    {
        "name": "TaskPeriodValue",
        "destroy": true
    },
    {
        "name": "TaskPeriodUnit",
        "value": "seconds"
    },
    {
        "name": "TaskType",
        "value": "ping"
    },
    {
        "name": "PingHost",
        "value": "example.com"
    },
    {
        "name": "PingPacketsCount",
        "value": "10"
    },
    {
        "name": "PingTimeout",
        "value": "50"
    },
    {
        "name": "PingSrcInterface",
        "destroy": true
    }
]

Ответ

Возвращает данные мониторинга. Подробная информация о модели доступна в статье Данные мониторинга.

Пример

Запрос

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
object_id=<...>
url=https://$saymon_hostname/node/api/objects/$object_id/monitoring/test

curl -X POST $url -u $login:$password \
    -H "Content-Type: application/json" \
    -d @- <<EOF
[
    {
        "name": "AgentId",
        "value": "66f14e6a55f73e02aa881125"
    },
    {
        "name": "TaskPeriodValue",
        "destroy": true
    },
    {
        "name": "TaskPeriodUnit",
        "value": "seconds"
    },
    {
        "name": "TaskType",
        "value": "ping"
    },
    {
        "name": "PingHost",
        "value": "example.com"
    },
    {
        "name": "PingPacketsCount",
        "value": "10"
    },
    {
        "name": "PingTimeout",
        "value": "50"
    },
    {
        "name": "PingSrcInterface",
        "destroy": true
    }
]
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let objectId = <...>
let path = "/node/api/objects/" + objectId + "/monitoring/test";
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", auth);

let data = JSON.stringify([
    {
        "name": "AgentId",
        "value": "66f14e6a55f73e02aa881125"
    },
    {
        "name": "TaskPeriodValue",
        "destroy": true
    },
    {
        "name": "TaskPeriodUnit",
        "value": "seconds"
    },
    {
        "name": "TaskType",
        "value": "ping"
    },
    {
        "name": "PingHost",
        "value": "example.com"
    },
    {
        "name": "PingPacketsCount",
        "value": "10"
    },
    {
        "name": "PingTimeout",
        "value": "50"
    },
    {
        "name": "PingSrcInterface",
        "destroy": true
    }
]);

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 request = require("request");
const fs = require("fs");

let login = <...>
let password = <...>
let saymon_hostname = <...>
let object_id = <...>
let url = "https://" + saymon_hostname + "/node/api/objects/" +
    object_id + "/monitoring/test";

let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let body = JSON.stringify([
    {
        "name": "AgentId",
        "value": "66f14e6a55f73e02aa881125"
    },
    {
        "name": "TaskPeriodValue",
        "destroy": true
    },
    {
        "name": "TaskPeriodUnit",
        "value": "seconds"
    },
    {
        "name": "TaskType",
        "value": "ping"
    },
    {
        "name": "PingHost",
        "value": "example.com"
    },
    {
        "name": "PingPacketsCount",
        "value": "10"
    },
    {
        "name": "PingTimeout",
        "value": "50"
    },
    {
        "name": "PingSrcInterface",
        "destroy": true
    }
]);

let options = {
    method: "POST",
    url: url,
    headers: {
        Authorization: auth
    },
    json : body
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);
});
import requests
import json

login = <...>
password = <...>
saymon_hostname = <...>
object_id = <...>
url = "https://" + saymon_hostname + "/node/api/objects/" + \
    object_id + "/monitoring/test"

body = [
    {
        "name": "AgentId",
        "value": "66f14e6a55f73e02aa881125"
    },
    {
        "name": "TaskPeriodValue",
        "destroy": true
    },
    {
        "name": "TaskPeriodUnit",
        "value": "seconds"
    },
    {
        "name": "TaskType",
        "value": "ping"
    },
    {
        "name": "PingHost",
        "value": "example.com"
    },
    {
        "name": "PingPacketsCount",
        "value": "10"
    },
    {
        "name": "PingTimeout",
        "value": "50"
    },
    {
        "name": "PingSrcInterface",
        "destroy": true
    }
]

response = requests.request("POST", url, json=body, auth=(login, password))
print(response.text)

Ответ

{
    "entityId": "5e21b85b308c3c66d64e07c8",
    "entityType": 1,
    "taskType": "agentWatchdog",
    "period": 60000,
    "timestamp": 1585040374498,
    "agentId": "5e21b85b308c3c66d64e07c8",
    "agentVersion": "4.2.69-SNAPSHOT",
    "agentBuild": "866cc",
    "payload": {
        "runtimeName": "OpenJDK Runtime Environment",
        "runtimeVersion": "1.8.0_242-8u242-b08-0ubuntu3~16.04-b08",
        "totalMemory": 267911168,
        "freeMemory": 226294168,
        "maxMemory": 1830813696,
        "usedHeapMemory": 41617000,
        "usedNonHeapMemory": 36068184,
        "processCpuLoad": 0.0036666666666666666,
        "numberOfThreads": 10,
        "snmpTrapsPerSecond": 0,
        "statNotificationsPerSecond": 0,
        "tasksNumber": 1,
        "hostName": "host",
        "networkInterfaces": {
            "IPv6": [
                "fe80:0:0:0:24a9:1aff:fecb:3722%veth3c89613",
                "fe80:0:0:0:f45b:6dff:fe6e:5497%veth9f402c5",
                "fe80:0:0:0:42:ffff:fe77:1b87%docker0",
                "fe80:0:0:0:3e4d:25b:3be:d798%enp4s0"
            ],
            "IPv4": [
                "127.0.0.1",
                "127.0.0.2"
            ]
        }
    }
}