Set Link's Stat

POST /node/api/links/:id/stat

Sets agent's data (stat) for a link.
Permissions: linkPermissions.

Request parameters

Path parameters

Parameter
Type
Description
id
string
required
The ID of a link for which stat should be set.

Response description

The response body is empty.

Request examples

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