Set Link’s Monitoring Properties

Sets monitoring properties for a link with the specified ID.

This request allows you to update multiple monitoring properties at once. Cannot be used to update other properties of a link.

Request

HTTP Request

POST /node/api/links/:id/monitoring

Permissions

linkPermissions & (manage-properties | manage-links)

Path parameters

Parameter Type Description

id

String
required

The ID of a link for which a property should be updated.

Body parameters

This request uses the Property model:

Field Type Description

name

String
required

Property’s name.

value

String
required

Property’s value.

Request body

Request body contains monitoring settings for the specified link. Note that you must include all monitoring settings you want applied to a link to avoid losing data.

[
    {
        "name": "AgentId",
        "value": "66ec44c2522580097d15bec6"
    },
    {
        "name": "TaskPeriodUnit",
        "value": "seconds"
    },
    {
        "name": "TaskType",
        "value": "ping"
    },
    {
        "name": "PingHost",
        "value": "example.com"
    },
    {
        "name": "PingPacketsCount",
        "value": "4"
    },
    {
        "name": "PingTimeout",
        "value": "10"
    }
]

Response

Response body is empty.

Example

Request

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
link_id=<...>
url=https://$saymon_hostname/node/api/links/$link_id/monitoring

curl -X POST $url -u $login:$password \
    -H "Content-Type: application/json" \
    -d @- <<EOF
[
    {
        "name": "AgentId",
        "value": "66ec44c2522580097d15bec6"
    },
    {
        "name": "TaskPeriodUnit",
        "value": "seconds"
    },
    {
        "name": "TaskType",
        "value": "ping"
    },
    {
        "name": "PingHost",
        "value": "example.com"
    },
    {
        "name": "PingPacketsCount",
        "value": "4"
    },
    {
        "name": "PingTimeout",
        "value": "10"
    }
]
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let linkId = <...>
let path = "/node/api/links/" + linkId + "/monitoring";
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": "66ec44c2522580097d15bec6"
    },
    {
        "name": "TaskPeriodUnit",
        "value": "seconds"
    },
    {
        "name": "TaskType",
        "value": "ping"
    },
    {
        "name": "PingHost",
        "value": "example.com"
    },
    {
        "name": "PingPacketsCount",
        "value": "4"
    },
    {
        "name": "PingTimeout",
        "value": "10"
    }
]);

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 linkId = <...>
let path = "/node/api/links/" + linkId + "/monitoring";
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([
    {
        "name": "AgentId",
        "value": "66ec44c2522580097d15bec6"
    },
    {
        "name": "TaskPeriodUnit",
        "value": "seconds"
    },
    {
        "name": "TaskType",
        "value": "ping"
    },
    {
        "name": "PingHost",
        "value": "example.com"
    },
    {
        "name": "PingPacketsCount",
        "value": "4"
    },
    {
        "name": "PingTimeout",
        "value": "10"
    }
]);

req.write(data);
req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
link_id = <...>
url = "https://" + saymon_hostname + "/node/api/links/" + \
    link_id + "/monitoring"

body = [
    {
        "name": "AgentId",
        "value": "66ec44c2522580097d15bec6"
    },
    {
        "name": "TaskPeriodUnit",
        "value": "seconds"
    },
    {
        "name": "TaskType",
        "value": "ping"
    },
    {
        "name": "PingHost",
        "value": "example.com"
    },
    {
        "name": "PingPacketsCount",
        "value": "4"
    },
    {
        "name": "PingTimeout",
        "value": "10"
    }
]

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