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

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

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

Запрос

HTTP Запрос

GET /node/api/monitoring-custom-tasks

Права

manage-service-properties

Тело запроса

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

Ответ

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

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

Поле Тип Описание

id

String

ID сенсора. ID должен быть частью пути до скрипта сенсора.

title

String

Название проверки.

icon

String

Иконка проверки, используемой в веб-интерфейсе.

args

Array<Object>

Массив аргументов сенсора. Аргументы описаны в разделе Агрументы сенсора.

excludeForClasses

Array<String>

Массив ID классов, для которых сенсор не отображается в списке сенсоров.

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

Поле Тип Описание

id

String

Агрумент, который передаётся в скрипт.

name

String

Имя аргумента.

description

String

Описание аргумента.

required

Boolean

Является ли этот аргумент обязательным?

type

String

Тип аргумента. Возможные значения select (выбор значений), text (текстовое поле), password (пароль).

options

Array<Object>

Массив значений, из которых можно выбирать. Доступен только для типа select.

options.value

String

Значение опции.

options.description

String

Описание опции.

Пример

Запрос

  • Bash

  • JavaScript

  • NodeJS

  • Python

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

curl -X GET $url -u $login:$password
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));
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();
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)

Ответ

[
    {
        "title": "Custom probe example",
        "icon": "fa fa-folder fa-fw",
        "excludeForClasses": [
            1,
            2
        ],
        "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"
    },
    ...
]