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

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

Запрос

HTTP Запрос

POST /node/api/links/:linkId/monitoring/test

Права

linkPermissions & (manage-properties | manage-link)

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

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

linkId

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=<...>
link_id=<...>
url=https://$saymon_hostname/node/api/links/$link_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 linkId = <...>
let path = "/node/api/links/" + linkId + "/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 link_id = <...>
let url = "https://" + saymon_hostname + "/node/api/links/" +
    link_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 = <...>
link_id = <...>
url = "https://" + saymon_hostname + "/node/api/links/" + \
    link_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)