Ad Widget

Collapse

Включение режима обслуживания для хоста с определённым тегом и значением

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • IgorM
    Junior Member
    • Jul 2023
    • 5

    #1

    Включение режима обслуживания для хоста с определённым тегом и значением

    День добрый
    использую Zabbix 6.2
    при выполнении запроса

    curl -X POST -H "Content-Type: application/json" -d '{
    "jsonrpc": "2.0",
    "method": "maintenance.create",
    "params": {
    "name": "Maintenance for landing service",
    "maintenance_type": 0,
    "active_since": 1678099200, // Unix timestamp for July 5, 2023, 12:00 UTC
    "active_till": 1678106400, // Unix timestamp for July 5, 2023, 14:00 UTC
    "groupids": [],
    "hostids": [],
    "tags": [
    {
    "tag": "systemid",
    "value": "landing"
    }
    },
    "auth": "**",
    "id": 1
    }' https://zabbix.**/api_jsonrpc.php


    при выполнении получаю ошибку
    {"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Invalid JSON. An error occurred on the server while parsing the JSON text."},"id":null}
  • Answer selected by IgorM at 10-07-2023, 08:47.
    IgorM
    Junior Member
    • Jul 2023
    • 5

    рабочий пример

    curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc": "2.0", "method": "maintenance.create", "params": {"name": "Sunday maintenance", "active_since": 1688551200, "active_till": 1688558400, "tags_evaltype": 0, "groups": [{"groupid": "31"}], "timeperiods": [{"period": 3600, "timeperiod_type": 0}], "tags": [{"tag": "systimid", "operator": "0", "value": "landing"}]}, "auth": "**", "id": 3}' "https://zabbix.**/api_jsonrpc.php"

    Comment

    • IgorM
      Junior Member
      • Jul 2023
      • 5

      #2
      пример для curl

      curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc": "2.0", "method": "maintenance.create", "params": { "name": "Sunday maintenance", "active_since": 1688551200, "active_till": 1688558400, "tags_evaltype": 0, "groups": [ { "groupid": "31" } ], "tags": [ { "tag": "systimid", "operator": "0", "value": "landing" } ] }, "id": 2, "auth": "**f"}' "https://zabbix.**/api_jsonrpc.php"

      получаю ошибку
      {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params.","data":"Invalid parameter "/1": the parameter "timeperiods" is missing."},"id":2}%

      Comment

      • IgorM
        Junior Member
        • Jul 2023
        • 5

        #3
        рабочий пример

        curl --header "Content-Type: application/json" --request POST --data '{"jsonrpc": "2.0", "method": "maintenance.create", "params": {"name": "Sunday maintenance", "active_since": 1688551200, "active_till": 1688558400, "tags_evaltype": 0, "groups": [{"groupid": "31"}], "timeperiods": [{"period": 3600, "timeperiod_type": 0}], "tags": [{"tag": "systimid", "operator": "0", "value": "landing"}]}, "auth": "**", "id": 3}' "https://zabbix.**/api_jsonrpc.php"

        Comment

        Working...