Получить список пользовательских сенсоров

Получить список пользовательских сенсоров

Получить список пользовательских сенсоров ​

Возвращает список пользовательских сенсоров.

NOTE

Мониторинг с помощью пользовательских сенсоров выполняется на агентах.

Запрос ​

HTTP Запрос ​

text
GET /node/api/monitoring-custom-tasks

Права ​

text
manage-service-properties

Тело запроса ​

Тело запроса пустое.

Ответ ​

Возвращает список всех пользовательских сенсоров в системе.

Пользовательские сенсоры имеют следующие поля:

ПолеТипОписание
idStringID сенсора. ID должен быть частью пути до скрипта сенсора.
titleStringНазвание проверки.
iconStringИконка проверки, используемой в веб-интерфейсе.
argsArray<Object>Массив аргументов сенсора. Аргументы описаны в разделе Агрументы сенсора.

Агрументы сенсора ​

ПолеТипОписание
idStringАгрумент, который передаётся в скрипт.
nameStringИмя аргумента.
descriptionStringОписание аргумента.
requiredBooleanЯвляется ли этот аргумент обязательным?
typeStringТип аргумента. Возможные значения select (выбор значений), text (текстовое поле), password (пароль).
optionsArray<Object>Массив значений, из которых можно выбирать. Доступен только для типа select.
options.valueStringЗначение опции.
options.descriptionStringОписание опции.

Пример ​

Запрос ​

  • Bash
  • JavaScript
  • NodeJS
  • Python
bash
login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/monitoring-custom-tasks

curl -X GET $url -u $login:$password
javascript
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/monitoring-custom-tasks";
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Authorization", auth);

let requestOptions = {
    method: "GET",
    headers: headers
};

fetch(saymonHostname + path, requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log("error", error));
javascript
const http = require("http");

let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/monitoring-custom-tasks/";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    "method": "GET",
    "hostname": saymonHostname,
    "headers": {
        "Authorization": auth
    },
    "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);
    });
});

req.end();
python
import requests

login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/monitoring-custom-tasks"

response = requests.request("GET", url, auth=(login, password))
print(response.text)

Ответ ​

json
[
    {
        "title": "Custom probe example",
        "icon": "fa fa-folder fa-fw",
        "args": [
            {
                "name": "Unnamed (positional) argument"
            },
            {
                "name": "Named argument",
                "id": "--name"
            },
            {
                "name": "Argument with description",
                "description": "Argument description",
                "id": "--description"
            },
            {
                "name": "Argument with default value",
                "description": "Argument description",
                "id": "--defval",
                "default": "default_value"
            },
            {
                "name": "Required argument",
                "description": "This field is required to fill in",
                "id": "--required",
                "required": true
            },
            {
                "name": "Type - Text",
                "description": "This and all above fields have got text type",
                "id": "--text",
                "type": "text"
            },
            {
                "name": "Type - Text Area",
                "description": "This field is text area. \nIt is resizable in most browsers. \nAnd allows to enter multiline texts.",
                "id": "--textarea",
                "type": "textarea"
            },
            {
                "name": "Type - Checkbox",
                "description": "This is the checkbox type",
                "id": "--checkbox",
                "type": "checkbox"
            },
            {
                "name": "Type - Password",
                "description": "This is the password field",
                "id": "--pass",
                "default": "qwerty",
                "type": "password"
            },
            {
                "name": "Type - Select",
                "description": "This is the select type. This description is not displayed in the web interface. Use description for each option instead.",
                "id": "--select",
                "default": "option2",
                "type": "select",
                "options": [
                    {
                        "description": "== Not selected =="
                    },
                    {
                        "value": "option1",
                        "description": "OK"
                    },
                    {
                        "description": "== Divider =="
                    },
                    {
                        "value": "option2",
                        "description": "Warning"
                    },
                    {
                        "value": "description"
                    }
                ]
            }
        ]
    }
    {
        "title": "Check SSH",
        "icon": "fa fa-folder fa-fw",
        "args": [
            {
                "name": "Host IP-address or DNS name"
            },
            {
                "name": "Port",
                "id": "-p"
            }
        ],
        "id": "Extras/check_ssh.sh"
    },
    ...
]

Смотрите также ​